-
用Paddle复现CycleMLP: A MLP-like Architecture for Dense Prediction论文
-
精度对比:
Model | paddlepaddle | pytorch | diff |
---|---|---|---|
CycleMLP-B1 | 78.794 | 78.9 | -0.106 |
CycleMLP-B2 | 81.508 | 81.6 | -0.092 |
CycleMLP-B3 | 82.274 | 82.4 | -0.126 |
CycleMLP-B4 | 82.962 | 83.0 | -0.038 |
CycleMLP-B5 | 83.25 | 83.2 | +0.05 |
paddle模型参数压缩包下载地址(CycleMLP-B1/2/3/4/5.pdparams)
超参数 | 设置值 |
---|---|
momentum | 0.9 |
weight decay | 5x10^-2 |
learning rate | 1x10^-3 |
epochs | 300 |
batch size | 1024 |
- 注:上述参数设置是在 8 Tesla V100 GPUs,在单卡上 batch size 减少倍数与 learning rate 减少倍数相同。
-
部分数据增强来自于PaddleClas
-
Mixup 混合数据增强
它可以将不同类之间的图像进行混合,从而扩充训练数据集。
- 李宏毅机器学习进阶-知识萃取
- 教师模型来自于PaddleClas
- 注:pip安装PaddleClas可能会卡在open-cv那里,可以下载压缩包,教师模型参数也需要下载在本地。
1. 下载地址
- 一个文件夹下放置图片,例如:
- 一个.txt文件,内含图片名,标签(以空格隔开),例如:
- map_to_1000.txt 文件内含类别映射,需要关注图片文件名前面几个字段。
!mkdir /home/aistudio/data/tar
!mkdir /home/aistudio/data/train_data00
!cd /home/aistudio/data/tar/;cat /home/aistudio/data/data9244/train.tar.00 | tar -x
!cd /home/aistudio/data/train_data00;ls /home/aistudio/data/tar/*.tar | xargs -n1 tar xf
#显示work/train中图片数量
!find /home/aistudio/data/train_data00 -type f | wc -l
!rm -rf /home/aistudio/data/tar
!mkdir /home/aistudio/data/val_data
!mkdir /home/aistudio/data/pretrained_pdparams
!tar -xf /home/aistudio/data/data9244/ILSVRC2012_img_val.tar -C /home/aistudio/data/val_data
!unzip -oq data/data107267/CycleMLP_pretrained.zip -d /home/aistudio/data/pretrained_pdparams
- 单机单卡
%cd CycleMLP/
!python train.py --train-data-dir /home/aistudio/data/train_data00 --train-txt-path /home/aistudio/train00.txt \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt \
--epochs 2 --batch-size 256 --lr 1e-8 --distillation-type soft \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B1.pdparams \
--teacher-pretrained /home/aistudio/RegNetX_4GF_pretrained.pdparams
- 自动混合精度训练
%cd CycleMLP/
!python train.py --train-data-dir /home/aistudio/data/train_data00 --train-txt-path /home/aistudio/train00.txt \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt \
--epochs 2 --batch-size 256 --lr 1e-8 --distillation-type soft \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B1.pdparams \
--teacher-pretrained /home/aistudio/RegNetX_4GF_pretrained.pdparams \
--is_amp True
- 单机多卡
%cd CycleMLP/
!python -m paddle.distributed.launch \
train.py --train-data-dir /home/aistudio/data/train_data00 --train-txt-path /home/aistudio/train00.txt \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt \
--epochs 2 --batch-size 256 --lr 1e-8 --distillation-type soft \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B1.pdparams \
--teacher-pretrained /home/aistudio/RegNetX_4GF_pretrained.pdparams \
--is_distributed True
%cd CycleMLP/
!python eval.py --model CycleMLP_B1 \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B1.pdparams \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt
%cd CycleMLP/
!python eval.py --model CycleMLP_B2 \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B2.pdparams \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt
%cd CycleMLP/
!python eval.py --model CycleMLP_B3 --batch-size 10 \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B3.pdparams \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt
%cd CycleMLP/
!python eval.py --model CycleMLP_B4 --batch-size 10 \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B4.pdparams \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt
%cd CycleMLP/
!python eval.py --model CycleMLP_B5 --batch-size 10 \
--model-pretrained /home/aistudio/data/pretrained_pdparams/CycleMLP_pretrained/paddle_CycleMLP_B5.pdparams \
--val-data-dir /home/aistudio/data/val_data --val-txt-path /home/aistudio/val.txt