prepare.sh 5.8 KB
Newer Older
L
LDOUBLEV 已提交
1 2
#!/bin/bash
FILENAME=$1
M
MissPenguin 已提交
3
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer', 'cpp_infer']
L
LDOUBLEV 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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 已提交
27
model_name=$(func_parser_value "${lines[1]}")
L
LDOUBLEV 已提交
28

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

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

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

M
MissPenguin 已提交
84 85
if [ ${MODE} = "cpp_infer" ];then
    cd deploy/cpp_infer
M
refine  
MissPenguin 已提交
86 87 88 89 90 91
    use_opencv=$(func_parser_value "${lines[52]}")
    if [ ${use_opencv} = "True" ]; then
        echo "################### build opencv ###################"
        rm -rf 3.4.7.tar.gz opencv-3.4.7/
        wget https://github.com/opencv/opencv/archive/3.4.7.tar.gz
        tar -xf 3.4.7.tar.gz
M
MissPenguin 已提交
92

M
refine  
MissPenguin 已提交
93 94
        cd opencv-3.4.7/
        install_path=$(pwd)/opencv-3.4.7/opencv3
M
MissPenguin 已提交
95

M
refine  
MissPenguin 已提交
96 97 98
        rm -rf build
        mkdir build
        cd build
M
MissPenguin 已提交
99

M
refine  
MissPenguin 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
        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 已提交
117

M
refine  
MissPenguin 已提交
118 119 120 121 122
        make -j
        make install
        cd ../
        echo "################### build opencv finished ###################"
    fi
M
MissPenguin 已提交
123 124


M
refine  
MissPenguin 已提交
125
    echo "################### build PaddleOCR demo ####################"
M
refine  
MissPenguin 已提交
126 127 128 129 130
    if [ ${use_opencv} = "True" ]; then
        OPENCV_DIR=$(pwd)/opencv-3.4.7/opencv3/
    else
        OPENCV_DIR=''
    fi
M
MissPenguin 已提交
131
    LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/
M
refine  
MissPenguin 已提交
132 133 134
    CUDA_LIB_DIR=$(dirname `find /usr -name libcudart.so`)
    CUDNN_LIB_DIR=$(dirname `find /usr -name libcudnn.so`)
    
M
MissPenguin 已提交
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    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 已提交
151
    echo "################### build PaddleOCR demo finished ###################"
M
MissPenguin 已提交
152
fi