Based on the flowers102 dataset, it takes only 30 mins to experience PaddleClas, include training varieties of backbone and pretrained model, SSLD distillation, and multiple data augmentation, Please refer to Installation to install at first.
cd path_to_PaddleClas
dataset/flowers102
, download and decompress flowers102 dataset.cd dataset/flowers102
wget https://www.robots.ox.ac.uk/~vgg/data/flowers/102/102flowers.tgz
wget https://www.robots.ox.ac.uk/~vgg/data/flowers/102/imagelabels.mat
wget https://www.robots.ox.ac.uk/~vgg/data/flowers/102/setid.mat
tar -xf 102flowers.tgz
python generate_flowers102_list.py jpg train > train_list.txt
python generate_flowers102_list.py jpg valid > val_list.txt
python generate_flowers102_list.py jpg test > extra_list.txt
cat train_list.txt extra_list.txt > train_extra_list.txt
Note: In order to offer more data to SSLD training task, train_list.txt and extra_list.txt will merge into train_extra_list.txft
PaddleClas
dircd ../../
export PYTHONPATH=./:$PYTHONPATH
python tools/download.py -a ResNet50_vd -p ./pretrained -d True
python tools/download.py -a ResNet50_vd_ssld -p ./pretrained -d True
python tools/download.py -a MobileNetV3_large_x1_0 -p ./pretrained -d True
Paramters:
architecture
(shortname: a): model name.path
(shortname: p) download path.decompress
(shortname: d) whether to decompress.export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/ResNet50_vd.yaml
The validation Top1 Acc
curve is showmn below.
export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/ResNet50_vd_finetune.yaml
The validation Top1 Acc
curve is shown below
Compare with training from scratch, it improve by 65% to 94.02%
Note: when finetuning model, which has been trained by SSLD, please use smaller learning rate in the middle of net.
ARCHITECTURE:
name: 'ResNet50_vd'
params:
lr_mult_list: [0.1, 0.1, 0.2, 0.2, 0.3]
pretrained_model: "./pretrained/ResNet50_vd_ssld_pretrained"
Tringing script
export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/ResNet50_vd_ssld_finetune.yaml
Compare with finetune on the 79.12% pretrained model, it improve by 0.9% to 95%.
Training script
export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/MobileNetV3_large_x1_0_finetune.yaml
Compare with ResNet50_vd pretrained model, it decrease by 5% to 90%. Different architecture generates different performance, actually it is a task-oriented decision to apply the best performance model, should consider the inference time, storage, heterogeneous device, etc.
Data augmentation works when training data is small.
Training script
export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/ResNet50_vd_ssld_random_erasing_finetune.yaml
It improves by 1.27% to 96.27%
cp -r output/ResNet50_vd/19/ ./pretrained/flowers102_R50_vd_final/
extra_list.txt
and val_list.txt
don't have intersectiontotal_images: 7169
ARCHITECTURE:
name: 'ResNet50_vd_distill_MobileNetV3_large_x1_0'
pretrained_model:
- "./pretrained/flowers102_R50_vd_final/ppcls"
- "./pretrained/MobileNetV3_large_x1_0_pretrained/”
TRAIN:
file_list: "./dataset/flowers102/train_extra_list.txt"
Final training script
export CUDA_VISIBLE_DEVICES=0
python -m paddle.distributed.launch \
--gpus="0" \
tools/train.py \
-c ./configs/quick_start/R50_vd_distill_MV3_large_x1_0.yaml
It significantly imporve by 6.47% to 96.47% with more unlabeled data and teacher model.
Configuration | Top1 Acc |
---|---|
ResNet50_vd.yaml | 0.2735 |
MobileNetV3_large_x1_0_finetune.yaml | 0.9000 |
ResNet50_vd_finetune.yaml | 0.9402 |
ResNet50_vd_ssld_finetune.yaml | 0.9500 |
ResNet50_vd_ssld_random_erasing_finetune.yaml | 0.9627 |
R50_vd_distill_MV3_large_x1_0.yaml | 0.9647 |
The whole accuracy curves are shown below
NOTE: As flowers102 is a small dataset, validatation accuracy maybe float 1%.
Please refer to Getting_started for more details
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。