|
| 1 | +# model settings |
| 2 | +model = dict( |
| 3 | + type='FasterRCNN', |
| 4 | + pretrained='modelzoo://resnet50', |
| 5 | + backbone=dict( |
| 6 | + type='ResNet', |
| 7 | + depth=50, |
| 8 | + num_stages=4, |
| 9 | + out_indices=(0, 1, 2, 3), |
| 10 | + frozen_stages=1, |
| 11 | + style='pytorch'), |
| 12 | + neck=dict( |
| 13 | + type='FPN', |
| 14 | + in_channels=[256, 512, 1024, 2048], |
| 15 | + out_channels=256, |
| 16 | + num_outs=5), |
| 17 | + rpn_head=dict( |
| 18 | + type='RPNHead', |
| 19 | + in_channels=256, |
| 20 | + feat_channels=256, |
| 21 | + anchor_scales=[8], |
| 22 | + anchor_ratios=[0.5, 1.0, 2.0], |
| 23 | + anchor_strides=[4, 8, 16, 32, 64], |
| 24 | + target_means=[.0, .0, .0, .0], |
| 25 | + target_stds=[1.0, 1.0, 1.0, 1.0], |
| 26 | + use_sigmoid_cls=True), |
| 27 | + bbox_roi_extractor=dict( |
| 28 | + type='SingleRoIExtractor', |
| 29 | + roi_layer=dict(type='RoIAlign', out_size=7, sample_num=2), |
| 30 | + out_channels=256, |
| 31 | + featmap_strides=[4, 8, 16, 32]), |
| 32 | + bbox_head=dict( |
| 33 | + type='SharedFCBBoxHead', |
| 34 | + num_fcs=2, |
| 35 | + in_channels=256, |
| 36 | + fc_out_channels=1024, |
| 37 | + roi_feat_size=7, |
| 38 | + num_classes=21, |
| 39 | + target_means=[0., 0., 0., 0.], |
| 40 | + target_stds=[0.1, 0.1, 0.2, 0.2], |
| 41 | + reg_class_agnostic=False)) |
| 42 | +# model training and testing settings |
| 43 | +train_cfg = dict( |
| 44 | + rpn=dict( |
| 45 | + assigner=dict( |
| 46 | + type='MaxIoUAssigner', |
| 47 | + pos_iou_thr=0.7, |
| 48 | + neg_iou_thr=0.3, |
| 49 | + min_pos_iou=0.3, |
| 50 | + ignore_iof_thr=-1), |
| 51 | + sampler=dict( |
| 52 | + type='RandomSampler', |
| 53 | + num=256, |
| 54 | + pos_fraction=0.5, |
| 55 | + neg_pos_ub=-1, |
| 56 | + add_gt_as_proposals=False), |
| 57 | + allowed_border=0, |
| 58 | + pos_weight=-1, |
| 59 | + smoothl1_beta=1 / 9.0, |
| 60 | + debug=False), |
| 61 | + rcnn=dict( |
| 62 | + assigner=dict( |
| 63 | + type='MaxIoUAssigner', |
| 64 | + pos_iou_thr=0.5, |
| 65 | + neg_iou_thr=0.5, |
| 66 | + min_pos_iou=0.5, |
| 67 | + ignore_iof_thr=-1), |
| 68 | + sampler=dict( |
| 69 | + type='RandomSampler', |
| 70 | + num=512, |
| 71 | + pos_fraction=0.25, |
| 72 | + neg_pos_ub=-1, |
| 73 | + add_gt_as_proposals=True), |
| 74 | + pos_weight=-1, |
| 75 | + debug=False)) |
| 76 | +test_cfg = dict( |
| 77 | + rpn=dict( |
| 78 | + nms_across_levels=False, |
| 79 | + nms_pre=2000, |
| 80 | + nms_post=2000, |
| 81 | + max_num=2000, |
| 82 | + nms_thr=0.7, |
| 83 | + min_bbox_size=0), |
| 84 | + rcnn=dict( |
| 85 | + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100) |
| 86 | + # soft-nms is also supported for rcnn testing |
| 87 | + # e.g., nms=dict(type='soft_nms', iou_thr=0.5, min_score=0.05) |
| 88 | +) |
| 89 | +# dataset settings |
| 90 | +dataset_type = 'VOCDataset' |
| 91 | +data_root = 'data/VOCdevkit/' |
| 92 | +img_norm_cfg = dict( |
| 93 | + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) |
| 94 | +data = dict( |
| 95 | + imgs_per_gpu=2, |
| 96 | + workers_per_gpu=2, |
| 97 | + train=dict( |
| 98 | + type='RepeatDataset', # to avoid reloading datasets frequently |
| 99 | + times=3, |
| 100 | + dataset=dict( |
| 101 | + type=dataset_type, |
| 102 | + ann_file=[ |
| 103 | + data_root + 'VOC2007/ImageSets/Main/trainval.txt', |
| 104 | + data_root + 'VOC2012/ImageSets/Main/trainval.txt' |
| 105 | + ], |
| 106 | + img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'], |
| 107 | + img_scale=(1000, 600), |
| 108 | + img_norm_cfg=img_norm_cfg, |
| 109 | + size_divisor=32, |
| 110 | + flip_ratio=0.5, |
| 111 | + with_mask=False, |
| 112 | + with_crowd=True, |
| 113 | + with_label=True)), |
| 114 | + val=dict( |
| 115 | + type=dataset_type, |
| 116 | + ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', |
| 117 | + img_prefix=data_root + 'VOC2007/', |
| 118 | + img_scale=(1000, 600), |
| 119 | + img_norm_cfg=img_norm_cfg, |
| 120 | + size_divisor=32, |
| 121 | + flip_ratio=0, |
| 122 | + with_mask=False, |
| 123 | + with_crowd=True, |
| 124 | + with_label=True), |
| 125 | + test=dict( |
| 126 | + type=dataset_type, |
| 127 | + ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', |
| 128 | + img_prefix=data_root + 'VOC2007/', |
| 129 | + img_scale=(1000, 600), |
| 130 | + img_norm_cfg=img_norm_cfg, |
| 131 | + size_divisor=32, |
| 132 | + flip_ratio=0, |
| 133 | + with_mask=False, |
| 134 | + with_label=False, |
| 135 | + test_mode=True)) |
| 136 | +# optimizer |
| 137 | +optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001) |
| 138 | +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) |
| 139 | +# learning policy |
| 140 | +lr_config = dict(policy='step', step=[3]) # actual epoch = 3 * 3 = 9 |
| 141 | +checkpoint_config = dict(interval=1) |
| 142 | +# yapf:disable |
| 143 | +log_config = dict( |
| 144 | + interval=50, |
| 145 | + hooks=[ |
| 146 | + dict(type='TextLoggerHook'), |
| 147 | + # dict(type='TensorboardLoggerHook') |
| 148 | + ]) |
| 149 | +# yapf:enable |
| 150 | +# runtime settings |
| 151 | +total_epochs = 4 # actual epoch = 4 * 3 = 12 |
| 152 | +dist_params = dict(backend='nccl') |
| 153 | +log_level = 'INFO' |
| 154 | +work_dir = './work_dirs/faster_rcnn_r50_fpn_1x_voc0712' |
| 155 | +load_from = None |
| 156 | +resume_from = None |
| 157 | +workflow = [('train', 1)] |
0 commit comments