epoch: 12
use_gpu: true
use_xpu: false
use_mlu: false
use_npu: false
target_metrics: mask
log_iter: 20
save_dir: output
snapshot_epoch: 1
print_flops: false
print_params: false

# Dataset
metric: COCO
num_classes: 80

worker_num: 8

TrainDataset:
  name: COCODataSet
  image_dir: train2017
  anno_path: annotations/instances_train2017.json
  dataset_dir: dataset/coco
  data_fields: ['image', 'gt_bbox', 'gt_class', 'gt_poly', 'is_crowd']

EvalDataset:
  name: COCODataSet
  image_dir: val2017
  anno_path: annotations/instances_val2017.json
  dataset_dir: dataset/coco

TestDataset:
  name: ImageFolder
  anno_path: annotations/instances_val2017.json # also support txt (like VOC's label_list.txt)
  dataset_dir: dataset/coco # if set, anno_path will be 'dataset_dir/anno_path'

TrainReader:
  sample_transforms:
  - Decode: {}
  - Poly2Mask: {}
  - Resize: {interp: 1, target_size: [800, 1333], keep_ratio: True}
  - RandomFlip: {}
  - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  - Permute: {}
  batch_transforms:
  - PadBatch: {pad_to_stride: 32}
  - Gt2Solov2Target: {num_grids: [40, 36, 24, 16, 12],
                        scale_ranges: [[1, 96], [48, 192], [96, 384], [192, 768], [384, 2048]],
                        coord_sigma: 0.2}
  batch_size: 2
  shuffle: true
  drop_last: true


EvalReader:
  sample_transforms:
  - Decode: {}
  - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  - Resize: {interp: 1, target_size: [800, 1333], keep_ratio: True}
  - Permute: {}
  batch_transforms:
  - PadBatch: {pad_to_stride: 32}
  batch_size: 1
  shuffle: false
  drop_last: false


TestReader:
  sample_transforms:
  - Decode: {}
  - NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]}
  - Resize: {interp: 1, target_size: [800, 1333], keep_ratio: True}
  - Permute: {}
  batch_transforms:
  - PadBatch: {pad_to_stride: 32}
  batch_size: 1
  shuffle: false
  drop_last: false

LearningRate:
  base_lr: 0.01
  schedulers:
  - !PiecewiseDecay
    gamma: 0.1
    milestones: [8, 11]
  - !LinearWarmup
    start_factor: 0.
    steps: 1000

OptimizerBuilder:
  optimizer:
    momentum: 0.9
    type: Momentum
  regularizer:
    factor: 0.0001
    type: L2

# Model
architecture: SOLOv2
pretrain_weights: https://paddledet.bj.bcebos.com/models/solov2_r50_fpn_1x_coco.pdparams

SOLOv2:
  backbone: ResNet
  neck: FPN
  solov2_head: SOLOv2Head
  mask_head: SOLOv2MaskHead

ResNet:
  depth: 50
  freeze_at: 0
  return_idx: [0,1,2,3]
  num_stages: 4

FPN:
  out_channel: 256

SOLOv2Head:
  seg_feat_channels: 512
  stacked_convs: 4
  num_grids: [40, 36, 24, 16, 12]
  kernel_out_channels: 256
  solov2_loss: SOLOv2Loss
  mask_nms: MaskMatrixNMS

SOLOv2MaskHead:
  mid_channels: 128
  out_channels: 256
  start_level: 0
  end_level: 3

SOLOv2Loss:
  ins_loss_weight: 3.0
  focal_loss_gamma: 2.0
  focal_loss_alpha: 0.25

MaskMatrixNMS:
  pre_nms_top_n: 500
  post_nms_top_n: 100




# Exporting the model
export:
  post_process: True 
  nms: True 
  benchmark: False 
  fuse_conv_bn: False
