|
| 1 | +_base_ = [ |
| 2 | + '../../../../_base_/default_runtime.py', |
| 3 | + '../../../../_base_/datasets/coco.py' |
| 4 | +] |
| 5 | +evaluation = dict(interval=10, metric='mAP', save_best='AP') |
| 6 | + |
| 7 | +optimizer = dict( |
| 8 | + type='AdamW', |
| 9 | + lr=5e-4, |
| 10 | + betas=(0.9, 0.999), |
| 11 | + weight_decay=0.1, |
| 12 | + constructor='LayerDecayOptimizerConstructor', |
| 13 | + paramwise_cfg=dict( |
| 14 | + num_layers=12, |
| 15 | + layer_decay_rate=0.75, |
| 16 | + )) |
| 17 | + |
| 18 | +optimizer_config = dict(grad_clip=dict(max_norm=1., norm_type=2)) |
| 19 | + |
| 20 | +# learning policy |
| 21 | +lr_config = dict( |
| 22 | + policy='step', |
| 23 | + warmup='linear', |
| 24 | + warmup_iters=500, |
| 25 | + warmup_ratio=0.001, |
| 26 | + step=[170, 200]) |
| 27 | +total_epochs = 210 |
| 28 | +target_type = 'GaussianHeatmap' |
| 29 | +channel_cfg = dict( |
| 30 | + num_output_channels=17, |
| 31 | + dataset_joints=17, |
| 32 | + dataset_channel=[ |
| 33 | + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], |
| 34 | + ], |
| 35 | + inference_channel=[ |
| 36 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 |
| 37 | + ]) |
| 38 | + |
| 39 | +# model settings |
| 40 | +model = dict( |
| 41 | + type='TopDown', |
| 42 | + pretrained=None, |
| 43 | + backbone=dict( |
| 44 | + type='VisionTransformer', |
| 45 | + img_size=(256, 192), |
| 46 | + patch_size=16, |
| 47 | + embed_dims=768, |
| 48 | + # Optional in train |
| 49 | + padding=2, |
| 50 | + num_layers=12, |
| 51 | + num_heads=12, |
| 52 | + mlp_ratio=4, |
| 53 | + drop_path_rate=0.3, |
| 54 | + final_norm=True, |
| 55 | + ), |
| 56 | + keypoint_head=dict( |
| 57 | + type='TopdownHeatmapSimpleHead', |
| 58 | + in_channels=768, |
| 59 | + num_deconv_layers=2, |
| 60 | + num_deconv_filters=(256, 256), |
| 61 | + num_deconv_kernels=(4, 4), |
| 62 | + extra=dict(final_conv_kernel=1, ), |
| 63 | + out_channels=channel_cfg['num_output_channels'], |
| 64 | + loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)), |
| 65 | + train_cfg=dict(), |
| 66 | + test_cfg=dict( |
| 67 | + flip_test=True, |
| 68 | + post_process='default', |
| 69 | + shift_heatmap=False, |
| 70 | + target_type=target_type, |
| 71 | + modulate_kernel=11, |
| 72 | + use_udp=True)) |
| 73 | + |
| 74 | +data_cfg = dict( |
| 75 | + image_size=[192, 256], |
| 76 | + heatmap_size=[48, 64], |
| 77 | + num_output_channels=channel_cfg['num_output_channels'], |
| 78 | + num_joints=channel_cfg['dataset_joints'], |
| 79 | + dataset_channel=channel_cfg['dataset_channel'], |
| 80 | + inference_channel=channel_cfg['inference_channel'], |
| 81 | + soft_nms=False, |
| 82 | + nms_thr=1.0, |
| 83 | + oks_thr=0.9, |
| 84 | + vis_thr=0.2, |
| 85 | + use_gt_bbox=False, |
| 86 | + det_bbox_thr=0.0, |
| 87 | + bbox_file='data/coco/person_detection_results/' |
| 88 | + 'COCO_val2017_detections_AP_H_56_person.json', |
| 89 | +) |
| 90 | + |
| 91 | +train_pipeline = [ |
| 92 | + dict(type='LoadImageFromFile'), |
| 93 | + dict(type='TopDownGetBboxCenterScale', padding=1.25), |
| 94 | + dict(type='TopDownRandomShiftBboxCenter', shift_factor=0.16, prob=0.3), |
| 95 | + dict(type='TopDownRandomFlip', flip_prob=0.5), |
| 96 | + dict( |
| 97 | + type='TopDownHalfBodyTransform', |
| 98 | + num_joints_half_body=8, |
| 99 | + prob_half_body=0.3), |
| 100 | + dict( |
| 101 | + type='TopDownGetRandomScaleRotation', rot_factor=40, scale_factor=0.5), |
| 102 | + dict(type='TopDownAffine', use_udp=True), |
| 103 | + dict(type='ToTensor'), |
| 104 | + dict( |
| 105 | + type='NormalizeTensor', |
| 106 | + mean=[0.485, 0.456, 0.406], |
| 107 | + std=[0.229, 0.224, 0.225]), |
| 108 | + dict( |
| 109 | + type='TopDownGenerateTarget', |
| 110 | + sigma=2, |
| 111 | + encoding='UDP', |
| 112 | + target_type=target_type), |
| 113 | + dict( |
| 114 | + type='Collect', |
| 115 | + keys=['img', 'target', 'target_weight'], |
| 116 | + meta_keys=[ |
| 117 | + 'image_file', 'joints_3d', 'joints_3d_visible', 'center', 'scale', |
| 118 | + 'rotation', 'bbox_score', 'flip_pairs' |
| 119 | + ]), |
| 120 | +] |
| 121 | + |
| 122 | +val_pipeline = [ |
| 123 | + dict(type='LoadImageFromFile'), |
| 124 | + dict(type='TopDownGetBboxCenterScale', padding=1.25), |
| 125 | + dict(type='TopDownAffine', use_udp=True), |
| 126 | + dict(type='ToTensor'), |
| 127 | + dict( |
| 128 | + type='NormalizeTensor', |
| 129 | + mean=[0.485, 0.456, 0.406], |
| 130 | + std=[0.229, 0.224, 0.225]), |
| 131 | + dict( |
| 132 | + type='Collect', |
| 133 | + keys=['img'], |
| 134 | + meta_keys=[ |
| 135 | + 'image_file', 'center', 'scale', 'rotation', 'bbox_score', |
| 136 | + 'flip_pairs' |
| 137 | + ]), |
| 138 | +] |
| 139 | + |
| 140 | +test_pipeline = val_pipeline |
| 141 | + |
| 142 | +data_root = 'data/coco' |
| 143 | +data = dict( |
| 144 | + samples_per_gpu=64, |
| 145 | + workers_per_gpu=4, |
| 146 | + val_dataloader=dict(samples_per_gpu=32), |
| 147 | + test_dataloader=dict(samples_per_gpu=32), |
| 148 | + train=dict( |
| 149 | + type='TopDownCocoDataset', |
| 150 | + ann_file=f'{data_root}/annotations/person_keypoints_train2017.json', |
| 151 | + img_prefix=f'{data_root}/train2017/', |
| 152 | + data_cfg=data_cfg, |
| 153 | + pipeline=train_pipeline, |
| 154 | + dataset_info={{_base_.dataset_info}}), |
| 155 | + val=dict( |
| 156 | + type='TopDownCocoDataset', |
| 157 | + ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', |
| 158 | + img_prefix=f'{data_root}/val2017/', |
| 159 | + data_cfg=data_cfg, |
| 160 | + pipeline=val_pipeline, |
| 161 | + dataset_info={{_base_.dataset_info}}), |
| 162 | + test=dict( |
| 163 | + type='TopDownCocoDataset', |
| 164 | + ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', |
| 165 | + img_prefix=f'{data_root}/val2017/', |
| 166 | + data_cfg=data_cfg, |
| 167 | + pipeline=test_pipeline, |
| 168 | + dataset_info={{_base_.dataset_info}}), |
| 169 | +) |
0 commit comments