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

# 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

log_iter: 10
snapshot_epoch: 3
weights: output/ppyoloe_r_crn_l_3x_dota/model_final

pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/CSPResNetb_l_pretrained.pdparams
depth_mult: 1.0
width_mult: 1.0

##### Data
metric: RBOX
num_classes: 15

TrainDataset:
    name: COCODataSet
    image_dir: images
    anno_path: annotations/instance_train.json
    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data
    data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd', 'gt_poly']

EvalDataset:
    name: COCODataSet
    image_dir: images
    anno_path: annotations/instance_val.json
    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data
    data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd', 'gt_poly']

TestDataset:
    name: ImageFolder
    anno_path: annotations/instance_val.json
    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data

worker_num: 4
image_height: &image_height 1024
image_width: &image_width 1024
image_size: &image_size [*image_height, *image_width]

TrainReader:
  sample_transforms:
    - Decode: {}
    - Poly2Array: {}
    - RandomRFlip: {}
    - RandomRRotate: {angle_mode: 'value', angle: [0, 90, 180, -90]}
    - RandomRRotate: {angle_mode: 'value', angle: [30, 60], rotate_prob: 0.5}
    - RResize: {target_size: *image_size, keep_ratio: True, interp: 2}
    - Poly2RBox: {filter_threshold: 2, filter_mode: 'edge', rbox_type: 'oc'}
  batch_transforms:
    - NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
    - Permute: {}
    - PadRGT: {}
    - PadBatch: {pad_to_stride: 32}
  batch_size: 4
  shuffle: true
  drop_last: true
  use_shared_memory: true
  collate_batch: true

EvalReader:
  sample_transforms:
    - Decode: {}
    - Poly2Array: {}
    - RResize: {target_size: *image_size, keep_ratio: True, interp: 2}
    - 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: 32}
  batch_size: 6
  collate_batch: false

TestReader:
  sample_transforms:
    - Decode: {}
    - Resize: {target_size: *image_size, keep_ratio: True, interp: 2}
    - 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: 32}
  batch_size: 2

##### Model

architecture: YOLOv3
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998

YOLOv3:
  backbone: CSPResNet
  neck: CustomCSPPAN
  yolo_head: PPYOLOERHead
  post_process: ~

CSPResNet:
  layers: [3, 6, 6, 3]
  channels: [64, 128, 256, 512, 1024]
  return_idx: [1, 2, 3]
  use_large_stem: True
  use_alpha: True

CustomCSPPAN:
  out_channels: [768, 384, 192]
  stage_num: 1
  block_num: 3
  act: 'swish'
  spp: true
  use_alpha: True

PPYOLOERHead:
  fpn_strides: [32, 16, 8]
  grid_cell_offset: 0.5
  use_varifocal_loss: true
  static_assigner_epoch: -1
  loss_weight: {class: 1.0, iou: 2.5, dfl: 0.05}
  static_assigner:
    name: FCOSRAssigner
    factor: 12
    threshold: 0.23
    boundary: [[512, 10000], [256, 512], [-1, 256]]
  assigner:
    name: RotatedTaskAlignedAssigner
    topk: 13
    alpha: 1.0
    beta: 6.0
  nms:
    name: MultiClassNMS
    nms_top_k: 2000
    keep_top_k: -1
    score_threshold: 0.1
    nms_threshold: 0.1
    normalized: False

##### Optimizer

epoch: 36

LearningRate:
  base_lr: 0.064
  schedulers:
    - !CosineDecay
      max_epochs: 44
    - !LinearWarmup
      start_factor: 0.
      steps: 1000

OptimizerBuilder:
  clip_grad_by_norm: 35.
  optimizer:
    momentum: 0.9
    type: Momentum
  regularizer:
    factor: 0.0005
    type: L2
