total_iters: 150000
output_dir: output_dir
find_unused_parameters: True
checkpoints_dir: checkpoints
use_dataset: True
# tensor range for function tensor2img
min_max:
  (0., 1.)

model:
  name: MultiStageVSRModel
  fix_iter: 2500
  generator:
    name: MSVSR
    mid_channels: 32
    num_init_blocks: 2
    num_blocks: 3
    num_reconstruction_blocks: 2
    only_last: True
    use_tiny_spynet: True
    deform_groups: 4
    stage1_groups: 8
    auxiliary_loss: True
    use_refine_align: True
    aux_reconstruction_blocks: 1
    use_local_connnect: True
  pixel_criterion:
    name: CharbonnierLoss
    reduction: mean

dataset:
  train:
    name: RepeatDataset
    times: 1000
    num_workers: 6
    batch_size: 2  #8 gpus
    dataset:
      name: VSRREDSMultipleGTDataset
      lq_folder: data/REDS/train_sharp_bicubic/X4
      gt_folder: data/REDS/train_sharp/X4
      ann_file: data/REDS/meta_info_REDS_GT.txt
      num_frames: 20
      preprocess:
        - name: GetNeighboringFramesIdx
          interval_list: [1]
        - name: ReadImageSequence
          key: lq
        - name: ReadImageSequence
          key: gt
        - name: Transforms
          input_keys: [lq, gt]
          pipeline:
            - name: SRPairedRandomCrop
              gt_patch_size: 256
              scale: 4
              keys: [image, image]
            - name: PairedRandomHorizontalFlip
              keys: [image, image]
            - name: PairedRandomVerticalFlip
              keys: [image, image]
            - name: PairedRandomTransposeHW
              keys: [image, image]
            - name: TransposeSequence
              keys: [image, image]
            - name: NormalizeSequence
              mean: [0., 0., 0.]
              std: [255., 255., 255.]
              keys: [image, image]

  test:
    name: VSRREDSMultipleGTDataset
    lq_folder: data/REDS/REDS4_test_sharp_bicubic/X4
    gt_folder: data/REDS/REDS4_test_sharp/X4
    ann_file: data/REDS/meta_info_REDS_GT.txt
    num_frames: 100
    test_mode: True
    preprocess:
        - name: GetNeighboringFramesIdx
          interval_list: [1]
        - name: ReadImageSequence
          key: lq
        - name: ReadImageSequence
          key: gt
        - name: Transforms
          input_keys: [lq, gt]
          pipeline:
            - name: TransposeSequence
              keys: [image, image]
            - name: NormalizeSequence
              mean: [0., 0., 0.]
              std: [255., 255., 255.]
              keys: [image, image]

lr_scheduler:
  name: CosineAnnealingRestartLR
  learning_rate: !!float 2e-4
  periods: [150000]
  restart_weights: [1]
  eta_min: !!float 1e-7

optimizer:
  name: Adam
  # add parameters of net_name to optim
  # name should in self.nets
  net_names:
    - generator
  beta1: 0.9
  beta2: 0.99

validate:
  interval: 5000
  save_img: false

  metrics:
    psnr: # metric name, can be arbitrary
      name: PSNR
      crop_border: 0
      test_y_channel: false
    ssim:
      name: SSIM
      crop_border: 0
      test_y_channel: false

log_config:
  interval: 10
  visiual_interval: 5000

snapshot_config:
  interval: 5000

export_model:
  - {name: 'generator', inputs_num: 1}
