run.sh 1.9 KB
Newer Older
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/usr/bin/env bash

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

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

cd ${pretrain_dir}

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

# for distillation
#-----------------
export CUDA_VISIBLE_DEVICES=0,1,2,3

# for mobilenet_v1 distillation
cd ${pretrain_dir}/ResNet50_pretrained
for files in $(ls res50_*)
    do mv $files ${files#*_}
done
for files in $(ls *)
    do mv $files "res50_"$files
done
cd -

python -u compress.py \
--model "MobileNet" \
--teacher_model "ResNet50" \
--teacher_pretrained_model ../pretrain/ResNet50_pretrained \
--compress_config ./configs/mobilenetv1_resnet50_distillation.yaml \
> mobilenet_v1.log 2>&1 &
tailf mobilenet_v1.log

B
Bai Yifan 已提交
47
## for mobilenet_v2 distillation
48 49 50 51 52 53 54 55 56 57 58 59 60
#cd ${pretrain_dir}/ResNet50_pretrained
#for files in $(ls res50_*)
#    do mv $files ${files#*_}
#done
#for files in $(ls *)
#    do mv $files "res50_"$files
#done
#cd -
#
#python -u compress.py \
#--model "MobileNetV2" \
#--teacher_model "ResNet50" \
#--teacher_pretrained_model ../pretrain/ResNet50_pretrained \
B
Bai Yifan 已提交
61
#--compress_config ./configs/mobilenetv2_resnet50_distillation.yaml \
62 63 64
#> mobilenet_v2.log 2>&1 &
#tailf mobilenet_v2.log

B
Bai Yifan 已提交
65
## for resnet34 distillation
66 67 68 69 70 71 72 73 74
#cd ${pretrain_dir}/ResNet50_pretrained
#for files in $(ls res50_*)
#    do mv $files ${files#*_}
#done
#for files in $(ls *)
#    do mv $files "res50_"$files
#done
#cd -
#
B
Bai Yifan 已提交
75
#python -u compress.py \
76 77 78 79 80 81
#--model "ResNet34" \
#--teacher_model "ResNet50" \
#--teacher_pretrained_model ../pretrain/ResNet50_pretrained \
#--compress_config ./configs/resnet34_resnet50_distillation.yaml \
#> resnet34.log 2>&1 &
#tailf resnet34.log