# Runtime
use_ema: true
use_gpu: true
use_xpu: false
use_mlu: false
use_npu: false
log_iter: 20
save_dir: output
snapshot_epoch: 1
print_flops: false
print_params: false

# Dataset
metric: COCO
num_classes: 80

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

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

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'


# Reader
worker_num: 2
TrainReader:
  sample_transforms:
  - Decode: {}
  - Resize: {target_size: [800, 1333], keep_ratio: True, interp: 1}
  - NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
  - RandomFlip: {}
  batch_transforms:
  - Permute: {}
  - PadBatch: {pad_to_stride: 128}
  - Gt2FCOSTarget:
      object_sizes_boundary: [64, 128, 256, 512]
      center_sampling_radius: 1.5
      downsample_ratios: [8, 16, 32, 64, 128]
      norm_reg_targets: True
  batch_size: 2
  shuffle: True
  drop_last: True
  use_shared_memory: True


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


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

# Model
architecture: FCOS
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams

FCOS:
  backbone: ResNet
  neck: FPN
  fcos_head: FCOSHead

ResNet:
  depth: 50
  variant: 'b'
  norm_type: bn
  freeze_at: 0 # res2
  return_idx: [1, 2, 3]
  num_stages: 4

FPN:
  out_channel: 256
  spatial_scales: [0.125, 0.0625, 0.03125]
  extra_stage: 2
  has_extra_convs: True
  use_c5: False

FCOSHead:
  fcos_feat:
    name: FCOSFeat
    feat_in: 256
    feat_out: 256
    num_convs: 4
    norm_type: "gn"
    use_dcn: False
  fpn_stride: [8, 16, 32, 64, 128]
  prior_prob: 0.01
  norm_reg_targets: True
  centerness_on_reg: True
  num_shift: 0.5
  fcos_loss:
    name: FCOSLoss
    loss_alpha: 0.25
    loss_gamma: 2.0
    iou_loss_type: "giou"
    reg_weights: 1.0
  nms:
    name: MultiClassNMS
    nms_top_k: 1000
    keep_top_k: 100
    score_threshold: 0.025
    nms_threshold: 0.6

# Optimizer
epoch: 12

LearningRate:
  base_lr: 0.01
  schedulers:
  - !PiecewiseDecay
    gamma: 0.1
    milestones: [8, 11]
  - !LinearWarmup
    start_factor: 0.3333333333333333
    steps: 500

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

# Exporting the model
export:
  post_process: True  # Whether post-processing is included in the network when export model.
  nms: True           # Whether NMS is included in the network when export model.
  benchmark: False    # It is used to testing model performance, if set `True`, post-process and NMS will not be exported.
  fuse_conv_bn: False
