prepare.sh 6.7 KB
Newer Older
L
LDOUBLEV 已提交
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
#!/bin/bash
FILENAME=$1
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer']
MODE=$2

dataline=$(cat ${FILENAME})

# parser params
IFS=$'\n'
lines=(${dataline})
function func_parser_key(){
    strs=$1
    IFS=":"
    array=(${strs})
    tmp=${array[0]}
    echo ${tmp}
}
function func_parser_value(){
    strs=$1
    IFS=":"
    array=(${strs})
    tmp=${array[1]}
    echo ${tmp}
}
IFS=$'\n'
# The training params
model_name=$(func_parser_value "${lines[0]}")
train_model_list=$(func_parser_value "${lines[0]}")
L
LDOUBLEV 已提交
29

L
LDOUBLEV 已提交
30
trainer_list=$(func_parser_value "${lines[10]}")
L
LDOUBLEV 已提交
31 32 33

# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2
T
tink2123 已提交
34 35 36 37 38 39
# prepare pretrained weights and dataset
if [ ${train_model_list[*]} = "ocr_det" ]; then
  wget -nc -P  ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
  wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar
  cd pretrain_models && tar xf det_mv3_db_v2.0_train.tar && cd ../
  fi
L
LDOUBLEV 已提交
40 41 42 43
if [ ${MODE} = "lite_train_infer" ];then
    # pretrain lite train data
    rm -rf ./train_data/icdar2015
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
T
tink2123 已提交
44 45 46
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar # todo change to bcebos

    cd ./train_data/ && tar xf icdar2015_lite.tar && tar xf ic15_data.tar
L
LDOUBLEV 已提交
47 48 49 50 51 52 53
    ln -s ./icdar2015_lite ./icdar2015
    cd ../
    epoch=10
    eval_batch_step=10
elif [ ${MODE} = "whole_train_infer" ];then
    rm -rf ./train_data/icdar2015
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
T
tink2123 已提交
54 55
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
    cd ./train_data/ && tar xf icdar2015.tar && tar xf ic15_data.tar && cd ../
L
LDOUBLEV 已提交
56 57 58 59 60
    epoch=500
    eval_batch_step=200
elif [ ${MODE} = "whole_infer" ];then
    rm -rf ./train_data/icdar2015
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_infer.tar
T
tink2123 已提交
61 62
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
    cd ./train_data/ && tar xf icdar2015_infer.tar && tar xf ic15_data.tar
L
LDOUBLEV 已提交
63 64 65 66 67 68 69 70
    ln -s ./icdar2015_infer ./icdar2015
    cd ../
    epoch=10
    eval_batch_step=10
else
    rm -rf ./train_data/icdar2015
    wget -nc -P ./train_data https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
    if [ ${model_name} = "ocr_det" ]; then
L
LDOUBLEV 已提交
71 72
        eval_model_name="ch_ppocr_mobile_v2.0_det_infer"
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
L
LDOUBLEV 已提交
73 74 75 76 77 78 79 80 81 82 83 84
        cd ./inference && tar xf ${eval_model_name}.tar && cd ../
    else 
        eval_model_name="ch_ppocr_mobile_v2.0_rec_train"
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
        cd ./inference && tar xf ${eval_model_name}.tar && cd ../
    fi 
fi


IFS='|'
for train_model in ${train_model_list[*]}; do 
    if [ ${train_model} = "ocr_det" ];then
L
LDOUBLEV 已提交
85
        model_name="ocr_det"
L
LDOUBLEV 已提交
86 87 88 89 90 91 92
        yml_file="configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml"
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        cd ./inference && tar xf ch_det_data_50.tar && cd ../
        img_dir="./inference/ch_det_data_50/all-sum-510"
        data_dir=./inference/ch_det_data_50/
        data_label_file=[./inference/ch_det_data_50/test_gt_50.txt]
    elif [ ${train_model} = "ocr_rec" ];then
L
LDOUBLEV 已提交
93
        model_name="ocr_rec"
L
LDOUBLEV 已提交
94
        yml_file="configs/rec/rec_mv3_none_bilstm_ctc.yml"
T
tink2123 已提交
95 96 97 98 99
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
        cd ./inference && tar xf rec_inference.tar  && cd ../
        img_dir="./inference/rec_inference/"
        data_dir=./inference/rec_inference
        data_label_file=[./inference/rec_inference/rec_gt_test.txt]
L
LDOUBLEV 已提交
100 101 102
    fi

    # eval 
L
LDOUBLEV 已提交
103
    for slim_trainer in ${trainer_list[*]}; do 
L
LDOUBLEV 已提交
104
        if [ ${slim_trainer} = "norm" ]; then
L
LDOUBLEV 已提交
105
            if [ ${model_name} = "det" ]; then
L
LDOUBLEV 已提交
106 107 108 109 110 111 112 113 114
                eval_model_name="ch_ppocr_mobile_v2.0_det_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            else 
                eval_model_name="ch_ppocr_mobile_v2.0_rec_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            fi 
        elif [ ${slim_trainer} = "pact" ]; then
L
LDOUBLEV 已提交
115
            if [ ${model_name} = "det" ]; then
L
LDOUBLEV 已提交
116 117 118 119 120 121 122 123 124
                eval_model_name="ch_ppocr_mobile_v2.0_det_quant_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_quant_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            else
                eval_model_name="ch_ppocr_mobile_v2.0_rec_quant_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_quant_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            fi
        elif [ ${slim_trainer} = "distill" ]; then
L
LDOUBLEV 已提交
125
            if [ ${model_name} = "det" ]; then
L
LDOUBLEV 已提交
126 127 128 129 130 131 132 133 134
                eval_model_name="ch_ppocr_mobile_v2.0_det_distill_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_distill_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            else
                eval_model_name="ch_ppocr_mobile_v2.0_rec_distill_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_distill_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            fi 
        elif [ ${slim_trainer} = "fpgm" ]; then
L
LDOUBLEV 已提交
135
            if [ ${model_name} = "det" ]; then
L
LDOUBLEV 已提交
136 137 138 139 140 141 142 143 144 145 146
                eval_model_name="ch_ppocr_mobile_v2.0_det_prune_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            else
                eval_model_name="ch_ppocr_mobile_v2.0_rec_prune_train"
                wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_prune_train.tar
                cd ./inference && tar xf ${eval_model_name}.tar && cd ../
            fi
        fi
    done
done