|
| 1 | +# model settings |
| 2 | +norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) |
| 3 | + |
| 4 | +model = dict( |
| 5 | + type='RepPointsDetector', |
| 6 | + pretrained='torchvision://resnet50', |
| 7 | + backbone=dict( |
| 8 | + type='ResNet', |
| 9 | + depth=50, |
| 10 | + num_stages=4, |
| 11 | + out_indices=(0, 1, 2, 3), |
| 12 | + frozen_stages=1, |
| 13 | + style='pytorch'), |
| 14 | + neck=dict( |
| 15 | + type='FPN', |
| 16 | + in_channels=[256, 512, 1024, 2048], |
| 17 | + out_channels=256, |
| 18 | + start_level=1, |
| 19 | + add_extra_convs=True, |
| 20 | + num_outs=5, |
| 21 | + norm_cfg=norm_cfg), |
| 22 | + bbox_head=dict( |
| 23 | + type='RepPointsHead', |
| 24 | + num_classes=81, |
| 25 | + in_channels=256, |
| 26 | + feat_channels=256, |
| 27 | + point_feat_channels=256, |
| 28 | + stacked_convs=3, |
| 29 | + num_points=9, |
| 30 | + gradient_mul=0.1, |
| 31 | + point_strides=[8, 16, 32, 64, 128], |
| 32 | + point_base_scale=4, |
| 33 | + norm_cfg=norm_cfg, |
| 34 | + loss_cls=dict( |
| 35 | + type='FocalLoss', |
| 36 | + use_sigmoid=True, |
| 37 | + gamma=2.0, |
| 38 | + alpha=0.25, |
| 39 | + loss_weight=1.0), |
| 40 | + loss_bbox_init=dict(type='SmoothL1Loss', beta=0.11, loss_weight=0.5), |
| 41 | + loss_bbox_refine=dict(type='SmoothL1Loss', beta=0.11, loss_weight=1.0), |
| 42 | + transform_method='minmax', |
| 43 | + use_grid_points=True)) |
| 44 | +# training and testing settings |
| 45 | +train_cfg = dict( |
| 46 | + init=dict( |
| 47 | + assigner=dict(type='PointAssigner', scale=4, pos_num=1), |
| 48 | + allowed_border=-1, |
| 49 | + pos_weight=-1, |
| 50 | + debug=False), |
| 51 | + refine=dict( |
| 52 | + assigner=dict( |
| 53 | + type='MaxIoUAssigner', |
| 54 | + pos_iou_thr=0.5, |
| 55 | + neg_iou_thr=0.4, |
| 56 | + min_pos_iou=0, |
| 57 | + ignore_iof_thr=-1), |
| 58 | + allowed_border=-1, |
| 59 | + pos_weight=-1, |
| 60 | + debug=False)) |
| 61 | +test_cfg = dict( |
| 62 | + nms_pre=1000, |
| 63 | + min_bbox_size=0, |
| 64 | + score_thr=0.05, |
| 65 | + nms=dict(type='nms', iou_thr=0.5), |
| 66 | + max_per_img=100) |
| 67 | +# dataset settings |
| 68 | +dataset_type = 'CocoDataset' |
| 69 | +data_root = 'data/coco/' |
| 70 | +img_norm_cfg = dict( |
| 71 | + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) |
| 72 | +train_pipeline = [ |
| 73 | + dict(type='LoadImageFromFile'), |
| 74 | + dict(type='LoadAnnotations', with_bbox=True), |
| 75 | + dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), |
| 76 | + dict(type='RandomFlip', flip_ratio=0.5), |
| 77 | + dict(type='Normalize', **img_norm_cfg), |
| 78 | + dict(type='Pad', size_divisor=32), |
| 79 | + dict(type='DefaultFormatBundle'), |
| 80 | + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), |
| 81 | +] |
| 82 | +test_pipeline = [ |
| 83 | + dict(type='LoadImageFromFile'), |
| 84 | + dict( |
| 85 | + type='MultiScaleFlipAug', |
| 86 | + img_scale=(1333, 800), |
| 87 | + flip=False, |
| 88 | + transforms=[ |
| 89 | + dict(type='Resize', keep_ratio=True), |
| 90 | + dict(type='RandomFlip'), |
| 91 | + dict(type='Normalize', **img_norm_cfg), |
| 92 | + dict(type='Pad', size_divisor=32), |
| 93 | + dict(type='ImageToTensor', keys=['img']), |
| 94 | + dict(type='Collect', keys=['img']), |
| 95 | + ]) |
| 96 | +] |
| 97 | +data = dict( |
| 98 | + imgs_per_gpu=2, |
| 99 | + workers_per_gpu=2, |
| 100 | + train=dict( |
| 101 | + type=dataset_type, |
| 102 | + ann_file=data_root + 'annotations/instances_train2017.json', |
| 103 | + img_prefix=data_root + 'train2017/', |
| 104 | + pipeline=train_pipeline), |
| 105 | + val=dict( |
| 106 | + type=dataset_type, |
| 107 | + ann_file=data_root + 'annotations/instances_val2017.json', |
| 108 | + img_prefix=data_root + 'val2017/', |
| 109 | + pipeline=test_pipeline), |
| 110 | + test=dict( |
| 111 | + type=dataset_type, |
| 112 | + ann_file=data_root + 'annotations/instances_val2017.json', |
| 113 | + img_prefix=data_root + 'val2017/', |
| 114 | + pipeline=test_pipeline)) |
| 115 | +# optimizer |
| 116 | +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) |
| 117 | +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) |
| 118 | +# learning policy |
| 119 | +lr_config = dict( |
| 120 | + policy='step', |
| 121 | + warmup='linear', |
| 122 | + warmup_iters=500, |
| 123 | + warmup_ratio=1.0 / 3, |
| 124 | + step=[8, 11]) |
| 125 | +checkpoint_config = dict(interval=1) |
| 126 | +# yapf:disable |
| 127 | +log_config = dict( |
| 128 | + interval=50, |
| 129 | + hooks=[ |
| 130 | + dict(type='TextLoggerHook'), |
| 131 | + # dict(type='TensorboardLoggerHook') |
| 132 | + ]) |
| 133 | +# yapf:enable |
| 134 | +# runtime settings |
| 135 | +total_epochs = 12 |
| 136 | +device_ids = range(8) |
| 137 | +dist_params = dict(backend='nccl') |
| 138 | +log_level = 'INFO' |
| 139 | +work_dir = './work_dirs/bbox_r50_grid_center_fpn_1x' |
| 140 | +load_from = None |
| 141 | +resume_from = None |
| 142 | +auto_resume = True |
| 143 | +workflow = [('train', 1)] |
0 commit comments