_base_ = 'base.py'
model = dict(
    type='GroupRCNN',
    backbone=dict(type='ResNet',
                  depth=50,
                  num_stages=4,
                  out_indices=(0, 1, 2, 3),
                  frozen_stages=1,
                  norm_cfg=dict(type='BN', requires_grad=True),
                  norm_eval=True,
                  style='pytorch',
                  init_cfg=dict(type='Pretrained',
                                checkpoint='torchvision://resnet50')),
    neck=dict(type='FPN',
              in_channels=[256, 512, 1024, 2048],
              out_channels=256,
              start_level=1,
              add_extra_convs='on_input',
              num_outs=5),
    rpn_head=dict(type='RetinaHead',
                  num_classes=80,
                  in_channels=256,
                  stacked_convs=4,
                  feat_channels=256,
                  anchor_generator=dict(type='AnchorGenerator',
                                        octave_base_scale=4,
                                        scales_per_octave=3,
                                        ratios=[0.5, 1.0, 2.0],
                                        strides=[8, 16, 32, 64, 128]),
                  bbox_coder=dict(type='DeltaXYWHBBoxCoder',
                                  target_means=[.0, .0, .0, .0],
                                  target_stds=[1.0, 1.0, 1.0, 1.0]),
                  loss_cls=dict(type='FocalLoss',
                                use_sigmoid=True,
                                gamma=2.0,
                                alpha=0.25,
                                loss_weight=1.0),
                  loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
    roi_head=dict(type='GroupRoIHead',
                  num_stages=3,
                  stage_loss_weights=[1, 0.5, 0.25],
                  bbox_roi_extractor=dict(type='SingleRoIExtractor',
                                          roi_layer=dict(type='RoIAlign',
                                                         output_size=7,
                                                         sampling_ratio=0),
                                          out_channels=256,
                                          featmap_strides=[8, 16, 32, 64]),
                  bbox_head=[
                      dict(type='Shared2FCBBoxHead',
                           in_channels=256,
                           fc_out_channels=1024,
                           roi_feat_size=7,
                           num_classes=80,
                           bbox_coder=dict(type='DeltaXYWHBBoxCoder',
                                           target_means=[0.0, 0.0, 0.0, 0.0],
                                           target_stds=[0.1, 0.1, 0.2, 0.2]),
                           reg_class_agnostic=True,
                           loss_cls=dict(type='CrossEntropyLoss',
                                         use_sigmoid=False,
                                         loss_weight=1.0),
                           loss_bbox=dict(type='SmoothL1Loss',
                                          beta=1.0,
                                          loss_weight=1.0)),
                      dict(type='Shared2FCBBoxHead',
                           in_channels=256,
                           fc_out_channels=1024,
                           roi_feat_size=7,
                           num_classes=80,
                           bbox_coder=dict(type='DeltaXYWHBBoxCoder',
                                           target_means=[0.0, 0.0, 0.0, 0.0],
                                           target_stds=[0.05, 0.05, 0.1, 0.1]),
                           reg_class_agnostic=True,
                           loss_cls=dict(type='CrossEntropyLoss',
                                         use_sigmoid=False,
                                         loss_weight=1.0),
                           loss_bbox=dict(type='SmoothL1Loss',
                                          beta=1.0,
                                          loss_weight=1.0)),
                      dict(type='Shared2FCBBoxHead',
                           in_channels=256,
                           fc_out_channels=1024,
                           roi_feat_size=7,
                           num_classes=80,
                           bbox_coder=dict(
                               type='DeltaXYWHBBoxCoder',
                               target_means=[0.0, 0.0, 0.0, 0.0],
                               target_stds=[0.033, 0.033, 0.067, 0.067]),
                           reg_class_agnostic=True,
                           loss_cls=dict(type='CrossEntropyLoss',
                                         use_sigmoid=False,
                                         loss_weight=1.0),
                           loss_bbox=dict(type='SmoothL1Loss',
                                          beta=1.0,
                                          loss_weight=1.0))
                  ]),
    train_cfg=dict(rpn=dict(assigner=dict(type='MaxIoUAssigner',
                                          pos_iou_thr=0.5,
                                          neg_iou_thr=0.4,
                                          min_pos_iou=0,
                                          ignore_iof_thr=-1),
                            allowed_border=-1,
                            pos_weight=-1,
                            debug=False),
                   rpn_proposal=None,
                   rcnn=None),
    # only used to evaluate the rpn results
    # do not be adopted when generate the proposals for second stage.
    test_cfg=dict(rpn=dict(nms_pre=1000,
                           max_per_img=100,
                           nms=dict(type='nms', iou_threshold=0.5),
                           score_thr=0.05,
                           min_bbox_size=0),
                  rcnn=None))

lr_config = dict(step=[30, 40])
runner = dict(type='EpochBasedRunner', max_epochs=50)
checkpoint_config = dict(interval=5)
evaluation = dict(interval=5, metric='bbox')
