softmax_triplet_with_center.yaml 4.4 KB
Newer Older
H
HydrogenSulfate 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
# global configs
Global:
  checkpoints: null
  pretrained_model: null
  output_dir: "./output/"
  device: "gpu"
  save_interval: 40
  eval_during_train: True
  eval_interval: 10
  epochs: 120
  print_batch_step: 20
  use_visualdl: False
  eval_mode: "retrieval"
H
HydrogenSulfate 已提交
14
  retrieval_feature_from: "features" # 'backbone' or 'features'
H
HydrogenSulfate 已提交
15 16 17 18 19 20 21 22 23 24 25
  # used for static mode and model export
  image_shape: [3, 256, 128]
  save_inference_dir: "./inference"

# model architecture
Arch:
  name: "RecModel"
  infer_output_key: "features"
  infer_add_softmax: False
  Backbone:
    name: "ResNet50_last_stage_stride1"
H
HydrogenSulfate 已提交
26
    pretrained: True
H
HydrogenSulfate 已提交
27 28 29 30 31 32
    stem_act: null
  BackboneStopLayer:
    name: "flatten"
  Neck:
    name: BNNeck
    num_features: &feat_dim 2048
H
HydrogenSulfate 已提交
33 34 35 36 37 38 39 40
    weight_attr:
      initializer:
        name: Constant
        value: 1.0
    bias_attr:
      initializer:
        name: Constant
        value: 0.0
H
HydrogenSulfate 已提交
41
      learning_rate: 1.0e-20 # NOTE: Temporarily set lr small enough to freeze the bias to zero
H
HydrogenSulfate 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
  Head:
    name: "FC"
    embedding_size: *feat_dim
    class_num: &class_num 751
    weight_attr:
      initializer:
        name: Normal
        std: 0.001
    bias_attr: False

# loss function config for traing/eval process
Loss:
  Train:
    - CELoss:
        weight: 1.0
        epsilon: 0.1
H
HydrogenSulfate 已提交
58
    - TripletLossV2:
H
HydrogenSulfate 已提交
59 60
        weight: 1.0
        margin: 0.3
H
HydrogenSulfate 已提交
61 62
        normalize_feature: False
        feature_from: "backbone"
H
HydrogenSulfate 已提交
63 64 65 66
    - CenterLoss:
        weight: 0.0005
        num_classes: *class_num
        feat_dim: *feat_dim
H
HydrogenSulfate 已提交
67
        feature_from: "backbone"
H
HydrogenSulfate 已提交
68 69 70 71 72 73
  Eval:
    - CELoss:
        weight: 1.0

Optimizer:
  - Adam:
H
HydrogenSulfate 已提交
74
      scope: RecModel
H
HydrogenSulfate 已提交
75 76 77 78 79 80
      lr:
        name: Piecewise
        decay_epochs: [30, 60]
        values: [0.00035, 0.000035, 0.0000035]
        warmup_epoch: 10
        warmup_start_lr: 0.0000035
H
HydrogenSulfate 已提交
81 82
        by_epoch: True
        last_epoch: 0
H
HydrogenSulfate 已提交
83 84 85
      regularizer:
        name: 'L2'
        coeff: 0.0005
H
HydrogenSulfate 已提交
86
  - SGD:
H
HydrogenSulfate 已提交
87 88 89
      scope: CenterLoss
      lr:
        name: Constant
H
HydrogenSulfate 已提交
90
        learning_rate: 1000.0 # NOTE: set to ori_lr*(1/centerloss_weight) to avoid manually scaling centers' gradidents.
H
HydrogenSulfate 已提交
91 92 93 94 95

# data loader for train and eval
DataLoader:
  Train:
    dataset:
H
HydrogenSulfate 已提交
96 97 98
        name: "Market1501"
        image_root: "./dataset/"
        cls_label_path: "bounding_box_train"
H
HydrogenSulfate 已提交
99
        backend: "pil"
