-
Notifications
You must be signed in to change notification settings - Fork 552
/
Copy pathyolox-pose_s_8xb32-300e-rtmdet-hyp_coco.py
136 lines (121 loc) · 3.91 KB
/
yolox-pose_s_8xb32-300e-rtmdet-hyp_coco.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
_base_ = '../yolox_s_fast_8xb32-300e-rtmdet-hyp_coco.py'
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolox/yolox_s_fast_8xb32-300e-rtmdet-hyp_coco/yolox_s_fast_8xb32-300e-rtmdet-hyp_coco_20230210_134645-3a8dfbd7.pth' # noqa
num_keypoints = 17
scaling_ratio_range = (0.75, 1.0)
mixup_ratio_range = (0.8, 1.6)
num_last_epochs = 20
# model settings
model = dict(
bbox_head=dict(
type='YOLOXPoseHead',
head_module=dict(
type='YOLOXPoseHeadModule',
num_classes=1,
num_keypoints=num_keypoints,
),
loss_pose=dict(
type='OksLoss',
metainfo='configs/_base_/pose/coco.py',
loss_weight=30.0)),
train_cfg=dict(
assigner=dict(
type='PoseSimOTAAssigner',
center_radius=2.5,
oks_weight=3.0,
iou_calculator=dict(type='mmdet.BboxOverlaps2D'),
oks_calculator=dict(
type='OksLoss', metainfo='configs/_base_/pose/coco.py'))),
test_cfg=dict(score_thr=0.01))
# pipelines
pre_transform = [
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
dict(type='LoadAnnotations', with_keypoints=True)
]
img_scale = _base_.img_scale
train_pipeline_stage1 = [
*pre_transform,
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='RandomAffine',
scaling_ratio_range=scaling_ratio_range,
border=(-img_scale[0] // 2, -img_scale[1] // 2)),
dict(
type='YOLOXMixUp',
img_scale=img_scale,
ratio_range=mixup_ratio_range,
pad_val=114.0,
pre_transform=pre_transform),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='RandomFlip', prob=0.5),
dict(type='FilterAnnotations', by_keypoints=True, keep_empty=False),
dict(
type='PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
]
train_pipeline_stage2 = [
*pre_transform,
dict(type='Resize', scale=img_scale, keep_ratio=True),
dict(
type='mmdet.Pad',
pad_to_square=True,
pad_val=dict(img=(114.0, 114.0, 114.0))),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='RandomFlip', prob=0.5),
dict(type='FilterAnnotations', by_keypoints=True, keep_empty=False),
dict(type='PackDetInputs')
]
test_pipeline = [
*pre_transform,
dict(type='Resize', scale=img_scale, keep_ratio=True),
dict(
type='mmdet.Pad',
pad_to_square=True,
pad_val=dict(img=(114.0, 114.0, 114.0))),
dict(
type='PackDetInputs',
meta_keys=('id', 'img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'flip_indices'))
]
# dataset settings
dataset_type = 'PoseCocoDataset'
train_dataloader = dict(
dataset=dict(
type=dataset_type,
data_mode='bottomup',
ann_file='annotations/person_keypoints_train2017.json',
pipeline=train_pipeline_stage1))
val_dataloader = dict(
dataset=dict(
type=dataset_type,
data_mode='bottomup',
ann_file='annotations/person_keypoints_val2017.json',
pipeline=test_pipeline))
test_dataloader = val_dataloader
# evaluators
val_evaluator = dict(
_delete_=True,
type='mmpose.CocoMetric',
ann_file=_base_.data_root + 'annotations/person_keypoints_val2017.json',
score_mode='bbox')
test_evaluator = val_evaluator
default_hooks = dict(checkpoint=dict(save_best='coco/AP', rule='greater'))
visualizer = dict(type='mmpose.PoseLocalVisualizer')
custom_hooks = [
dict(
type='YOLOXModeSwitchHook',
num_last_epochs=num_last_epochs,
new_train_pipeline=train_pipeline_stage2,
priority=48),
dict(type='mmdet.SyncNormHook', priority=48),
dict(
type='EMAHook',
ema_type='ExpMomentumEMA',
momentum=0.0002,
update_buffers=True,
strict_load=False,
priority=49)
]