run.sh 2.9 KB
Newer Older
W
whs 已提交
1 2 3 4
#!/usr/bin/env bash

# download pretrain model
root_url="http://paddle-imagenet-models-name.bj.bcebos.com"
K
Kaipeng Deng 已提交
5 6
MobileNetV1="MobileNetV1_pretrained.tar"
ResNet50="ResNet50_pretrained.tar"
W
whs 已提交
7 8 9 10 11 12 13 14 15 16
pretrain_dir='./pretrain'

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

cd ${pretrain_dir}

if [ ! -f ${MobileNetV1} ]; then
    wget ${root_url}/${MobileNetV1}
K
Kaipeng Deng 已提交
17
    tar xf ${MobileNetV1}
W
whs 已提交
18 19 20 21
fi

if [ ! -f ${ResNet50} ]; then
    wget ${root_url}/${ResNet50}
K
Kaipeng Deng 已提交
22
    tar xf ${ResNet50}
W
whs 已提交
23 24 25
fi

cd -
26 27

# for distillation
28
#-----------------
29 30 31 32
export CUDA_VISIBLE_DEVICES=0,1,2,3


# Fixing name conflicts in distillation
W
whs 已提交
33 34 35 36 37
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 -
38 39 40
python compress.py \
--model "MobileNet" \
--teacher_model "ResNet50" \
W
whs 已提交
41
--teacher_pretrained_model ./pretrain/ResNet50_pretrained \
42 43
--compress_config ./configs/mobilenetv1_resnet50_distillation.yaml

W
whs 已提交
44 45 46 47 48
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 -
49 50

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

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

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

74
# for quantization
75
#-----------------
76 77 78 79
#export CUDA_VISIBLE_DEVICES=0
#python compress.py \
#--batch_size 64 \
#--model "MobileNet" \
W
whs 已提交
80
#--pretrained_model ./pretrain/MobileNetV1_pretrained \
81 82
#--compress_config ./configs/quantization.yaml \
#--quant_only True
83

84 85
# for distillation with quantization
#-----------------------------------
W
whs 已提交
86
#export CUDA_VISIBLE_DEVICES=4,5,6,7
87 88
#
## Fixing name conflicts in distillation
W
whs 已提交
89 90 91 92 93
#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 -
94
#
95 96 97
#python compress.py \
#--model "MobileNet" \
#--teacher_model "ResNet50" \
W
whs 已提交
98
#--teacher_pretrained_model ./pretrain/ResNet50_pretrained \
99
#--compress_config ./configs/quantization_dist.yaml
100
#
W
whs 已提交
101 102 103 104 105
#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 -
106 107 108 109 110 111

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