-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathground.py
68 lines (52 loc) · 2.25 KB
/
ground.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
68
# ====================================================
# @Author : Xiao Junbin
# @Email : [email protected]
# @File : ground.py
# ====================================================
from ground_relation import *
from dataloader.ground_loader import *
from dataloader.build_vocab import Vocabulary
import os.path as osp
import pickle as pkl
from argparse import ArgumentParser
batch_size = 32
lr = 1e-4
num_workers = 8
epoch_num = 10
cuda = True
nframes, nbbox = 120, 40
vis_step = 200
save_step = 10000
visual_dim = 2048+5 #visual appearance+bbox
dataset = 'vidvrd/'
root_dir = '/path/to/workspace/' #this directory includes two folders: ground_data and vRGV
video_feature_path = osp.join(root_dir, 'ground_data/{}/frame_feature/'.format(dataset))
video_feature_cache = osp.join(root_dir, 'ground_data/{}/video_feature/'.format(dataset))
sample_list_path = osp.join('dataset/', dataset)
vocab_file = osp.join(sample_list_path, 'vocab.pkl')
checkpoint_path = osp.join('models', dataset)
model_prefix = 'visual_bbox_trans_temp2'
def main(args):
with open(vocab_file, 'rb') as fp:
vocab = pkl.load(fp)
data_loader = RelationLoader(batch_size, num_workers, video_feature_path, video_feature_cache,
sample_list_path, vocab, nframes, nbbox, visual_dim, True, False)
train_loader, val_loader = data_loader.run(mode=args.mode)
ground_relation = GroundRelation(vocab, train_loader, val_loader, checkpoint_path, model_prefix, vis_step, save_step, visual_dim,
lr, batch_size, epoch_num, cuda)
mode = args.mode
if mode == 'train':
ground_relation.run(pretrain=False)
elif mode == 'val':
#return relation-aware spatio-temporal attention for dynamicly linking object proposals into trajectories
save_name = '../ground_data/results/vidvrd_batch.json'
ground_relation.ground_attention(7, save_name)
if __name__ == "__main__":
torch.backends.cudnn.enabled = False
torch.manual_seed(666)
torch.cuda.manual_seed(666)
torch.backends.cudnn.benchmark = True
parser = ArgumentParser()
parser.add_argument('--mode', dest='mode', type=str, default='train', help='train or val')
args = parser.parse_args()
main(args)