提交 70ccf385 编写于 作者: B Bai Yifan 提交者: whs

fix scripts and docs (#3465)

上级 a324d22d
......@@ -5,6 +5,8 @@
## 概述
该示例使用PaddleSlim提供的[蒸馏策略]([https://github.com/PaddlePaddle/models/blob/develop/PaddleSlim/docs/tutorial.md#3-%E8%92%B8%E9%A6%8F](https://github.com/PaddlePaddle/models/blob/develop/PaddleSlim/docs/tutorial.md#3-蒸馏))对分类模型进行知识蒸馏。
>本文默认使用ILSVRC2012数据集,数据集存放在`models/PaddleSlim/data/`路径下, 可以参考[数据准备](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification#数据准备)在执行训练脚本run.sh前配置好您的数据集
在阅读该示例前,建议您先了解以下内容:
- [分类模型的常规训练方法](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification)
......
......@@ -2,9 +2,6 @@
# download pretrain model
root_url="http://paddle-imagenet-models-name.bj.bcebos.com"
MobileNetV1="MobileNetV1_pretrained.tar"
MobileNetV2="MobileNetV2_pretrained.tar"
ResNet34="ResNet34_pretrained.tar"
ResNet50="ResNet50_pretrained.tar"
pretrain_dir='../pretrain'
......@@ -14,15 +11,6 @@ fi
cd ${pretrain_dir}
if [ ! -f ${MobileNetV2} ]; then
wget ${root_url}/${MobileNetV2}
tar xf ${MobileNetV2}
fi
if [ ! -f ${ResNet34} ]; then
wget ${root_url}/${ResNet34}
tar xf ${ResNet34}
fi
if [ ! -f ${ResNet50} ]; then
wget ${root_url}/${ResNet50}
tar xf ${ResNet50}
......@@ -62,7 +50,7 @@ for files in $(ls res50_*)
done
cd -
# for mobilenet_v2 distillation
## for mobilenet_v2 distillation
#cd ${pretrain_dir}/ResNet50_pretrained
#for files in $(ls res50_*)
# do mv $files ${files#*_}
......@@ -86,7 +74,7 @@ cd -
#done
#cd -
# for resnet34 distillation
## for resnet34 distillation
#cd ${pretrain_dir}/ResNet50_pretrained
#for files in $(ls res50_*)
# do mv $files ${files#*_}
......@@ -96,16 +84,7 @@ cd -
#done
#cd -
#
#cd ${pretrain_dir}/ResNet34_pretrained
#for files in $(ls res34_*)
# do mv $files ${files#*_}
#done
#for files in $(ls *)
# do mv $files "res34_"$files
#done
#cd -
#
#python compress.py \
#python -u compress.py \
#--model "ResNet34" \
#--teacher_model "ResNet50" \
#--teacher_pretrained_model ../pretrain/ResNet50_pretrained \
......@@ -118,10 +97,3 @@ cd -
# do mv $files ${files#*_}
#done
#cd -
#
#cd ${pretrain_dir}/ResNet34_pretrained
#for files in $(ls res34_*)
# do mv $files ${files#*_}
#done
#cd -
......@@ -5,6 +5,8 @@
## 概述
该示例使用PaddleSlim提供的[卷积通道剪裁压缩策略](https://github.com/PaddlePaddle/models/blob/develop/PaddleSlim/docs/tutorial.md#2-%E5%8D%B7%E7%A7%AF%E6%A0%B8%E5%89%AA%E8%A3%81%E5%8E%9F%E7%90%86)对分类模型进行压缩。
>本文默认使用ILSVRC2012数据集,数据集存放在`models/PaddleSlim/data/`路径下, 可以参考[数据准备](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification#数据准备)在执行训练脚本run.sh前配置好您的数据集
在阅读该示例前,建议您先了解以下内容:
- [分类模型的常规训练方法](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification)
......
#!/usr/bin/env bash
export CUDA_VISIBLE_DEVICES=0
nohup python compress.py \
# download pretrain model
root_url="http://paddle-imagenet-models-name.bj.bcebos.com"
MobileNetV1="MobileNetV1_pretrained.tar"
MobileNetV2="MobileNetV2_pretrained.tar"
ResNet50="ResNet50_pretrained.tar"
pretrain_dir='../pretrain'
if [ ! -d ${pretrain_dir} ]; then
mkdir ${pretrain_dir}
fi
cd ${pretrain_dir}
if [ ! -f ${MobileNetV1} ]; then
wget ${root_url}/${MobileNetV1}
tar xf ${MobileNetV1}
fi
if [ ! -f ${MobileNetV2} ]; then
wget ${root_url}/${MobileNetV2}
tar xf ${MobileNetV2}
fi
if [ ! -f ${ResNet50} ]; then
wget ${root_url}/${ResNet50}
tar xf ${ResNet50}
fi
cd -
nohup python -u compress.py \
--model "MobileNet" \
--use_gpu 0 \
--batch_size 1 \
--use_gpu 1 \
--batch_size 256 \
--pretrained_model ../pretrain/MobileNetV1_pretrained \
--config_file "./configs/mobilenet_v1.yaml" \
> mobilenet_v1.log 2>&1 &
tailf mobilenet_v1.log
# for compression of mobilenet_v2
#nohup python compress.py \
#nohup python -u compress.py \
#--model "MobileNetV2" \
#--use_gpu 0 \
#--batch_size 1 \
#--use_gpu 1 \
#--batch_size 256 \
#--pretrained_model ../pretrain/MobileNetV2_pretrained \
#--config_file "./configs/mobilenet_v2.yaml" \
#> mobilenet_v2.log 2>&1 &
#tailf mobilenet_v2.log
# for compression of resnet50
#python compress.py \
## for compression of resnet50
#python -u compress.py \
#--model "ResNet50" \
#--use_gpu 0 \
#--batch_size 1 \
#--use_gpu 1 \
#--batch_size 256 \
#--pretrained_model ../pretrain/ResNet50_pretrained \
#--config_file "./configs/resnet50.yaml" \
#> resnet50.log 2>&1 &
#tailf resnet50.log
......@@ -5,6 +5,8 @@
## 概述
该示例使用PaddleSlim提供的[量化压缩策略](https://github.com/PaddlePaddle/models/blob/develop/PaddleSlim/docs/tutorial.md#1-quantization-aware-training%E9%87%8F%E5%8C%96%E4%BB%8B%E7%BB%8D)对分类模型进行压缩。
>本文默认使用ILSVRC2012数据集,数据集存放在`models/PaddleSlim/data/`路径下, 可以参考[数据准备](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification#数据准备)在执行训练脚本run.sh前配置好您的数据集
在阅读该示例前,建议您先了解以下内容:
- [分类模型的常规训练方法](https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/image_classification)
......
#!/usr/bin/env bash
#export CUDA_VISIBLE_DEVICES=0
# download pretrain model
root_url="http://paddle-imagenet-models-name.bj.bcebos.com"
MobileNetV1="MobileNetV1_pretrained.tar"
MobileNetV2="MobileNetV2_pretrained.tar"
ResNet50="ResNet50_pretrained.tar"
pretrain_dir='../pretrain'
# for quantization for mobilenet_v1
#python compress.py \
# --model "MobileNet" \
# --use_gpu 1 \
# --batch_size 32 \
# --pretrained_model ../pretrain/MobileNetV1_pretrained \
# --config_file "./configs/mobilenet_v1.yaml" \
#> mobilenet_v1.log 2>&1 &
#tailf mobilenet_v1.log
if [ ! -d ${pretrain_dir} ]; then
mkdir ${pretrain_dir}
fi
cd ${pretrain_dir}
if [ ! -f ${MobileNetV1} ]; then
wget ${root_url}/${MobileNetV1}
tar xf ${MobileNetV1}
fi
if [ ! -f ${MobileNetV2} ]; then
wget ${root_url}/${MobileNetV2}
tar xf ${MobileNetV2}
fi
if [ ! -f ${ResNet50} ]; then
wget ${root_url}/${ResNet50}
tar xf ${ResNet50}
fi
cd -
# enable GC strategy
export FLAGS_fast_eager_deletion_mode=1
export FLAGS_eager_delete_tensor_gb=0.0
export CUDA_VISIBLE_DEVICES=0
# for quantization of mobilenet_v2
# python compress.py \
## for quantization for mobilenet_v1
python -u compress.py \
--model "MobileNet" \
--use_gpu 1 \
--batch_size 32 \
--pretrained_model ../pretrain/MobileNetV1_pretrained \
--config_file "./configs/mobilenet_v1.yaml" \
> mobilenet_v1.log 2>&1 &
tailf mobilenet_v1.log
## for quantization of mobilenet_v2
#python -u compress.py \
# --model "MobileNetV2" \
# --use_gpu 1 \
# --batch_size 32 \
......@@ -22,14 +56,12 @@
# > mobilenet_v2.log 2>&1 &
#tailf mobilenet_v2.log
# for compression of resnet50
python compress.py \
--model "ResNet50" \
--use_gpu 1 \
--batch_size 32 \
--pretrained_model ../pretrain/ResNet50_pretrained \
--config_file "./configs/resnet50.yaml" \
> resnet50.log 2>&1 &
tailf resnet50.log
#python -u compress.py \
# --model "ResNet50" \
# --use_gpu 1 \
# --batch_size 32 \
# --pretrained_model ../pretrain/ResNet50_pretrained \
# --config_file "./configs/resnet50.yaml" \
# > resnet50.log 2>&1 &
#tailf resnet50.log
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册