H
HydrogenSulfate 已提交
100 101 102
        transform_ops:
          - ResizeImage:
              size: [128, 256]
H
HydrogenSulfate 已提交
103
              return_numpy: False
104
              interpolation: 'bilinear'
H
HydrogenSulfate 已提交
105
              backend: "pil"
H
HydrogenSulfate 已提交
106 107 108 109
          - RandFlipImage:
              flip_code: 1
          - Pad:
              padding: 10
H
HydrogenSulfate 已提交
110
          - RandCropImageV2:
H
HydrogenSulfate 已提交
111
              size: [128, 256]
H
HydrogenSulfate 已提交
112 113
          - ToTensor:
          - Normalize:
H
HydrogenSulfate 已提交
114 115 116 117 118 119 120
              mean: [0.485, 0.456, 0.406]
              std: [0.229, 0.224, 0.225]
          - RandomErasing:
              EPSILON: 0.5
              sl: 0.02
              sh: 0.4
              r1: 0.3
H
HydrogenSulfate 已提交
121
              mean: [0.485, 0.456, 0.406]
H
HydrogenSulfate 已提交
122 123 124 125
    sampler:
        name: DistributedRandomIdentitySampler
        batch_size: 64
        num_instances: 4
H
HydrogenSulfate 已提交
126
        drop_last: False
H
HydrogenSulfate 已提交
127 128
        shuffle: True
    loader:
H
HydrogenSulfate 已提交
129
        num_workers: 4
H
HydrogenSulfate 已提交
130 131 132 133
        use_shared_memory: True
  Eval:
    Query:
      dataset:
H
HydrogenSulfate 已提交
134 135 136
        name: "Market1501"
        image_root: "./dataset/"
        cls_label_path: "query"
H
HydrogenSulfate 已提交
137
        backend: "pil"
H
HydrogenSulfate 已提交
138 139 140
        transform_ops:
          - ResizeImage:
              size: [128, 256]
H
HydrogenSulfate 已提交
141
              return_numpy: False
142
              interpolation: 'bilinear'
H
HydrogenSulfate 已提交
143
              backend: "pil"
H
HydrogenSulfate 已提交
144 145
          - ToTensor:
          - Normalize:
H
HydrogenSulfate 已提交
146 147 148 149 150 151 152 153
              mean: [0.485, 0.456, 0.406]
              std: [0.229, 0.224, 0.225]
      sampler:
        name: DistributedBatchSampler
        batch_size: 128
        drop_last: False
        shuffle: False
      loader:
H
HydrogenSulfate 已提交
154
        num_workers: 4
H
HydrogenSulfate 已提交
155 156 157 158
        use_shared_memory: True

    Gallery:
      dataset:
H
HydrogenSulfate 已提交
159 160 161
        name: "Market1501"
        image_root: "./dataset/"
        cls_label_path: "bounding_box_test"
H
HydrogenSulfate 已提交
162
        backend: "pil"
H
HydrogenSulfate 已提交
163 164 165
        transform_ops:
          - ResizeImage:
              size: [128, 256]
H
HydrogenSulfate 已提交
166
              return_numpy: False
167
              interpolation: 'bilinear'
H
HydrogenSulfate 已提交
168
              backend: "pil"
H
HydrogenSulfate 已提交
169 170
          - ToTensor:
          - Normalize:
H
HydrogenSulfate 已提交
171 172 173 174 175 176 177 178
              mean: [0.485, 0.456, 0.406]
              std: [0.229, 0.224, 0.225]
      sampler:
        name: DistributedBatchSampler
        batch_size: 128
        drop_last: False
        shuffle: False
      loader:
H
HydrogenSulfate 已提交
179
        num_workers: 4
H
HydrogenSulfate 已提交
180 181 182 183 184 185 186
        use_shared_memory: True

Metric:
  Eval:
    - Recallk:
        topk: [1, 5]
    - mAP: {}