prepare.sh 7.6 KB
Newer Older
L
LDOUBLEV 已提交
1 2
#!/bin/bash
FILENAME=$1
3 4

# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer', 'cpp_infer', 'serving_infer']
L
LDOUBLEV 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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
L
LDOUBLEV 已提交
28
model_name=$(func_parser_value "${lines[1]}")
L
LDOUBLEV 已提交
29

L
LDOUBLEV 已提交
30
trainer_list=$(func_parser_value "${lines[14]}")
D
Double_V 已提交
31

D
Double_V 已提交
32 33
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2
L
LDOUBLEV 已提交
34

D
Double_V 已提交
35 36 37
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
L
LDOUBLEV 已提交
38 39
    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 ../
D
Double_V 已提交
40
    rm -rf ./train_data/icdar2015
T
tink2123 已提交
41
    rm -rf ./train_data/ic15_data
D
Double_V 已提交
42
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
T
tink2123 已提交
43
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar # todo change to bcebos
T
tink2123 已提交
44
    wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
L
LDOUBLEV 已提交
45 46
    wget -nc -P ./deploy/slim/prune https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/sen.pickle
    
T
tink2123 已提交
47
    cd ./train_data/ && tar xf icdar2015_lite.tar && tar xf ic15_data.tar
D
Double_V 已提交
48 49
    ln -s ./icdar2015_lite ./icdar2015
    cd ../
T
tink2123 已提交
50
    cd ./inference && tar xf rec_inference.tar && cd ../
D
Double_V 已提交
51 52 53
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
T
tink2123 已提交
54
    rm -rf ./train_data/ic15_data
D
Double_V 已提交
55
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
T
tink2123 已提交
56 57
    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 ../
D
Double_V 已提交
58 59 60
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
T
tink2123 已提交
61
    rm -rf ./train_data/ic15_data
D
Double_V 已提交
62
    wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_infer.tar
T
tink2123 已提交
63 64
    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
D
Double_V 已提交
65 66
    ln -s ./icdar2015_infer ./icdar2015
    cd ../
M
MissPenguin 已提交
67
elif [ ${MODE} = "infer" ] || [ ${MODE} = "cpp_infer" ];then
T
tink2123 已提交
68
    if [ ${model_name} = "ocr_det" ]; then
L
LDOUBLEV 已提交
69
        eval_model_name="ch_ppocr_mobile_v2.0_det_train"
T
tink2123 已提交
70
        rm -rf ./train_data/icdar2015
L
LDOUBLEV 已提交
71
        wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
L
LDOUBLEV 已提交
72
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar
D
Double_V 已提交
73
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf ch_det_data_50.tar && cd ../
L
LDOUBLEV 已提交
74 75 76 77
    elif [ ${model_name} = "ocr_server_det" ]; 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
        cd ./inference && tar xf ch_ppocr_server_v2.0_det_infer.tar && tar xf ch_det_data_50.tar && cd ../
L
LDOUBLEV 已提交
78 79 80 81 82
    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 ../
D
Double_V 已提交
83
    else 
T
tink2123 已提交
84
        rm -rf ./train_data/ic15_data
T
tink2123 已提交
85
        eval_model_name="ch_ppocr_mobile_v2.0_rec_infer"
T
tink2123 已提交
86
        wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
T
tink2123 已提交
87
        wget -nc  -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
T
tink2123 已提交
88
        cd ./inference && tar xf ${eval_model_name}.tar && tar xf rec_inference.tar && cd ../
D
Double_V 已提交
89 90
    fi 
fi
T
tink2123 已提交
91

T
tink2123 已提交
92 93 94 95 96 97 98 99 100 101
if [ ${MODE} = "serving_infer" ];then
    # prepare serving env
    python_name=$(func_parser_value "${lines[2]}")
    ${python_name} -m pip install install paddle-serving-server-gpu==0.6.1.post101
    ${python_name} -m pip install paddle_serving_client==0.6.1
    ${python_name} -m pip install paddle-serving-app==0.6.1
    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
    cd ./inference && tar xf ch_ppocr_mobile_v2.0_det_infer.tar && tar xf ch_ppocr_mobile_v2.0_rec_infer.tar
