From c01ddee14bb18b2c654d08df1760c6ab3e42f71f Mon Sep 17 00:00:00 2001 From: littletomatodonkey <2120160898@bit.edu.cn> Date: Wed, 16 Jun 2021 16:36:22 +0800 Subject: [PATCH] fix distillation and augment yaml (#851) --- .../DataAugment/ResNet50_AutoAugment.yaml | 73 ---------- .../DataAugment/ResNet50_Baseline.yaml | 72 ---------- .../configs/DataAugment/ResNet50_Cutmix.yaml | 75 ---------- .../configs/DataAugment/ResNet50_Cutout.yaml | 75 ---------- .../DataAugment/ResNet50_GridMask.yaml | 78 ---------- .../DataAugment/ResNet50_HideAndSeek.yaml | 73 ---------- ppcls/configs/DataAugment/ResNet50_Mixup.yaml | 75 ---------- .../DataAugment/ResNet50_RandAugment.yaml | 75 ---------- .../DataAugment/ResNet50_RandomErasing.yaml | 78 ---------- .../R50_vd_distill_MV3_large_x1_0.yaml | 71 --------- .../ResX101_32x16d_wsl_distill_R50_vd.yaml | 71 --------- .../DataAugment/ResNet50_AutoAugment.yaml | 130 +++++++++++++++++ .../DataAugment/ResNet50_Baseline.yaml | 129 +++++++++++++++++ .../ImageNet/DataAugment/ResNet50_Cutmix.yaml | 129 +++++++++++++++++ .../ImageNet/DataAugment/ResNet50_Cutout.yaml | 132 +++++++++++++++++ .../DataAugment/ResNet50_GridMask.yaml | 135 ++++++++++++++++++ .../DataAugment/ResNet50_HideAndSeek.yaml | 130 +++++++++++++++++ .../ImageNet/DataAugment/ResNet50_Mixup.yaml | 129 +++++++++++++++++ .../DataAugment/ResNet50_RandAugment.yaml | 132 +++++++++++++++++ .../DataAugment/ResNet50_RandomErasing.yaml | 135 ++++++++++++++++++ ppcls/data/preprocess/ops/random_erasing.py | 16 +-- 21 files changed, 1187 insertions(+), 826 deletions(-) delete mode 100644 ppcls/configs/DataAugment/ResNet50_AutoAugment.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_Baseline.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_Cutmix.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_Cutout.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_GridMask.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_HideAndSeek.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_Mixup.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_RandAugment.yaml delete mode 100644 ppcls/configs/DataAugment/ResNet50_RandomErasing.yaml delete mode 100644 ppcls/configs/Distillation/R50_vd_distill_MV3_large_x1_0.yaml delete mode 100644 ppcls/configs/Distillation/ResX101_32x16d_wsl_distill_R50_vd.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml create mode 100644 ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml diff --git a/ppcls/configs/DataAugment/ResNet50_AutoAugment.yaml b/ppcls/configs/DataAugment/ResNet50_AutoAugment.yaml deleted file mode 100644 index 81883355..00000000 --- a/ppcls/configs/DataAugment/ResNet50_AutoAugment.yaml +++ /dev/null @@ -1,73 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - AutoAugment: - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_Baseline.yaml b/ppcls/configs/DataAugment/ResNet50_Baseline.yaml deleted file mode 100644 index 76f9a897..00000000 --- a/ppcls/configs/DataAugment/ResNet50_Baseline.yaml +++ /dev/null @@ -1,72 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_Cutmix.yaml b/ppcls/configs/DataAugment/ResNet50_Cutmix.yaml deleted file mode 100644 index 83fe01a6..00000000 --- a/ppcls/configs/DataAugment/ResNet50_Cutmix.yaml +++ /dev/null @@ -1,75 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: True -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - mix: - - CutmixOperator: - alpha: 0.2 - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_Cutout.yaml b/ppcls/configs/DataAugment/ResNet50_Cutout.yaml deleted file mode 100644 index f6fef61f..00000000 --- a/ppcls/configs/DataAugment/ResNet50_Cutout.yaml +++ /dev/null @@ -1,75 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - Cutout: - n_holes: 1 - length: 112 - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_GridMask.yaml b/ppcls/configs/DataAugment/ResNet50_GridMask.yaml deleted file mode 100644 index e3e76d88..00000000 --- a/ppcls/configs/DataAugment/ResNet50_GridMask.yaml +++ /dev/null @@ -1,78 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - GridMask: - d1: 96 - d2: 224 - rotate: 1 - ratio: 0.5 - mode: 0 - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_HideAndSeek.yaml b/ppcls/configs/DataAugment/ResNet50_HideAndSeek.yaml deleted file mode 100644 index 0be47f16..00000000 --- a/ppcls/configs/DataAugment/ResNet50_HideAndSeek.yaml +++ /dev/null @@ -1,73 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - HideAndSeek: - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_Mixup.yaml b/ppcls/configs/DataAugment/ResNet50_Mixup.yaml deleted file mode 100644 index 0dd2a44f..00000000 --- a/ppcls/configs/DataAugment/ResNet50_Mixup.yaml +++ /dev/null @@ -1,75 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: True -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - mix: - - MixupOperator: - alpha: 0.2 - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_RandAugment.yaml b/ppcls/configs/DataAugment/ResNet50_RandAugment.yaml deleted file mode 100644 index 35b3bcf9..00000000 --- a/ppcls/configs/DataAugment/ResNet50_RandAugment.yaml +++ /dev/null @@ -1,75 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - RandAugment: - num_layers: 2 - magnitude: 5 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/DataAugment/ResNet50_RandomErasing.yaml b/ppcls/configs/DataAugment/ResNet50_RandomErasing.yaml deleted file mode 100644 index 624cb4dc..00000000 --- a/ppcls/configs/DataAugment/ResNet50_RandomErasing.yaml +++ /dev/null @@ -1,78 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50' - -pretrained_model: "" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 300 -topk: 5 -image_shape: [3, 224, 224] - -use_mix: False -ls_epsilon: -1 - -LEARNING_RATE: - function: 'Cosine' - params: - lr: 0.1 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.000100 - -TRAIN: - batch_size: 256 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - - RandomErasing: - EPSILON: 0.5 - sl: 0.02 - sh: 0.4 - r1: 0.3 - mean: [0., 0., 0.] - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/Distillation/R50_vd_distill_MV3_large_x1_0.yaml b/ppcls/configs/Distillation/R50_vd_distill_MV3_large_x1_0.yaml deleted file mode 100644 index e987af3a..00000000 --- a/ppcls/configs/Distillation/R50_vd_distill_MV3_large_x1_0.yaml +++ /dev/null @@ -1,71 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNet50_vd_distill_MobileNetV3_large_x1_0' - -pretrained_model: "./pretrained/ResNet50_vd_ssld_pretrained" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 120 -topk: 5 -image_shape: [3, 224, 224] - -use_distillation: True - -LEARNING_RATE: - function: 'CosineWarmup' - params: - lr: 1.3 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.00001 - -TRAIN: - batch_size: 2048 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/Distillation/ResX101_32x16d_wsl_distill_R50_vd.yaml b/ppcls/configs/Distillation/ResX101_32x16d_wsl_distill_R50_vd.yaml deleted file mode 100644 index f2cbe81d..00000000 --- a/ppcls/configs/Distillation/ResX101_32x16d_wsl_distill_R50_vd.yaml +++ /dev/null @@ -1,71 +0,0 @@ -mode: 'train' -ARCHITECTURE: - name: 'ResNeXt101_32x16d_wsl_distill_ResNet50_vd' - -pretrained_model: "./pretrained/ResNeXt101_32x16d_wsl_pretrained" -model_save_dir: "./output/" -classes_num: 1000 -total_images: 1281167 -save_interval: 1 -validate: True -valid_interval: 1 -epochs: 120 -topk: 5 -image_shape: [3, 224, 224] - -use_distillation: True - -LEARNING_RATE: - function: 'CosineWarmup' - params: - lr: 0.4 - -OPTIMIZER: - function: 'Momentum' - params: - momentum: 0.9 - regularizer: - function: 'L2' - factor: 0.00007 - -TRAIN: - batch_size: 1024 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/train_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - transforms: - - DecodeImage: - to_rgb: True - channel_first: False - - RandCropImage: - size: 224 - - RandFlipImage: - flip_code: 1 - - NormalizeImage: - scale: 1./255. - mean: [0.485, 0.456, 0.406] - std: [0.229, 0.224, 0.225] - order: '' - - ToCHWImage: - -VALID: - batch_size: 64 - num_workers: 4 - file_list: "./dataset/ILSVRC2012/val_list.txt" - data_dir: "./dataset/ILSVRC2012/" - shuffle_seed: 0 - 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: diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml new file mode 100644 index 00000000..dd0907d4 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_AutoAugment.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - AutoAugment: + - 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: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml new file mode 100644 index 00000000..48a9fdc9 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_Baseline.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - 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: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml new file mode 100644 index 00000000..265543a5 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutmix.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - CutmixOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml new file mode 100644 index 00000000..f0e53bf9 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_Cutout.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - Cutout: + n_holes: 1 + length: 112 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml new file mode 100644 index 00000000..2db82796 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_GridMask.yaml @@ -0,0 +1,135 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - GridMask: + d1: 96 + d2: 224 + rotate: 1 + ratio: 0.5 + mode: 0 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml new file mode 100644 index 00000000..e9699d43 --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_HideAndSeek.yaml @@ -0,0 +1,130 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + - HideAndSeek: + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml new file mode 100644 index 00000000..90ead48b --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_Mixup.yaml @@ -0,0 +1,129 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - NormalizeImage: + scale: 1.0/255.0 + mean: [0.485, 0.456, 0.406] + std: [0.229, 0.224, 0.225] + order: '' + batch_transform_ops: + - MixupOperator: + alpha: 0.2 + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml new file mode 100644 index 00000000..5123ef5a --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_RandAugment.yaml @@ -0,0 +1,132 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - RandAugment: + num_layers: 2 + magnitude: 5 + - 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: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml b/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml new file mode 100644 index 00000000..7d7a36af --- /dev/null +++ b/ppcls/configs/ImageNet/DataAugment/ResNet50_RandomErasing.yaml @@ -0,0 +1,135 @@ +# global configs +Global: + checkpoints: null + pretrained_model: null + output_dir: ./output/ + device: gpu + class_num: 1000 + save_interval: 1 + eval_during_train: True + eval_interval: 1 + epochs: 300 + print_batch_step: 10 + use_visualdl: False + # used for static mode and model export + image_shape: [3, 224, 224] + save_inference_dir: ./inference + +# model architecture +Arch: + name: ResNet50 + +# loss function config for traing/eval process +Loss: + Train: + - CELoss: + weight: 1.0 + Eval: + - CELoss: + weight: 1.0 + + +Optimizer: + name: Momentum + momentum: 0.9 + lr: + name: Cosine + learning_rate: 0.1 + regularizer: + name: 'L2' + coeff: 0.0001 + + +# data loader for train and eval +DataLoader: + Train: + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/train_list.txt + transform_ops: + - DecodeImage: + to_rgb: True + channel_first: False + - RandCropImage: + size: 224 + - RandFlipImage: + flip_code: 1 + - 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: 0.4 + r1: 0.3 + mean: [0., 0., 0.] + + sampler: + name: DistributedBatchSampler + batch_size: 64 + drop_last: False + shuffle: True + loader: + num_workers: 4 + use_shared_memory: True + + Eval: + # TOTO: modify to the latest trainer + dataset: + name: ImageNetDataset + image_root: ./dataset/ILSVRC2012/ + cls_label_path: ./dataset/ILSVRC2012/val_list.txt + 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: + infer_imgs: docs/images/whl/demo.jpg + batch_size: 10 + 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: Topk + topk: 5 + class_id_map_file: ppcls/utils/imagenet1k_label_list.txt + +Metric: + Train: + - TopkAcc: + topk: [1, 5] + Eval: + - TopkAcc: + topk: [1, 5] diff --git a/ppcls/data/preprocess/ops/random_erasing.py b/ppcls/data/preprocess/ops/random_erasing.py index dd6501ab..d96ceda6 100644 --- a/ppcls/data/preprocess/ops/random_erasing.py +++ b/ppcls/data/preprocess/ops/random_erasing.py @@ -21,11 +21,7 @@ import numpy as np class RandomErasing(object): - def __init__(self, - EPSILON=0.5, - sl=0.02, - sh=0.4, - r1=0.3, + def __init__(self, EPSILON=0.5, sl=0.02, sh=0.4, r1=0.3, mean=[0., 0., 0.]): self.EPSILON = EPSILON self.mean = mean @@ -37,8 +33,8 @@ class RandomErasing(object): if random.uniform(0, 1) > self.EPSILON: return img - for attempt in range(100): - area = img.shape[1] * img.shape[2] + for _ in range(100): + area = img.shape[0] * img.shape[1] target_area = random.uniform(self.sl, self.sh) * area aspect_ratio = random.uniform(self.r1, 1 / self.r1) @@ -50,9 +46,9 @@ class RandomErasing(object): x1 = random.randint(0, img.shape[1] - h) y1 = random.randint(0, img.shape[2] - w) if img.shape[0] == 3: - img[0, x1:x1 + h, y1:y1 + w] = self.mean[0] - img[1, x1:x1 + h, y1:y1 + w] = self.mean[1] - img[2, x1:x1 + h, y1:y1 + w] = self.mean[2] + img[x1:x1 + h, y1:y1 + w, 0] = self.mean[0] + img[x1:x1 + h, y1:y1 + w, 1] = self.mean[1] + img[x1:x1 + h, y1:y1 + w, 2] = self.mean[2] else: img[0, x1:x1 + h, y1:y1 + w] = self.mean[1] return img -- GitLab