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

M
MissPenguin 已提交
82 83
if [ ${MODE} = "cpp_infer" ];then
    cd deploy/cpp_infer
M
refine  
MissPenguin 已提交
84 85 86 87 88 89
    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 已提交
90

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

M
refine  
MissPenguin 已提交
94 95 96
        rm -rf build
        mkdir build
        cd build
M
MissPenguin 已提交
97

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

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


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