-
Notifications
You must be signed in to change notification settings - Fork 1
/
slowfast_kinetics400-pretrained-r50_8xb6-8x8x1-cosine-10e_ava22-rgb-drink-0725.py
216 lines (204 loc) · 7.01 KB
/
slowfast_kinetics400-pretrained-r50_8xb6-8x8x1-cosine-10e_ava22-rgb-drink-0725.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
default_scope = 'mmaction'
default_hooks = dict(
runtime_info=dict(type='RuntimeInfoHook'),
timer=dict(type='IterTimerHook'),
logger=dict(type='LoggerHook', interval=10, ignore_last=False),
param_scheduler=dict(type='ParamSchedulerHook'),
checkpoint=dict(type='CheckpointHook', interval=1, save_best='auto'),
sampler_seed=dict(type='DistSamplerSeedHook'),
sync_buffers=dict(type='SyncBuffersHook'))
env_cfg = dict(
cudnn_benchmark=False,
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
dist_cfg=dict(backend='nccl'))
log_processor = dict(type='LogProcessor', window_size=20, by_epoch=True)
vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
type='ActionVisualizer', vis_backends=[dict(type='LocalVisBackend')])
log_level = 'INFO'
load_from = None
resume = False
# url = 'https://download.openmmlab.com/mmaction/recognition/slowfast/slowfast_r50_8x8x1_256e_kinetics400_rgb/slowfast_r50_8x8x1_256e_kinetics400_rgb_20200716-73547d2b.pth'
# num_classes = 8
# custom_classes = [1, 2, 3, 4, 5, 6, 7]
num_classes = 3
custom_classes = [1, 2]
model = dict(
type='FastRCNN',
_scope_='mmdet',
# init_cfg=None,
init_cfg=dict(
type='Pretrained',
checkpoint="checkpoints/slowfast_r50_8x8x1_256e_kinetics400_rgb_20200716-73547d2b.pth"
),
backbone=dict(
type='mmaction.ResNet3dSlowFast',
resample_rate=4,
speed_ratio=4,
channel_ratio=8,
pretrained=None,
slow_pathway=dict(
type='resnet3d',
depth=50,
pretrained=None,
lateral=True,
conv1_kernel=(1, 7, 7),
dilations=(1, 1, 1, 1),
conv1_stride_t=1,
pool1_stride_t=1,
inflate=(0, 0, 1, 1),
spatial_strides=(1, 2, 2, 1),
fusion_kernel=7),
fast_pathway=dict(
type='resnet3d',
depth=50,
pretrained=None,
lateral=False,
base_channels=8,
conv1_kernel=(5, 7, 7),
conv1_stride_t=1,
pool1_stride_t=1,
spatial_strides=(1, 2, 2, 1))),
roi_head=dict(
type='AVARoIHead',
bbox_roi_extractor=dict(
type='SingleRoIExtractor3D',
roi_layer_type='RoIAlign',
output_size=8,
with_temporal_pool=True),
bbox_head=dict(
type='BBoxHeadAVA',
in_channels=2304,
# num_classes=81,
num_classes=num_classes,
topk=1, # 两类topk=1即可,大于5类按默认topk=(3, 5)
multilabel=True,
dropout_ratio=0.5)),
data_preprocessor=dict(
type='mmaction.ActionDataPreprocessor',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
format_shape='NCTHW'),
train_cfg=dict(
rcnn=dict(
assigner=dict(
type='MaxIoUAssignerAVA',
pos_iou_thr=0.9,
neg_iou_thr=0.9,
min_pos_iou=0.9),
sampler=dict(
type='RandomSampler',
num=32,
pos_fraction=1,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=1.0)),
test_cfg=dict(rcnn=None))
dataset_type = 'AVADataset'
# data_root = 'data/ava_Custom/rawframes' # 生成的视频帧图
# anno_root = 'data/ava_Custom/annotations'
data_root = '../AVADatasetMake-drinkWater/ava_finally/rawframes'
anno_root = '../AVADatasetMake-drinkWater/ava_finally/annotations'
ann_file_train = f'{anno_root}/train.csv'
ann_file_val = f'{anno_root}/train.csv'
exclude_file_train = f'{anno_root}/train_excluded_timestamps.csv'
exclude_file_val = f'{anno_root}/train_excluded_timestamps.csv'
label_file = f'{anno_root}/action_list.pbtxt'
proposal_file_train = f'{anno_root}/dense_proposals_train.pkl'
proposal_file_val = f'{anno_root}/dense_proposals_train.pkl'
file_client_args = dict(io_backend='disk')
train_pipeline = [
# clip_len:输入使用多少帧的片段,对应到输入数据H/NCTHW
# frame_ingerval:输入片段的帧间隔
dict(type='SampleAVAFrames', clip_len=32, frame_interval=1),
dict(type='RawFrameDecode', io_backend='disk'),
dict(type='RandomRescale', scale_range=(256, 320)),
dict(type='RandomCrop', size=256),
# dict(type='Flip', flip_ratio=0.5),
dict(type='FormatShape', input_format='NCTHW', collapse=True),
dict(type='PackActionInputs')
]
val_pipeline = [
dict(
type='SampleAVAFrames', clip_len=32, frame_interval=1, test_mode=True),
dict(type='RawFrameDecode', io_backend='disk'),
dict(type='Resize', scale=(-1, 256)),
dict(type='FormatShape', input_format='NCTHW', collapse=True),
dict(type='PackActionInputs')
]
train_dataloader = dict(
batch_size=2,
num_workers=8,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type=dataset_type,
ann_file=ann_file_train,
exclude_file=exclude_file_train,
pipeline=train_pipeline,
label_file=label_file,
proposal_file=proposal_file_train,
data_prefix=dict(img=data_root),
# 自定义类别(标签、数目)
custom_classes=custom_classes,
num_classes=num_classes,
start_index=1
)
)
val_dataloader = dict(
batch_size=1,
num_workers=8,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
ann_file=ann_file_val,
exclude_file=exclude_file_val,
pipeline=val_pipeline,
label_file=label_file,
proposal_file=proposal_file_val,
data_prefix=dict(img=data_root),
# 自定义类别(标签、数目)
custom_classes=custom_classes,
num_classes=num_classes,
start_index=1,
test_mode=True))
test_dataloader = val_dataloader
val_evaluator = dict(
type='AVAMetric',
ann_file=ann_file_val,
label_file=label_file,
exclude_file=exclude_file_val,
# 自定义类别(标签、数目)
custom_classes=custom_classes,
num_classes=num_classes
)
test_evaluator = val_evaluator
train_cfg = dict(
type='EpochBasedTrainLoop', max_epochs=12, val_begin=1, val_interval=1)
val_cfg = dict(type='ValLoop')
test_cfg = dict(type='TestLoop')
param_scheduler = [
dict(
type='LinearLR',
start_factor=0.1,
by_epoch=True,
begin=0,
end=2,
convert_to_iter_based=True),
dict(
type='CosineAnnealingLR',
T_max=8,
eta_min=0,
by_epoch=True,
begin=2,
end=10,
convert_to_iter_based=True)
]
optim_wrapper = dict(
optimizer=dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=1e-05),
clip_grad=dict(max_norm=40, norm_type=2))
auto_scale_lr = dict(enable=False, base_batch_size=48)
launcher = 'none'
work_dir = '../work_dirs/slowfast_det_rec_drinkWater'
randomness = dict(seed=None, diff_rank_seed=False, deterministic=False)