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

M
MissPenguin 已提交
77 78
if [ ${MODE} = "cpp_infer" ];then
    cd deploy/cpp_infer
M
refine  
MissPenguin 已提交
79 80 81 82 83 84
    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 已提交
85

M
refine  
MissPenguin 已提交
86 87
        cd opencv-3.4.7/
        install_path=$(pwd)/opencv-3.4.7/opencv3
M
MissPenguin 已提交
88

M
refine  
MissPenguin 已提交
89 90 91
        rm -rf build
        mkdir build
        cd build
M
MissPenguin 已提交
92

M
refine  
MissPenguin 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
        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 已提交
110

M
refine  
MissPenguin 已提交
111 112 113 114 115
        make -j
        make install
        cd ../
        echo "################### build opencv finished ###################"
    fi
M
MissPenguin 已提交
116 117


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