forked from joonson/syncnet_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_syncnet.py
executable file
·45 lines (31 loc) · 1.55 KB
/
run_syncnet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
#-*- coding: utf-8 -*-
import time, pdb, argparse, subprocess, pickle, os, gzip, glob
from SyncNetInstance import *
# ==================== PARSE ARGUMENT ====================
parser = argparse.ArgumentParser(description = "SyncNet");
parser.add_argument('--initial_model', type=str, default="data/syncnet_v2.model", help='');
parser.add_argument('--batch_size', type=int, default='20', help='');
parser.add_argument('--vshift', type=int, default='15', help='');
parser.add_argument('--data_dir', type=str, default='data/work', help='');
parser.add_argument('--videofile', type=str, default='', help='');
parser.add_argument('--reference', type=str, default='', help='');
opt = parser.parse_args();
setattr(opt,'avi_dir',os.path.join(opt.data_dir,'pyavi'))
setattr(opt,'tmp_dir',os.path.join(opt.data_dir,'pytmp'))
setattr(opt,'work_dir',os.path.join(opt.data_dir,'pywork'))
setattr(opt,'crop_dir',os.path.join(opt.data_dir,'pycrop'))
# ==================== LOAD MODEL AND FILE LIST ====================
s = SyncNetInstance();
s.loadParameters(opt.initial_model);
print("Model %s loaded."%opt.initial_model);
flist = glob.glob(os.path.join(opt.crop_dir,opt.reference,'0*.avi'))
flist.sort()
# ==================== GET OFFSETS ====================
dists = []
for idx, fname in enumerate(flist):
offset, conf, dist = s.evaluate(opt,videofile=fname)
dists.append(dist)
# ==================== PRINT RESULTS TO FILE ====================
with open(os.path.join(opt.work_dir,opt.reference,'activesd.pckl'), 'wb') as fil:
pickle.dump(dists, fil)