-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add swin backbones and support solider pretrain
- Loading branch information
Showing
7 changed files
with
1,925 additions
and
263 deletions.
There are no files selected for viewing
166 changes: 166 additions & 0 deletions
166
configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/swin_base_coco_384x288_release.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,166 @@ | ||
_base_ = ['../../../../_base_/datasets/coco.py'] | ||
log_level = 'INFO' | ||
load_from = None | ||
resume_from = None | ||
dist_params = dict(backend='nccl') | ||
workflow = [('train', 1)] | ||
checkpoint_config = dict(interval=5, create_symlink=False) | ||
evaluation = dict(interval=5, metric='mAP', save_best='AP') | ||
|
||
optimizer = dict( | ||
type='AdamW', | ||
lr=1e-3, | ||
betas=(0.9, 0.999), | ||
weight_decay=0.01, | ||
paramwise_cfg=dict( | ||
custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) | ||
|
||
optimizer_config = dict(grad_clip=None) | ||
# learning policy | ||
lr_config = dict( | ||
policy='step', | ||
warmup='linear', | ||
warmup_iters=11710, | ||
warmup_ratio=0.001, | ||
step=[120, 150]) | ||
total_epochs = 160 | ||
log_config = dict( | ||
interval=50, hooks=[ | ||
dict(type='TextLoggerHook'), | ||
]) | ||
|
||
channel_cfg = dict( | ||
num_output_channels=17, | ||
dataset_joints=17, | ||
dataset_channel=[ | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], | ||
], | ||
inference_channel=[ | ||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
]) | ||
|
||
# model settings | ||
norm_cfg = dict(type='SyncBN', requires_grad=True) | ||
model = dict( | ||
type='TopDown', | ||
pretrained='./pretrain_models/swin_base.pth', | ||
backbone=dict( | ||
type='SwinTransformer', | ||
in_channels=3, | ||
pretrain_img_size=224, | ||
patch_size=4, | ||
window_size=7, | ||
embed_dims=128, | ||
strides=(4, 2, 1, 1), | ||
depths=(2, 2, 18, 2), | ||
num_heads=(4, 8, 16, 32), | ||
drop_path_rate=0.0, | ||
drop_rate=0.0, | ||
attn_drop_rate=0.0, | ||
semantic_weight=0.8,), | ||
keypoint_head=dict( | ||
type='TopdownHeatmapSimpleHead', | ||
in_channels=1024, | ||
in_index=3, | ||
out_channels=channel_cfg['num_output_channels'], | ||
num_deconv_layers=1, | ||
num_deconv_kernels=(4, ), | ||
num_deconv_filters=(256, ), | ||
#in_index=-1, | ||
extra=dict(final_conv_kernel=1, ), | ||
loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)), | ||
train_cfg=dict(), | ||
test_cfg=dict( | ||
flip_test=True, | ||
post_process='default', | ||
shift_heatmap=True, | ||
modulate_kernel=11)) | ||
data_root = 'data/coco' | ||
data_cfg = dict( | ||
image_size=[288, 384], | ||
heatmap_size=[72, 96], #[48, 64] | ||
num_output_channels=channel_cfg['num_output_channels'], | ||
num_joints=channel_cfg['dataset_joints'], | ||
dataset_channel=channel_cfg['dataset_channel'], | ||
inference_channel=channel_cfg['inference_channel'], | ||
soft_nms=False, | ||
nms_thr=1.0, | ||
oks_thr=0.9, | ||
vis_thr=0.2, | ||
use_gt_bbox=False, | ||
det_bbox_thr=0.0, | ||
bbox_file=f'{data_root}/person_detection_results/' | ||
'COCO_val2017_detections_AP_H_56_person.json', | ||
) | ||
|
||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='TopDownRandomFlip', flip_prob=0.5), | ||
dict( | ||
type='TopDownHalfBodyTransform', | ||
num_joints_half_body=8, | ||
prob_half_body=0.3), | ||
dict( | ||
type='TopDownGetRandomScaleRotation', rot_factor=40, scale_factor=0.5), | ||
dict(type='TopDownAffine'), | ||
dict(type='ToTensor'), | ||
dict( | ||
type='NormalizeTensor', | ||
mean=[0.485, 0.456, 0.406], | ||
std=[0.229, 0.224, 0.225]), | ||
dict(type='TopDownGenerateTarget', sigma=2), | ||
dict( | ||
type='Collect', | ||
keys=['img', 'target', 'target_weight'], | ||
meta_keys=[ | ||
'image_file', 'joints_3d', 'joints_3d_visible', 'center', 'scale', | ||
'rotation', 'bbox_score', 'flip_pairs' | ||
]), | ||
] | ||
|
||
val_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='TopDownAffine'), | ||
dict(type='ToTensor'), | ||
dict( | ||
type='NormalizeTensor', | ||
mean=[0.485, 0.456, 0.406], | ||
std=[0.229, 0.224, 0.225]), | ||
dict( | ||
type='Collect', | ||
keys=['img'], | ||
meta_keys=[ | ||
'image_file', 'center', 'scale', 'rotation', 'bbox_score', | ||
'flip_pairs' | ||
]), | ||
] | ||
|
||
test_pipeline = val_pipeline | ||
|
||
data = dict( | ||
samples_per_gpu=12, | ||
workers_per_gpu=2, | ||
val_dataloader=dict(samples_per_gpu=12), | ||
test_dataloader=dict(samples_per_gpu=12), | ||
train=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_train2017.json', | ||
img_prefix=f'{data_root}/train2017/', | ||
data_cfg=data_cfg, | ||
pipeline=train_pipeline), | ||
val=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', | ||
img_prefix=f'{data_root}/val2017/', | ||
data_cfg=data_cfg, | ||
pipeline=val_pipeline), | ||
test=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', | ||
img_prefix=f'{data_root}/val2017/', | ||
data_cfg=data_cfg, | ||
pipeline=val_pipeline), | ||
) | ||
|
||
# fp16 settings | ||
fp16 = dict(loss_scale='dynamic') |
166 changes: 166 additions & 0 deletions
166
configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/swin_small_coco_384x288_release.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,166 @@ | ||
_base_ = ['../../../../_base_/datasets/coco.py'] | ||
log_level = 'INFO' | ||
load_from = None | ||
resume_from = None | ||
dist_params = dict(backend='nccl') | ||
workflow = [('train', 1)] | ||
checkpoint_config = dict(interval=5, create_symlink=False) | ||
evaluation = dict(interval=5, metric='mAP', save_best='AP') | ||
|
||
optimizer = dict( | ||
type='AdamW', | ||
lr=1e-3, | ||
betas=(0.9, 0.999), | ||
weight_decay=0.01, | ||
paramwise_cfg=dict( | ||
custom_keys={'relative_position_bias_table': dict(decay_mult=0.)})) | ||
|
||
optimizer_config = dict(grad_clip=None) | ||
# learning policy | ||
lr_config = dict( | ||
policy='step', | ||
warmup='linear', | ||
warmup_iters=11710, | ||
warmup_ratio=0.001, | ||
step=[170, 200]) | ||
total_epochs = 210 | ||
log_config = dict( | ||
interval=50, hooks=[ | ||
dict(type='TextLoggerHook'), | ||
]) | ||
|
||
channel_cfg = dict( | ||
num_output_channels=17, | ||
dataset_joints=17, | ||
dataset_channel=[ | ||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], | ||
], | ||
inference_channel=[ | ||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
]) | ||
|
||
# model settings | ||
norm_cfg = dict(type='SyncBN', requires_grad=True) | ||
model = dict( | ||
type='TopDown', | ||
pretrained='./pretrain_models/swin_small.pth', | ||
backbone=dict( | ||
type='SwinTransformer', | ||
in_channels=3, | ||
pretrain_img_size=224, | ||
patch_size=4, | ||
window_size=7, | ||
embed_dims=96, | ||
strides=(4, 2, 1, 1), | ||
depths=(2, 2, 18, 2), | ||
num_heads=(3, 6, 12, 24), | ||
drop_path_rate=0.0, | ||
drop_rate=0.0, | ||
attn_drop_rate=0.0, | ||
semantic_weight=0.8), | ||
keypoint_head=dict( | ||
type='TopdownHeatmapSimpleHead', | ||
in_channels=768, | ||
in_index=3, | ||
out_channels=channel_cfg['num_output_channels'], | ||
num_deconv_layers=1, | ||
num_deconv_kernels=(4, ), | ||
num_deconv_filters=(256, ), | ||
#in_index=-1, | ||
extra=dict(final_conv_kernel=1, ), | ||
loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)), | ||
train_cfg=dict(), | ||
test_cfg=dict( | ||
flip_test=True, | ||
post_process='default', | ||
shift_heatmap=True, | ||
modulate_kernel=11)) | ||
data_root = 'data/coco' | ||
data_cfg = dict( | ||
image_size=[288, 384], | ||
heatmap_size=[72, 96], #[48, 64] | ||
num_output_channels=channel_cfg['num_output_channels'], | ||
num_joints=channel_cfg['dataset_joints'], | ||
dataset_channel=channel_cfg['dataset_channel'], | ||
inference_channel=channel_cfg['inference_channel'], | ||
soft_nms=False, | ||
nms_thr=1.0, | ||
oks_thr=0.9, | ||
vis_thr=0.2, | ||
use_gt_bbox=False, | ||
det_bbox_thr=0.0, | ||
bbox_file=f'{data_root}/person_detection_results/' | ||
'COCO_val2017_detections_AP_H_56_person.json', | ||
) | ||
|
||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='TopDownRandomFlip', flip_prob=0.5), | ||
dict( | ||
type='TopDownHalfBodyTransform', | ||
num_joints_half_body=8, | ||
prob_half_body=0.3), | ||
dict( | ||
type='TopDownGetRandomScaleRotation', rot_factor=40, scale_factor=0.5), | ||
dict(type='TopDownAffine'), | ||
dict(type='ToTensor'), | ||
dict( | ||
type='NormalizeTensor', | ||
mean=[0.485, 0.456, 0.406], | ||
std=[0.229, 0.224, 0.225]), | ||
dict(type='TopDownGenerateTarget', sigma=2), | ||
dict( | ||
type='Collect', | ||
keys=['img', 'target', 'target_weight'], | ||
meta_keys=[ | ||
'image_file', 'joints_3d', 'joints_3d_visible', 'center', 'scale', | ||
'rotation', 'bbox_score', 'flip_pairs' | ||
]), | ||
] | ||
|
||
val_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='TopDownAffine'), | ||
dict(type='ToTensor'), | ||
dict( | ||
type='NormalizeTensor', | ||
mean=[0.485, 0.456, 0.406], | ||
std=[0.229, 0.224, 0.225]), | ||
dict( | ||
type='Collect', | ||
keys=['img'], | ||
meta_keys=[ | ||
'image_file', 'center', 'scale', 'rotation', 'bbox_score', | ||
'flip_pairs' | ||
]), | ||
] | ||
|
||
test_pipeline = val_pipeline | ||
|
||
data = dict( | ||
samples_per_gpu=8, | ||
workers_per_gpu=2, | ||
val_dataloader=dict(samples_per_gpu=8), | ||
test_dataloader=dict(samples_per_gpu=8), | ||
train=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_train2017.json', | ||
img_prefix=f'{data_root}/train2017/', | ||
data_cfg=data_cfg, | ||
pipeline=train_pipeline), | ||
val=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', | ||
img_prefix=f'{data_root}/val2017/', | ||
data_cfg=data_cfg, | ||
pipeline=val_pipeline), | ||
test=dict( | ||
type='TopDownCocoDataset', | ||
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', | ||
img_prefix=f'{data_root}/val2017/', | ||
data_cfg=data_cfg, | ||
pipeline=val_pipeline), | ||
) | ||
|
||
# fp16 settings | ||
fp16 = dict(loss_scale='dynamic') |
Oops, something went wrong.