forked from open-mmlab/mmaction2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsn_activitynet.py
97 lines (94 loc) · 3.21 KB
/
tsn_activitynet.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
_base_ = [
'../../../_base_/models/tsn_r50.py', '../../../_base_/schedules/sgd_50e.py',
'../../../_base_/default_runtime.py'
]
# model settings
model = dict(cls_head=dict(num_classes=200, dropout_ratio=0.8))
# dataset settings
dataset_type = 'RawframeDataset'
data_root = '/home/ubuntu/drive2/ActivityNet/rawframes'
data_root_val = '/home/ubuntu/drive2/ActivityNet/rawframes'
ann_file_train = '/home/ubuntu/drive2/ActivityNet/anet_train_clip.txt'
ann_file_val = '/home/ubuntu/drive2/ActivityNet/anet_val_clip.txt'
ann_file_test = '/home/ubuntu/drive2/ActivityNet/anet_val_clip.txt'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_bgr=False)
train_pipeline = [
dict(type='SampleFrames', clip_len=1, frame_interval=1, num_clips=8),
dict(type='FrameSelector'),
dict(type='Resize', scale=(-1, 256)),
dict(type='RandomResizedCrop'),
dict(type='Resize', scale=(224, 224), keep_ratio=False),
dict(type='Flip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='FormatShape', input_format='NCHW'),
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),
dict(type='ToTensor', keys=['imgs', 'label'])
]
val_pipeline = [
dict(
type='SampleFrames',
clip_len=1,
frame_interval=1,
num_clips=8,
test_mode=True),
dict(type='FrameSelector'),
dict(type='Resize', scale=(-1, 256)),
dict(type='CenterCrop', crop_size=256),
dict(type='Flip', flip_ratio=0),
dict(type='Normalize', **img_norm_cfg),
dict(type='FormatShape', input_format='NCHW'),
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),
dict(type='ToTensor', keys=['imgs'])
]
test_pipeline = [
dict(
type='SampleFrames',
clip_len=1,
frame_interval=1,
num_clips=25,
test_mode=True),
dict(type='FrameSelector'),
dict(type='Resize', scale=(-1, 256)),
dict(type='ThreeCrop', crop_size=256),
dict(type='Flip', flip_ratio=0),
dict(type='Normalize', **img_norm_cfg),
dict(type='FormatShape', input_format='NCHW'),
dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),
dict(type='ToTensor', keys=['imgs'])
]
data = dict(
videos_per_gpu=8,
workers_per_gpu=4,
train=dict(
type=dataset_type,
ann_file=ann_file_train,
data_prefix=data_root,
pipeline=train_pipeline,
with_offset=True,
start_index=0,
filename_tmpl='img_{:05d}.jpg'),
val=dict(
type=dataset_type,
ann_file=ann_file_val,
data_prefix=data_root_val,
pipeline=val_pipeline,
with_offset=True,
start_index=0,
filename_tmpl='img_{:05d}.jpg'),
test=dict(
type=dataset_type,
ann_file=ann_file_test,
data_prefix=data_root_val,
pipeline=test_pipeline,
with_offset=True,
start_index=0,
filename_tmpl='img_{:05d}.jpg'))
evaluation = dict(
interval=5, metrics=['top_k_accuracy', 'mean_class_accuracy'])
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
# runtime settings
work_dir = './work_dirs/vclr/tsn_activitynet/'
load_from = '/home/ubuntu/mmaction2/checkpoints/vclr_mm.pth'
workflow = [('train', 5)]