-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] New Codec for IPR, a wrapper for multi task losses (#1628)
Co-authored-by: Yining Li <liyining0712@gmail.com>
- Loading branch information
Showing
42 changed files
with
1,586 additions
and
664 deletions.
There are no files selected for viewing
139 changes: 139 additions & 0 deletions
139
configs/body_2d_keypoint/integral_regression/coco/ipr_res50_8xb64-210e_coco-256x256.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
_base_ = ['../../../_base_/default_runtime.py'] | ||
|
||
# runtime | ||
train_cfg = dict(max_epochs=210, val_interval=10) | ||
|
||
# optimizer | ||
optim_wrapper = dict(optimizer=dict( | ||
type='Adam', | ||
lr=5e-4, | ||
)) | ||
|
||
# learning policy | ||
param_scheduler = [ | ||
dict( | ||
type='LinearLR', begin=0, end=500, start_factor=0.001, | ||
by_epoch=False), # warm-up | ||
dict( | ||
type='MultiStepLR', | ||
begin=0, | ||
end=210, | ||
milestones=[170, 200], | ||
gamma=0.1, | ||
by_epoch=True) | ||
] | ||
|
||
# automatically scaling LR based on the actual training batch size | ||
auto_scale_lr = dict(base_batch_size=512) | ||
|
||
# hooks | ||
default_hooks = dict(checkpoint=dict(save_best='coco/AP', rule='greater')) | ||
|
||
# codec settings | ||
codec = dict( | ||
type='IntegralRegressionLabel', | ||
input_size=(256, 256), | ||
heatmap_size=(64, 64), | ||
sigma=2.0, | ||
normalize=True) | ||
|
||
# model settings | ||
model = dict( | ||
type='TopdownPoseEstimator', | ||
data_preprocessor=dict( | ||
type='PoseDataPreprocessor', | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
bgr_to_rgb=True), | ||
backbone=dict( | ||
type='ResNet', | ||
depth=50, | ||
), | ||
head=dict( | ||
type='DSNTHead', | ||
in_channels=2048, | ||
in_featuremap_size=(8, 8), | ||
num_joints=17, | ||
loss=dict( | ||
type='MultipleLossWrapper', | ||
losses=[ | ||
dict(type='SmoothL1Loss', use_target_weight=True), | ||
dict(type='KeypointMSELoss', use_target_weight=True) | ||
]), | ||
decoder=codec), | ||
test_cfg=dict( | ||
flip_test=True, | ||
shift_coords=True, | ||
shift_heatmap=True, | ||
), | ||
init_cfg=dict( | ||
type='Pretrained', | ||
checkpoint='https://download.openmmlab.com/mmpose/' | ||
'pretrain_models/td-hm_res50_8xb64-210e_coco-256x192.pth')) | ||
|
||
# base dataset settings | ||
dataset_type = 'CocoDataset' | ||
data_mode = 'topdown' | ||
data_root = 'data/coco/' | ||
|
||
file_client_args = dict(backend='disk') | ||
|
||
# pipelines | ||
train_pipeline = [ | ||
dict(type='LoadImage', file_client_args=file_client_args), | ||
dict(type='GetBBoxCenterScale'), | ||
dict(type='RandomFlip', direction='horizontal'), | ||
dict(type='RandomHalfBody'), | ||
dict(type='RandomBBoxTransform'), | ||
dict(type='TopdownAffine', input_size=codec['input_size']), | ||
dict( | ||
type='GenerateTarget', | ||
target_type='heatmap+keypoint_label', | ||
encoder=codec), | ||
dict(type='PackPoseInputs') | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImage', file_client_args=file_client_args), | ||
dict(type='GetBBoxCenterScale'), | ||
dict(type='TopdownAffine', input_size=codec['input_size']), | ||
dict(type='PackPoseInputs') | ||
] | ||
|
||
# data loaders | ||
train_dataloader = dict( | ||
batch_size=64, | ||
num_workers=2, | ||
persistent_workers=True, | ||
sampler=dict(type='DefaultSampler', shuffle=True), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_mode=data_mode, | ||
ann_file='annotations/person_keypoints_train2017.json', | ||
data_prefix=dict(img='train2017/'), | ||
pipeline=train_pipeline, | ||
)) | ||
val_dataloader = dict( | ||
batch_size=32, | ||
num_workers=2, | ||
persistent_workers=True, | ||
drop_last=False, | ||
sampler=dict(type='DefaultSampler', shuffle=False, round_up=False), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_mode=data_mode, | ||
ann_file='annotations/person_keypoints_val2017.json', | ||
bbox_file=f'{data_root}person_detection_results/' | ||
'COCO_val2017_detections_AP_H_56_person.json', | ||
data_prefix=dict(img='val2017/'), | ||
test_mode=True, | ||
pipeline=test_pipeline, | ||
)) | ||
test_dataloader = val_dataloader | ||
|
||
# evaluators | ||
val_evaluator = dict( | ||
type='CocoMetric', | ||
ann_file=f'{data_root}annotations/person_keypoints_val2017.json') | ||
test_evaluator = val_evaluator |
138 changes: 138 additions & 0 deletions
138
...igs/body_2d_keypoint/integral_regression/coco/ipr_res50_debias-8xb64-210e_coco-256x256.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
_base_ = ['../../../_base_/default_runtime.py'] | ||
|
||
# runtime | ||
train_cfg = dict(max_epochs=210, val_interval=10) | ||
|
||
# optimizer | ||
optim_wrapper = dict(optimizer=dict( | ||
type='Adam', | ||
lr=5e-4, | ||
)) | ||
|
||
# learning policy | ||
param_scheduler = [ | ||
dict( | ||
type='LinearLR', begin=0, end=500, start_factor=0.001, | ||
by_epoch=False), # warm-up | ||
dict( | ||
type='MultiStepLR', | ||
begin=0, | ||
end=210, | ||
milestones=[170, 200], | ||
gamma=0.1, | ||
by_epoch=True) | ||
] | ||
|
||
# automatically scaling LR based on the actual training batch size | ||
auto_scale_lr = dict(base_batch_size=512) | ||
|
||
# hooks | ||
default_hooks = dict(checkpoint=dict(save_best='coco/AP', rule='greater')) | ||
|
||
# codec settings | ||
codec = dict( | ||
type='IntegralRegressionLabel', | ||
input_size=(256, 256), | ||
heatmap_size=(64, 64), | ||
sigma=2.0, | ||
normalize=True) | ||
|
||
# model settings | ||
model = dict( | ||
type='TopdownPoseEstimator', | ||
data_preprocessor=dict( | ||
type='PoseDataPreprocessor', | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
bgr_to_rgb=True), | ||
backbone=dict(type='ResNet', depth=50), | ||
head=dict( | ||
type='DSNTHead', | ||
in_channels=2048, | ||
in_featuremap_size=(8, 8), | ||
num_joints=17, | ||
debias=True, | ||
beta=10., | ||
loss=dict( | ||
type='MultipleLossWrapper', | ||
losses=[ | ||
dict(type='SmoothL1Loss', use_target_weight=True), | ||
dict(type='JSDiscretLoss', use_target_weight=True) | ||
]), | ||
decoder=codec), | ||
test_cfg=dict( | ||
flip_test=True, | ||
shift_coords=True, | ||
shift_heatmap=True, | ||
), | ||
init_cfg=dict( | ||
type='Pretrained', | ||
checkpoint='https://download.openmmlab.com/mmpose/' | ||
'pretrain_models/td-hm_res50_8xb64-210e_coco-256x192.pth')) | ||
|
||
# base dataset settings | ||
dataset_type = 'CocoDataset' | ||
data_mode = 'topdown' | ||
data_root = 'data/coco/' | ||
|
||
file_client_args = dict(backend='disk') | ||
|
||
# pipelines | ||
train_pipeline = [ | ||
dict(type='LoadImage', file_client_args=file_client_args), | ||
dict(type='GetBBoxCenterScale'), | ||
dict(type='RandomFlip', direction='horizontal'), | ||
dict(type='RandomHalfBody'), | ||
dict(type='RandomBBoxTransform'), | ||
dict(type='TopdownAffine', input_size=codec['input_size']), | ||
dict( | ||
type='GenerateTarget', | ||
target_type='heatmap+keypoint_label', | ||
encoder=codec), | ||
dict(type='PackPoseInputs') | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImage', file_client_args=file_client_args), | ||
dict(type='GetBBoxCenterScale'), | ||
dict(type='TopdownAffine', input_size=codec['input_size']), | ||
dict(type='PackPoseInputs') | ||
] | ||
|
||
# data loaders | ||
train_dataloader = dict( | ||
batch_size=64, | ||
num_workers=2, | ||
persistent_workers=True, | ||
sampler=dict(type='DefaultSampler', shuffle=True), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_mode=data_mode, | ||
ann_file='annotations/person_keypoints_train2017.json', | ||
data_prefix=dict(img='train2017/'), | ||
pipeline=train_pipeline, | ||
)) | ||
val_dataloader = dict( | ||
batch_size=32, | ||
num_workers=2, | ||
persistent_workers=True, | ||
drop_last=False, | ||
sampler=dict(type='DefaultSampler', shuffle=False, round_up=False), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_mode=data_mode, | ||
ann_file='annotations/person_keypoints_val2017.json', | ||
bbox_file=f'{data_root}person_detection_results/' | ||
'COCO_val2017_detections_AP_H_56_person.json', | ||
data_prefix=dict(img='val2017/'), | ||
test_mode=True, | ||
pipeline=test_pipeline, | ||
)) | ||
test_dataloader = val_dataloader | ||
|
||
# evaluators | ||
val_evaluator = dict( | ||
type='CocoMetric', | ||
ann_file=f'{data_root}annotations/person_keypoints_val2017.json') | ||
test_evaluator = val_evaluator |
Oops, something went wrong.