PPLCNet_x1_0_distillation.yaml 4.2 KB
Newer Older
T
Tingquan Gao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# global configs
Global:
  checkpoints: null
  pretrained_model: null
  output_dir: ./output
  device: gpu
  save_interval: 1
  eval_during_train: True
  start_eval_epoch: 1
  eval_interval: 1
  epochs: 40
  print_batch_step: 10
  use_visualdl: False
  # used for static mode and model export
  image_shape: [3, 224, 224]
  save_inference_dir: ./inference
  # training model under @to_static
  to_static: False
  use_dali: False

# model architecture
Arch:
  name: "DistillationModel"
  class_num: &class_num 2
  # if not null, its lengths should be same as models
  pretrained_list:
  # if not null, its lengths should be same as models
  freeze_params_list:
G
gaotingquan 已提交
29
  - False
T
Tingquan Gao 已提交
30 31 32 33
  - False
  use_sync_bn: True
  models:
    - Teacher:
G
gaotingquan 已提交
34
        name: PPLCNet_x1_0
T
Tingquan Gao 已提交
35
        class_num: *class_num
G
gaotingquan 已提交
36 37 38 39
        pretrained: True
        use_ssld: True
        return_stages: True
        return_patterns: ["blocks3", "blocks4", "blocks5", "blocks6"]
T
Tingquan Gao 已提交
40 41 42 43 44
    - Student:
        name: PPLCNet_x1_0
        class_num: *class_num
        pretrained: True
        use_ssld: True
G
gaotingquan 已提交
45 46
        return_stages: True
        return_patterns: ["blocks3", "blocks4", "blocks5", "blocks6"]
T
Tingquan Gao 已提交
47 48 49 50 51 52

  infer_model_name: "Student"
 
# loss function config for traing/eval process
Loss:
  Train:
G
gaotingquan 已提交
53 54 55 56
    - DistillationGTCELoss:
        weight: 1.0
        key: logits
        model_names: ["Student", "Teacher"]
T
Tingquan Gao 已提交
57 58
    - DistillationDMLLoss:
        weight: 1.0
G
gaotingquan 已提交
59 60 61 62 63 64
        key: logits
        model_name_pairs:
        - ["Student", "Teacher"]
    - DistillationDistanceLoss:
        weight: 1.0
        key: "blocks4"
T
Tingquan Gao 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        model_name_pairs:
        - ["Student", "Teacher"]
  Eval:
    - CELoss:
        weight: 1.0


Optimizer:
  name: Momentum
  momentum: 0.9
  lr:
    name: Cosine
    learning_rate: 0.015
    warmup_epoch: 5
  regularizer:
    name: 'L2'
    coeff: 0.00003


# data loader for train and eval
DataLoader:
  Train:
    dataset:
      name: ImageNetDataset
G
fix  
gaotingquan 已提交
89 90
      image_root: ./dataset/safety_helmet/
      cls_label_path: ./dataset/safety_helmet/train_list.txt
T
Tingquan Gao 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
      transform_ops:
        - DecodeImage:
            to_rgb: True
            channel_first: False
        - RandCropImage:
            size: 192
        - RandFlipImage:
            flip_code: 1
        - TimmAutoAugment:
            prob: 0.5
            config_str: rand-m9-mstd0.5-inc1
            interpolation: bicubic
            img_size: 192
        - NormalizeImage:
            scale: 1.0/255.0
            mean: [0.485, 0.456, 0.406]
            std: [0.229, 0.224, 0.225]
            order: ''
        - RandomErasing:
            EPSILON: 0.5
            sl: 0.02
            sh: 1.0/3.0
            r1: 0.3
            attempt: 10
            use_log_aspect: True
            mode: pixel
    sampler:
      name: DistributedBatchSampler
      batch_size: 64
      drop_last: False
      shuffle: True
    loader:
      num_workers: 8
      use_shared_memory: True

  Eval:
    dataset: 
      name: ImageNetDataset
G
fix  
gaotingquan 已提交
129 130
      image_root: ./dataset/safety_helmet/
      cls_label_path: ./dataset/safety_helmet/val_list.txt
T
Tingquan Gao 已提交
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
      transform_ops:
        - DecodeImage:
            to_rgb: True
            channel_first: False
        - ResizeImage:
            resize_short: 256
        - CropImage:
            size: 224
        - NormalizeImage:
            scale: 1.0/255.0
            mean: [0.485, 0.456, 0.406]
            std: [0.229, 0.224, 0.225]
            order: ''
    sampler:
      name: DistributedBatchSampler
      batch_size: 64
      drop_last: False
      shuffle: False
    loader:
      num_workers: 4
      use_shared_memory: True

Infer:
G
gaotingquan 已提交
154
  infer_imgs: deploy/images/PULC/safety_helmet/safety_helmet_test_1.png
T
Tingquan Gao 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
  batch_size: 1
  transforms:
    - DecodeImage:
        to_rgb: True
        channel_first: False
    - ResizeImage:
        resize_short: 256
    - CropImage:
        size: 224
    - NormalizeImage:
        scale: 1.0/255.0
        mean: [0.485, 0.456, 0.406]
        std: [0.229, 0.224, 0.225]
        order: ''
    - ToCHWImage:
  PostProcess:
    name: ThreshOutput
G
gaotingquan 已提交
172
    threshold: 0.5
G
gaotingquan 已提交
173 174
    label_0: wearing_helmet
    label_1: unwearing_helmet
T
Tingquan Gao 已提交
175 176 177 178 179

Metric:
  Train:
    - DistillationTopkAcc:
        model_key: "Student"
G
gaotingquan 已提交
180
        topk: [1]
T
Tingquan Gao 已提交
181 182 183 184
  Eval:
    - TprAtFpr:
        max_fpr: 0.0001
    - TopkAcc:
G
gaotingquan 已提交
185
        topk: [1]