run.sh 2.7 KB
Newer Older
W
whs 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/bin/env bash

# download pretrain model
root_url="http://paddle-imagenet-models-name.bj.bcebos.com"
MobileNetV1="MobileNetV1_pretrained.zip"
ResNet50="ResNet50_pretrained.zip"
pretrain_dir='./pretrain'

if [ ! -d ${pretrain_dir} ]; then
  mkdir ${pretrain_dir}
fi

cd ${pretrain_dir}

if [ ! -f ${MobileNetV1} ]; then
    wget ${root_url}/${MobileNetV1}
    unzip ${MobileNetV1}
fi

if [ ! -f ${ResNet50} ]; then
    wget ${root_url}/${ResNet50}
    unzip ${ResNet50}
fi

cd -
26

W
whs 已提交
27 28 29 30
# enable GC strategy
export FLAGS_fast_eager_deletion_mode=1
export FLAGS_eager_delete_tensor_gb=0.0

31
# for distillation
32
#-----------------
33 34 35 36
export CUDA_VISIBLE_DEVICES=0,1,2,3


# Fixing name conflicts in distillation
W
whs 已提交
37 38 39 40 41
cd ${pretrain_dir}/ResNet50_pretrained
mv conv1_weights res_conv1_weights
mv fc_0.w_0 res_fc.w_0
mv fc_0.b_0 res_fc.b_0
cd -
42 43 44
python compress.py \
--model "MobileNet" \
--teacher_model "ResNet50" \
W
whs 已提交
45
--teacher_pretrained_model ./pretrain/ResNet50_pretrained \
46 47
--compress_config ./configs/mobilenetv1_resnet50_distillation.yaml

W
whs 已提交
48 49 50 51 52
cd ${pretrain_dir}/ResNet50_pretrained
mv res_conv1_weights conv1_weights
mv res_fc.w_0 fc_0.w_0
mv res_fc.b_0 fc_0.b_0
cd -
53 54

# for sensitivity filter pruning
55
#-------------------------------
56 57 58
#export CUDA_VISIBLE_DEVICES=0
#python compress.py \
#--model "MobileNet" \
W
whs 已提交
59
#--pretrained_model ./pretrain/MobileNetV1_pretrained \
60 61 62 63 64 65 66
#--compress_config ./configs/filter_pruning_sen.yaml

# for uniform filter pruning
#---------------------------
#export CUDA_VISIBLE_DEVICES=0
#python compress.py \
#--model "MobileNet" \
W
whs 已提交
67
#--pretrained_model ./pretrain/MobileNetV1_pretrained \
68 69 70
#--compress_config ./configs/filter_pruning_uniform.yaml

# for quantization
71
#-----------------
72 73 74 75
#export CUDA_VISIBLE_DEVICES=0
#python compress.py \
#--batch_size 64 \
#--model "MobileNet" \
W
whs 已提交
76
#--pretrained_model ./pretrain/MobileNetV1_pretrained \
77 78
#--compress_config ./configs/quantization.yaml

79 80
# for distillation with quantization
#-----------------------------------
W
whs 已提交
81
#export CUDA_VISIBLE_DEVICES=4,5,6,7
82 83
#
## Fixing name conflicts in distillation
W
whs 已提交
84 85 86 87 88
#cd ${pretrain_dir}/ResNet50_pretrained
#mv conv1_weights res_conv1_weights
#mv fc_0.w_0 res_fc.w_0
#mv fc_0.b_0 res_fc.b_0
#cd -
89
#
90 91 92
#python compress.py \
#--model "MobileNet" \
#--teacher_model "ResNet50" \
W
whs 已提交
93
#--teacher_pretrained_model ./pretrain/ResNet50_pretrained \
94
#--compress_config ./configs/quantization_dist.yaml
95
#
W
whs 已提交
96 97 98 99 100
#cd ${pretrain_dir}/ResNet50_pretrained
#mv res_conv1_weights conv1_weights
#mv res_fc.w_0 fc_0.w_0
#mv res_fc.b_0 fc_0.b_0
#cd -
101 102 103 104 105 106

# for uniform filter pruning with quantization
#---------------------------------------------
#export CUDA_VISIBLE_DEVICES=0
#python compress.py \
#--model "MobileNet" \
W
whs 已提交
107
#--pretrained_model ./pretrain/MobileNetV1_pretrained \
108 109
#--compress_config ./configs/quantization_pruning.yaml