|
| 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='Adam', |
| 9 | + lr=1e-3, |
| 10 | +) |
| 11 | +optimizer_config = dict(grad_clip=None) |
| 12 | +# learning policy |
| 13 | +lr_config = dict( |
| 14 | + policy='step', |
| 15 | + warmup='linear', |
| 16 | + warmup_iters=500, |
| 17 | + warmup_ratio=0.001, |
| 18 | + step=[170, 200]) |
| 19 | +total_epochs = 210 |
| 20 | +channel_cfg = dict( |
| 21 | + num_output_channels=17, |
| 22 | + dataset_joints=17, |
| 23 | + dataset_channel=[ |
| 24 | + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], |
| 25 | + ], |
| 26 | + inference_channel=[ |
| 27 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 |
| 28 | + ]) |
| 29 | + |
| 30 | +# model settings |
| 31 | +norm_cfg = dict(type='SyncBN', requires_grad=True) |
| 32 | +model = dict( |
| 33 | + type='TopDown', |
| 34 | + pretrained="https://github.com/Westlake-AI/MogaNet/releases/download/" |
| 35 | + "moganet-in1k-weights/moganet_xtiny_sz224_8xbs128_ep300.pth.tar", |
| 36 | + backbone=dict( |
| 37 | + type='MogaNet_feat', |
| 38 | + arch="x-tiny", # modify 'arch' for various architectures |
| 39 | + init_value=1e-5, |
| 40 | + frozen_stages=1, |
| 41 | + drop_path_rate=0.1, |
| 42 | + stem_norm_cfg=norm_cfg, |
| 43 | + conv_norm_cfg=norm_cfg, |
| 44 | + out_indices=(0, 1, 2, 3), |
| 45 | + ), |
| 46 | + keypoint_head=dict( |
| 47 | + type='TopdownHeatmapSimpleHead', |
| 48 | + in_channels=192, # modify 'in_channels' for various architectures |
| 49 | + out_channels=channel_cfg['num_output_channels'], |
| 50 | + in_index=3, |
| 51 | + loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)), |
| 52 | + train_cfg=dict(), |
| 53 | + test_cfg=dict( |
| 54 | + flip_test=True, |
| 55 | + post_process='default', |
| 56 | + shift_heatmap=True, |
| 57 | + modulate_kernel=11)) |
| 58 | + |
| 59 | +data_cfg = dict( |
| 60 | + image_size=[192, 256], |
| 61 | + heatmap_size=[48, 64], |
| 62 | + num_output_channels=channel_cfg['num_output_channels'], |
| 63 | + num_joints=channel_cfg['dataset_joints'], |
| 64 | + dataset_channel=channel_cfg['dataset_channel'], |
| 65 | + inference_channel=channel_cfg['inference_channel'], |
| 66 | + soft_nms=False, |
| 67 | + nms_thr=1.0, |
| 68 | + oks_thr=0.9, |
| 69 | + vis_thr=0.2, |
| 70 | + use_gt_bbox=False, |
| 71 | + det_bbox_thr=0.0, |
| 72 | + bbox_file='data/coco/person_detection_results/' |
| 73 | + 'COCO_val2017_detections_AP_H_56_person.json', |
| 74 | +) |
| 75 | + |
| 76 | +train_pipeline = [ |
| 77 | + dict(type='LoadImageFromFile'), |
| 78 | + dict(type='TopDownGetBboxCenterScale', padding=1.25), |
| 79 | + dict(type='TopDownRandomShiftBboxCenter', shift_factor=0.16, prob=0.3), |
| 80 | + dict(type='TopDownRandomFlip', flip_prob=0.5), |
| 81 | + dict( |
| 82 | + type='TopDownHalfBodyTransform', |
| 83 | + num_joints_half_body=8, |
| 84 | + prob_half_body=0.3), |
| 85 | + dict( |
| 86 | + type='TopDownGetRandomScaleRotation', rot_factor=40, scale_factor=0.5), |
| 87 | + dict(type='TopDownAffine'), |
| 88 | + dict(type='ToTensor'), |
| 89 | + dict( |
| 90 | + type='NormalizeTensor', |
| 91 | + mean=[0.485, 0.456, 0.406], |
| 92 | + std=[0.229, 0.224, 0.225]), |
| 93 | + dict(type='TopDownGenerateTarget', sigma=2), |
| 94 | + dict( |
| 95 | + type='Collect', |
| 96 | + keys=['img', 'target', 'target_weight'], |
| 97 | + meta_keys=[ |
| 98 | + 'image_file', 'joints_3d', 'joints_3d_visible', 'center', 'scale', |
| 99 | + 'rotation', 'bbox_score', 'flip_pairs' |
| 100 | + ]), |
| 101 | +] |
| 102 | + |
| 103 | +val_pipeline = [ |
| 104 | + dict(type='LoadImageFromFile'), |
| 105 | + dict(type='TopDownGetBboxCenterScale', padding=1.25), |
| 106 | + dict(type='TopDownAffine'), |
| 107 | + dict(type='ToTensor'), |
| 108 | + dict( |
| 109 | + type='NormalizeTensor', |
| 110 | + mean=[0.485, 0.456, 0.406], |
| 111 | + std=[0.229, 0.224, 0.225]), |
| 112 | + dict( |
| 113 | + type='Collect', |
| 114 | + keys=['img'], |
| 115 | + meta_keys=[ |
| 116 | + 'image_file', 'center', 'scale', 'rotation', 'bbox_score', |
| 117 | + 'flip_pairs' |
| 118 | + ]), |
| 119 | +] |
| 120 | + |
| 121 | +test_pipeline = val_pipeline |
| 122 | + |
| 123 | +data_root = 'data/coco' |
| 124 | +data = dict( |
| 125 | + samples_per_gpu=32, |
| 126 | + workers_per_gpu=2, |
| 127 | + val_dataloader=dict(samples_per_gpu=32), |
| 128 | + test_dataloader=dict(samples_per_gpu=32), |
| 129 | + train=dict( |
| 130 | + type='TopDownCocoDataset', |
| 131 | + ann_file=f'{data_root}/annotations/person_keypoints_train2017.json', |
| 132 | + img_prefix=f'{data_root}/train2017/', |
| 133 | + data_cfg=data_cfg, |
| 134 | + pipeline=train_pipeline, |
| 135 | + dataset_info={{_base_.dataset_info}}), |
| 136 | + val=dict( |
| 137 | + type='TopDownCocoDataset', |
| 138 | + ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', |
| 139 | + img_prefix=f'{data_root}/val2017/', |
| 140 | + data_cfg=data_cfg, |
| 141 | + pipeline=val_pipeline, |
| 142 | + dataset_info={{_base_.dataset_info}}), |
| 143 | + test=dict( |
| 144 | + type='TopDownCocoDataset', |
| 145 | + ann_file=f'{data_root}/annotations/person_keypoints_val2017.json', |
| 146 | + img_prefix=f'{data_root}/val2017/', |
| 147 | + data_cfg=data_cfg, |
| 148 | + pipeline=test_pipeline, |
| 149 | + dataset_info={{_base_.dataset_info}}), |
| 150 | +) |
0 commit comments