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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#_base_ = ['../../../_base_/default_runtime.py']
|
| 2 |
+
_base_ = ['default_runtime.py']
|
| 3 |
+
|
| 4 |
+
# runtime
|
| 5 |
+
max_epochs = 270
|
| 6 |
+
stage2_num_epochs = 30
|
| 7 |
+
base_lr = 4e-3
|
| 8 |
+
train_batch_size = 32
|
| 9 |
+
val_batch_size = 32
|
| 10 |
+
|
| 11 |
+
train_cfg = dict(max_epochs=max_epochs, val_interval=10)
|
| 12 |
+
randomness = dict(seed=21)
|
| 13 |
+
|
| 14 |
+
# optimizer
|
| 15 |
+
optim_wrapper = dict(
|
| 16 |
+
type='OptimWrapper',
|
| 17 |
+
optimizer=dict(type='AdamW', lr=base_lr, weight_decay=0.05),
|
| 18 |
+
paramwise_cfg=dict(
|
| 19 |
+
norm_decay_mult=0, bias_decay_mult=0, bypass_duplicate=True))
|
| 20 |
+
|
| 21 |
+
# learning rate
|
| 22 |
+
param_scheduler = [
|
| 23 |
+
dict(
|
| 24 |
+
type='LinearLR',
|
| 25 |
+
start_factor=1.0e-5,
|
| 26 |
+
by_epoch=False,
|
| 27 |
+
begin=0,
|
| 28 |
+
end=1000),
|
| 29 |
+
dict(
|
| 30 |
+
# use cosine lr from 150 to 300 epoch
|
| 31 |
+
type='CosineAnnealingLR',
|
| 32 |
+
eta_min=base_lr * 0.05,
|
| 33 |
+
begin=max_epochs // 2,
|
| 34 |
+
end=max_epochs,
|
| 35 |
+
T_max=max_epochs // 2,
|
| 36 |
+
by_epoch=True,
|
| 37 |
+
convert_to_iter_based=True),
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
# automatically scaling LR based on the actual training batch size
|
| 41 |
+
auto_scale_lr = dict(base_batch_size=512)
|
| 42 |
+
|
| 43 |
+
# codec settings
|
| 44 |
+
codec = dict(
|
| 45 |
+
type='SimCCLabel',
|
| 46 |
+
input_size=(288, 384),
|
| 47 |
+
sigma=(6., 6.93),
|
| 48 |
+
simcc_split_ratio=2.0,
|
| 49 |
+
normalize=False,
|
| 50 |
+
use_dark=False)
|
| 51 |
+
|
| 52 |
+
# model settings
|
| 53 |
+
model = dict(
|
| 54 |
+
type='TopdownPoseEstimator',
|
| 55 |
+
data_preprocessor=dict(
|
| 56 |
+
type='PoseDataPreprocessor',
|
| 57 |
+
mean=[123.675, 116.28, 103.53],
|
| 58 |
+
std=[58.395, 57.12, 57.375],
|
| 59 |
+
bgr_to_rgb=True),
|
| 60 |
+
backbone=dict(
|
| 61 |
+
_scope_='mmdet',
|
| 62 |
+
type='CSPNeXt',
|
| 63 |
+
arch='P5',
|
| 64 |
+
expand_ratio=0.5,
|
| 65 |
+
deepen_factor=1.,
|
| 66 |
+
widen_factor=1.,
|
| 67 |
+
out_indices=(4, ),
|
| 68 |
+
channel_attention=True,
|
| 69 |
+
norm_cfg=dict(type='SyncBN'),
|
| 70 |
+
act_cfg=dict(type='SiLU'),
|
| 71 |
+
init_cfg=dict(
|
| 72 |
+
type='Pretrained',
|
| 73 |
+
prefix='backbone.',
|
| 74 |
+
checkpoint='https://download.openmmlab.com/mmpose/v1/projects/'
|
| 75 |
+
'rtmpose/cspnext-l_udp-aic-coco_210e-256x192-273b7631_20230130.pth' # noqa: E501
|
| 76 |
+
)),
|
| 77 |
+
head=dict(
|
| 78 |
+
type='RTMCCHead',
|
| 79 |
+
in_channels=1024,
|
| 80 |
+
out_channels=133,
|
| 81 |
+
input_size=codec['input_size'],
|
| 82 |
+
in_featuremap_size=(9, 12),
|
| 83 |
+
simcc_split_ratio=codec['simcc_split_ratio'],
|
| 84 |
+
final_layer_kernel_size=7,
|
| 85 |
+
gau_cfg=dict(
|
| 86 |
+
hidden_dims=256,
|
| 87 |
+
s=128,
|
| 88 |
+
expansion_factor=2,
|
| 89 |
+
dropout_rate=0.,
|
| 90 |
+
drop_path=0.,
|
| 91 |
+
act_fn='SiLU',
|
| 92 |
+
use_rel_bias=False,
|
| 93 |
+
pos_enc=False),
|
| 94 |
+
loss=dict(
|
| 95 |
+
type='KLDiscretLoss',
|
| 96 |
+
use_target_weight=True,
|
| 97 |
+
beta=10.,
|
| 98 |
+
label_softmax=True),
|
| 99 |
+
decoder=codec),
|
| 100 |
+
test_cfg=dict(flip_test=True, ))
|
| 101 |
+
|
| 102 |
+
# base dataset settings
|
| 103 |
+
dataset_type = 'UBody2dDataset'
|
| 104 |
+
data_mode = 'topdown'
|
| 105 |
+
data_root = 'data/UBody/'
|
| 106 |
+
|
| 107 |
+
backend_args = dict(backend='local')
|
| 108 |
+
|
| 109 |
+
scenes = [
|
| 110 |
+
'Magic_show', 'Entertainment', 'ConductMusic', 'Online_class', 'TalkShow',
|
| 111 |
+
'Speech', 'Fitness', 'Interview', 'Olympic', 'TVShow', 'Singing',
|
| 112 |
+
'SignLanguage', 'Movie', 'LiveVlog', 'VideoConference'
|
| 113 |
+
]
|
| 114 |
+
|
| 115 |
+
train_datasets = [
|
| 116 |
+
dict(
|
| 117 |
+
type='CocoWholeBodyDataset',
|
| 118 |
+
data_root='data/coco/',
|
| 119 |
+
data_mode=data_mode,
|
| 120 |
+
ann_file='annotations/coco_wholebody_train_v1.0.json',
|
| 121 |
+
data_prefix=dict(img='train2017/'),
|
| 122 |
+
pipeline=[])
|
| 123 |
+
]
|
| 124 |
+
|
| 125 |
+
for scene in scenes:
|
| 126 |
+
train_dataset = dict(
|
| 127 |
+
type=dataset_type,
|
| 128 |
+
data_root=data_root,
|
| 129 |
+
data_mode=data_mode,
|
| 130 |
+
ann_file=f'annotations/{scene}/train_annotations.json',
|
| 131 |
+
data_prefix=dict(img='images/'),
|
| 132 |
+
pipeline=[],
|
| 133 |
+
sample_interval=10)
|
| 134 |
+
train_datasets.append(train_dataset)
|
| 135 |
+
|
| 136 |
+
# pipelines
|
| 137 |
+
train_pipeline = [
|
| 138 |
+
dict(type='LoadImage', backend_args=backend_args),
|
| 139 |
+
dict(type='GetBBoxCenterScale'),
|
| 140 |
+
dict(type='RandomFlip', direction='horizontal'),
|
| 141 |
+
dict(type='RandomHalfBody'),
|
| 142 |
+
dict(
|
| 143 |
+
type='RandomBBoxTransform', scale_factor=[0.5, 1.5], rotate_factor=90),
|
| 144 |
+
dict(type='TopdownAffine', input_size=codec['input_size']),
|
| 145 |
+
dict(type='mmdet.YOLOXHSVRandomAug'),
|
| 146 |
+
dict(
|
| 147 |
+
type='Albumentation',
|
| 148 |
+
transforms=[
|
| 149 |
+
dict(type='Blur', p=0.1),
|
| 150 |
+
dict(type='MedianBlur', p=0.1),
|
| 151 |
+
dict(
|
| 152 |
+
type='CoarseDropout',
|
| 153 |
+
max_holes=1,
|
| 154 |
+
max_height=0.4,
|
| 155 |
+
max_width=0.4,
|
| 156 |
+
min_holes=1,
|
| 157 |
+
min_height=0.2,
|
| 158 |
+
min_width=0.2,
|
| 159 |
+
p=1.0),
|
| 160 |
+
]),
|
| 161 |
+
dict(type='GenerateTarget', encoder=codec),
|
| 162 |
+
dict(type='PackPoseInputs')
|
| 163 |
+
]
|
| 164 |
+
val_pipeline = [
|
| 165 |
+
dict(type='LoadImage', backend_args=backend_args),
|
| 166 |
+
dict(type='GetBBoxCenterScale'),
|
| 167 |
+
dict(type='TopdownAffine', input_size=codec['input_size']),
|
| 168 |
+
dict(type='PackPoseInputs')
|
| 169 |
+
]
|
| 170 |
+
|
| 171 |
+
train_pipeline_stage2 = [
|
| 172 |
+
dict(type='LoadImage', backend_args=backend_args),
|
| 173 |
+
dict(type='GetBBoxCenterScale'),
|
| 174 |
+
dict(type='RandomFlip', direction='horizontal'),
|
| 175 |
+
dict(type='RandomHalfBody'),
|
| 176 |
+
dict(
|
| 177 |
+
type='RandomBBoxTransform',
|
| 178 |
+
shift_factor=0.,
|
| 179 |
+
scale_factor=[0.5, 1.5],
|
| 180 |
+
rotate_factor=90),
|
| 181 |
+
dict(type='TopdownAffine', input_size=codec['input_size']),
|
| 182 |
+
dict(type='mmdet.YOLOXHSVRandomAug'),
|
| 183 |
+
dict(
|
| 184 |
+
type='Albumentation',
|
| 185 |
+
transforms=[
|
| 186 |
+
dict(type='Blur', p=0.1),
|
| 187 |
+
dict(type='MedianBlur', p=0.1),
|
| 188 |
+
dict(
|
| 189 |
+
type='CoarseDropout',
|
| 190 |
+
max_holes=1,
|
| 191 |
+
max_height=0.4,
|
| 192 |
+
max_width=0.4,
|
| 193 |
+
min_holes=1,
|
| 194 |
+
min_height=0.2,
|
| 195 |
+
min_width=0.2,
|
| 196 |
+
p=0.5),
|
| 197 |
+
]),
|
| 198 |
+
dict(type='GenerateTarget', encoder=codec),
|
| 199 |
+
dict(type='PackPoseInputs')
|
| 200 |
+
]
|
| 201 |
+
|
| 202 |
+
# data loaders
|
| 203 |
+
train_dataloader = dict(
|
| 204 |
+
batch_size=train_batch_size,
|
| 205 |
+
num_workers=10,
|
| 206 |
+
persistent_workers=True,
|
| 207 |
+
sampler=dict(type='DefaultSampler', shuffle=True),
|
| 208 |
+
dataset=dict(
|
| 209 |
+
type='CombinedDataset',
|
| 210 |
+
metainfo=dict(from_file='configs/_base_/datasets/coco_wholebody.py'),
|
| 211 |
+
datasets=train_datasets,
|
| 212 |
+
pipeline=train_pipeline,
|
| 213 |
+
test_mode=False,
|
| 214 |
+
))
|
| 215 |
+
|
| 216 |
+
val_dataloader = dict(
|
| 217 |
+
batch_size=val_batch_size,
|
| 218 |
+
num_workers=10,
|
| 219 |
+
persistent_workers=True,
|
| 220 |
+
drop_last=False,
|
| 221 |
+
sampler=dict(type='DefaultSampler', shuffle=False, round_up=False),
|
| 222 |
+
dataset=dict(
|
| 223 |
+
type='CocoWholeBodyDataset',
|
| 224 |
+
data_root=data_root,
|
| 225 |
+
data_mode=data_mode,
|
| 226 |
+
ann_file='data/coco/annotations/coco_wholebody_val_v1.0.json',
|
| 227 |
+
bbox_file='data/coco/person_detection_results/'
|
| 228 |
+
'COCO_val2017_detections_AP_H_56_person.json',
|
| 229 |
+
data_prefix=dict(img='coco/val2017/'),
|
| 230 |
+
test_mode=True,
|
| 231 |
+
pipeline=val_pipeline,
|
| 232 |
+
))
|
| 233 |
+
test_dataloader = val_dataloader
|
| 234 |
+
|
| 235 |
+
# hooks
|
| 236 |
+
default_hooks = dict(
|
| 237 |
+
checkpoint=dict(
|
| 238 |
+
save_best='coco-wholebody/AP', rule='greater', max_keep_ckpts=1))
|
| 239 |
+
|
| 240 |
+
custom_hooks = [
|
| 241 |
+
dict(
|
| 242 |
+
type='EMAHook',
|
| 243 |
+
ema_type='ExpMomentumEMA',
|
| 244 |
+
momentum=0.0002,
|
| 245 |
+
update_buffers=True,
|
| 246 |
+
priority=49),
|
| 247 |
+
dict(
|
| 248 |
+
type='mmdet.PipelineSwitchHook',
|
| 249 |
+
switch_epoch=max_epochs - stage2_num_epochs,
|
| 250 |
+
switch_pipeline=train_pipeline_stage2)
|
| 251 |
+
]
|
| 252 |
+
|
| 253 |
+
# evaluators
|
| 254 |
+
val_evaluator = dict(
|
| 255 |
+
type='CocoWholeBodyMetric',
|
| 256 |
+
ann_file='data/coco/annotations/coco_wholebody_val_v1.0.json')
|
| 257 |
+
test_evaluator = val_evaluator
|