forked from wzmsltw/BSN-boundary-sensitive-network.pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_pgm_results_jobs.py
67 lines (53 loc) · 2.17 KB
/
gen_pgm_results_jobs.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Run the jobs that generate PGM features.
Example commands:
python gen_pgm_results_jobs.py
"""
from copy import deepcopy
import os
import re
import sys
from run_on_cluster import fb_run_batch
from tem_jobs import run
email = 'cinjon@nyu.edu'
code_directory = '/private/home/cinjon/Code/BSN-boundary-sensitive-network.pytorch'
base_dir = '/checkpoint/cinjon/spaceofmotion/bsn'
tem_dir = os.path.join(base_dir, 'teminf')
tem_results_dir = os.path.join(tem_dir, 'results')
pgm_proposals_dir = os.path.join(base_dir, 'pgmprops')
pgm_feats_dir = os.path.join(base_dir, 'pgmfeats')
regex = re.compile('.*(\d{5}).*')
check = 0
for tem_results_subdir in os.listdir(tem_results_dir):
counter = int(regex.match(tem_results_subdir).groups()[0])
print(tem_results_dir, tem_results_subdir, counter)
job = run(find_counter=counter)
if type(job) == tuple:
job = job[1]
name = job['name']
for ckpt_subdir in os.listdir(os.path.join(tem_results_dir, tem_results_subdir)):
_job = deepcopy(job)
if 'thumos' in _job['dataset']:
_job['video_anno'] = os.path.join(_job['video_info'], 'thumos_anno_action.json')
elif 'gymnastics' in _job['dataset']:
_job['video_anno'] = os.path.join(_job['video_info'], 'gymnastics_anno_action.sep052019.json')
_job['num_gpus'] = 0
_job['num_cpus'] = 48
_job['pgm_thread'] = 40
_job['gb'] = 64
_job['time'] = 3
_job['tem_results_dir'] = os.path.join(tem_results_dir, tem_results_subdir, ckpt_subdir)
propdir = os.path.join(pgm_proposals_dir, tem_results_subdir, ckpt_subdir)
if not os.path.exists(propdir):
os.makedirs(propdir)
_job['pgm_proposals_dir'] = propdir
featsdir = os.path.join(pgm_feats_dir, tem_results_subdir, ckpt_subdir)
if not os.path.exists(featsdir):
os.makedirs(featsdir)
_job['pgm_features_dir'] = featsdir
_job['module'] = 'PGM'
_job['mode'] = 'pgm'
_job['name'] = '%s.%s' % (name, ckpt_subdir)
fb_run_batch(_job, counter, email, code_directory)
check += 1
print('\n')
print("Count: ", check)