fi
T
tink2123 已提交
102

M
MissPenguin 已提交
103 104
if [ ${MODE} = "cpp_infer" ];then
    cd deploy/cpp_infer
M
refine  
MissPenguin 已提交
105 106
    use_opencv=$(func_parser_value "${lines[52]}")
    if [ ${use_opencv} = "True" ]; then
M
MissPenguin 已提交
107 108 109 110 111 112 113
        if [ -d "opencv-3.4.7/opencv3/" ] && [ $(md5sum opencv-3.4.7.tar.gz | awk -F ' ' '{print $1}') = "faa2b5950f8bee3f03118e600c74746a" ];then
            echo "################### build opencv skipped ###################"
        else
            echo "################### build opencv ###################"
            rm -rf opencv-3.4.7.tar.gz opencv-3.4.7/
            wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/opencv-3.4.7.tar.gz
            tar -xf opencv-3.4.7.tar.gz
M
MissPenguin 已提交
114

M
MissPenguin 已提交
115 116
            cd opencv-3.4.7/
            install_path=$(pwd)/opencv3
M
MissPenguin 已提交
117

M
MissPenguin 已提交
118 119 120
            rm -rf build
            mkdir build
            cd build
M
MissPenguin 已提交
121

M
MissPenguin 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
            cmake .. \
                -DCMAKE_INSTALL_PREFIX=${install_path} \
                -DCMAKE_BUILD_TYPE=Release \
                -DBUILD_SHARED_LIBS=OFF \
                -DWITH_IPP=OFF \
                -DBUILD_IPP_IW=OFF \
                -DWITH_LAPACK=OFF \
                -DWITH_EIGEN=OFF \
                -DCMAKE_INSTALL_LIBDIR=lib64 \
                -DWITH_ZLIB=ON \
                -DBUILD_ZLIB=ON \
                -DWITH_JPEG=ON \
                -DBUILD_JPEG=ON \
                -DWITH_PNG=ON \
                -DBUILD_PNG=ON \
                -DWITH_TIFF=ON \
                -DBUILD_TIFF=ON
M
MissPenguin 已提交
139

M
MissPenguin 已提交
140 141 142 143 144
            make -j
            make install
            cd ../
            echo "################### build opencv finished ###################"
        fi
M
refine  
MissPenguin 已提交
145
    fi
M
MissPenguin 已提交
146 147


M
refine  
MissPenguin 已提交
148
    echo "################### build PaddleOCR demo ####################"
M
refine  
MissPenguin 已提交
149 150 151 152 153
    if [ ${use_opencv} = "True" ]; then
        OPENCV_DIR=$(pwd)/opencv-3.4.7/opencv3/
    else
        OPENCV_DIR=''
    fi
M
MissPenguin 已提交
154
    LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/
M
refine  
MissPenguin 已提交
155 156 157
    CUDA_LIB_DIR=$(dirname `find /usr -name libcudart.so`)
    CUDNN_LIB_DIR=$(dirname `find /usr -name libcudnn.so`)
    
M
MissPenguin 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
    BUILD_DIR=build
    rm -rf ${BUILD_DIR}
    mkdir ${BUILD_DIR}
    cd ${BUILD_DIR}
    cmake .. \
        -DPADDLE_LIB=${LIB_DIR} \
        -DWITH_MKL=ON \
        -DWITH_GPU=OFF \
        -DWITH_STATIC_LIB=OFF \
        -DWITH_TENSORRT=OFF \
        -DOPENCV_DIR=${OPENCV_DIR} \
        -DCUDNN_LIB=${CUDNN_LIB_DIR} \
        -DCUDA_LIB=${CUDA_LIB_DIR} \
        -DTENSORRT_DIR=${TENSORRT_DIR} \

    make -j
M
refine  
MissPenguin 已提交
174
    echo "################### build PaddleOCR demo finished ###################"
L
LDOUBLEV 已提交
175
fi