prepare.sh 9.9 KB
Newer Older
LDOUBLEV's avatar
LDOUBLEV committed
1
2
#!/bin/bash
FILENAME=$1
3

LDOUBLEV's avatar
LDOUBLEV committed
4
5
6
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer',  'infer', 
#                 'cpp_infer', 'serving_infer', 'klquant_infer']

LDOUBLEV's avatar
LDOUBLEV committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
LDOUBLEV's avatar
LDOUBLEV committed
30
model_name=$(func_parser_value "${lines[1]}")
LDOUBLEV's avatar
LDOUBLEV committed
31

LDOUBLEV's avatar
LDOUBLEV committed
32
trainer_list=$(func_parser_value "${lines[14]}")
Double_V's avatar
Double_V committed
33

Double_V's avatar
Double_V committed
34
35
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2
LDOUBLEV's avatar
LDOUBLEV committed
36

Double_V's avatar
Double_V committed
37
38
39
if [ ${MODE} = "lite_train_infer" ];then
    # pretrain lite train data
    wget -nc -P  ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
LDOUBLEV's avatar
LDOUBLEV committed
40
    wget -nc -P ./pretrain_models/  https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar
LDOUBLEV's avatar
LDOUBLEV committed
41
42
43
44
    if [ ${model_name} == "PPOCRv2_ocr_det" ]; then
        wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_distill_train.tar
        cd ./pretrain_models/ && tar xf ch_PP-OCRv2_det_distill_train.tar && cd ../
    fi
LDOUBLEV's avatar
LDOUBLEV committed
45
    cd ./pretrain_models/ && tar xf det_mv3_db_v2.0_train.tar && cd ../
Double_V's avatar
Double_V committed
46
    rm -rf ./train_data/icdar2015
tink2123's avatar
tink2123 committed
47
    rm -rf ./train_data/ic15_data
Double_V's avatar
Double_V committed
48
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
tink2123's avatar
tink2123 committed
49
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar # todo change to bcebos
tink2123's avatar
tink2123 committed
50
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
LDOUBLEV's avatar
LDOUBLEV committed
51
52
    wget -nc -P ./deploy/slim/prune https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/sen.pickle
    
tink2123's avatar
tink2123 committed
53
    cd ./train_data/ && tar xf icdar2015_lite.tar && tar xf ic15_data.tar
Double_V's avatar
Double_V committed
54
55
    ln -s ./icdar2015_lite ./icdar2015
    cd ../
tink2123's avatar
tink2123 committed
56
    cd ./inference && tar xf rec_inference.tar && cd ../
Double_V's avatar
Double_V committed
57
58
59
elif [ ${MODE} = "whole_train_infer" ];then
    wget -nc -P  ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
    rm -rf ./train_data/icdar2015
tink2123's avatar
tink2123 committed
60
    rm -rf ./train_data/ic15_data
Double_V's avatar
Double_V committed
61
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
tink2123's avatar
tink2123 committed
62
63
    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 ../
LDOUBLEV's avatar
LDOUBLEV committed
64
65
66
67
    if [ ${model_name} == "PPOCRv2_ocr_det" ]; then
        wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_distill_train.tar
        cd ./pretrain_models/ && tar xf ch_PP-OCRv2_det_distill_train.tar && cd ../
    fi
Double_V's avatar
Double_V committed
68
69
70
elif [ ${MODE} = "whole_infer" ];then
    wget -nc -P  ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
    rm -rf ./train_data/icdar2015
tink2123's avatar
tink2123 committed
71
    rm -rf ./train_data/ic15_data
Double_V's avatar
Double_V committed
72
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_infer.tar
tink2123's avatar
tink2123 committed
73
74
    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
Double_V's avatar
Double_V committed
75
76
    ln -s ./icdar2015_infer ./icdar2015
    cd ../
LDOUBLEV's avatar
LDOUBLEV committed
77
78
79
80
    if [ ${model_name} == "PPOCRv2_ocr_det" ]; then
        wget -nc -P ./pretrain_models/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_distill_train.tar
        cd ./pretrain_models/ && tar xf ch_PP-OCRv2_det_distill_train.tar && cd ../
    fi
MissPenguin's avatar
MissPenguin committed
81
elif [ ${MODE} = "infer" ];then
tink2123's avatar
tink2123 committed
82
    if [ ${model_name} = "ocr_det" ]; then
LDOUBLEV's avatar
LDOUBLEV committed
83
        eval_model_name="ch_ppocr_mobile_v2.0_det_train"
tink2123's avatar
tink2123 committed
84
        rm -rf ./train_data/icdar2015
LDOUBLEV's avatar
LDOUBLEV committed
85
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
LDOUBLEV's avatar
LDOUBLEV committed
86
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar
Double_V's avatar
Double_V committed
87
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf ch_det_data_50.tar && cd ../
LDOUBLEV's avatar
LDOUBLEV committed
88
    elif [ ${model_name} = "ocr_server_det" ]; then
LDOUBLEV's avatar
LDOUBLEV committed
89
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar
LDOUBLEV's avatar
LDOUBLEV committed
90
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
LDOUBLEV's avatar
LDOUBLEV committed
91
        cd ./inference && tar xf ch_ppocr_server_v2.0_det_train.tar && tar xf ch_det_data_50.tar && cd ../
tink2123's avatar
tink2123 committed
92
    elif  [ ${model_name} = "ocr_system_mobile" ]; then
LDOUBLEV's avatar
LDOUBLEV committed
93
94
95
96
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
        cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_det_data_50.tar && cd ../
tink2123's avatar
tink2123 committed
97
98
99
100
101
    elif  [ ${model_name} = "ocr_system_server" ]; then
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar
        cd ./inference && tar xf ch_ppocr_server_v2.0_det_infer.tar && tar xf ch_ppocr_server_v2.0_rec_infer.tar && tar xf ch_det_data_50.tar && cd ../
102
    elif [ ${model_name} = "ocr_rec" ]; then
tink2123's avatar
tink2123 committed
103
        rm -rf ./train_data/ic15_data
tink2123's avatar
tink2123 committed
104
        eval_model_name="ch_ppocr_mobile_v2.0_rec_infer"
tink2123's avatar
tink2123 committed
105
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
tink2123's avatar
tink2123 committed
106
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
tink2123's avatar
tink2123 committed
107
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf rec_inference.tar && cd ../
108
109
110
111
112
113
    elif [ ${model_name} = "ocr_server_rec" ]; then
        rm -rf ./train_data/ic15_data
        eval_model_name="ch_ppocr_server_v2.0_rec_infer"
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf rec_inference.tar && cd ../
Double_V's avatar
Double_V committed
114
    fi 
LDOUBLEV's avatar
LDOUBLEV committed
115
116
117
118
119
120
    elif [ ${model_name} = "PPOCRv2_ocr_det" ]; then
        eval_model_name="ch_PP-OCRv2_det_infer"
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf ch_det_data_50.tar && cd ../
    fi 
LDOUBLEV's avatar
LDOUBLEV committed
121
122
123
124
125
126
elif [ ${MODE} = "klquant_infer" ];then
    if [ ${model_name} = "ocr_det" ]; then
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_det_data_50.tar && cd ../
    fi
LDOUBLEV's avatar
LDOUBLEV committed
127
128
129
130
131
132
    if [ ${model_name} = "PPOCRv2_ocr_det" ]; then
        eval_model_name="ch_PP-OCRv2_det_infer"
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf ch_det_data_50.tar && cd ../
    fi 
MissPenguin's avatar
MissPenguin committed
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
elif [ ${MODE} = "cpp_infer" ];then
    if [ ${model_name} = "ocr_det" ]; then
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
        cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_det_data_50.tar && cd ../
    elif [ ${model_name} = "ocr_rec" ]; then
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
        cd ./inference && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf rec_inference.tar && cd ../
    elif  [ ${model_name} = "ocr_system" ]; then
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
        cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_det_data_50.tar && cd ../
    fi 
Double_V's avatar
Double_V committed
148
fi
tink2123's avatar
tink2123 committed
149

tink2123's avatar
tink2123 committed
150
151
152
if [ ${MODE} = "serving_infer" ];then
    # prepare serving env
    python_name=$(func_parser_value "${lines[2]}")
153
154
    wget https://paddle-serving.bj.bcebos.com/chain/paddle_serving_server_gpu-0.0.0.post101-py3-none-any.whl
    ${python_name} -m pip install install paddle_serving_server_gpu-0.0.0.post101-py3-none-any.whl
tink2123's avatar
tink2123 committed
155
    ${python_name} -m pip install paddle_serving_client==0.6.1
156
    ${python_name} -m pip install paddle-serving-app==0.6.3
tink2123's avatar
tink2123 committed
157
158
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
159
160
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar
tink2123's avatar
tink2123 committed
161
    cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar && tar xf ch_ppocr_server_v2.0_rec_infer.tar && tar xf ch_ppocr_server_v2.0_det_infer.tar && cd ../
tink2123's avatar
tink2123 committed
162
fi