CMakeLists.txt 4.0 KB
Newer Older
L
luotao1 已提交
1 2 3 4 5
set(INFERENCE_URL "http://paddle-inference-dist.bj.bcebos.com")
set(INFERENCE_DEMO_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo")
set(INFERENCE_EXTRA_DEPS paddle_inference_api paddle_fluid_api ir_pass_manager analysis_predictor)
function (inference_download_and_uncompress install_dir filename)
    message(STATUS "Download inference test stuff from ${INFERENCE_URL}/${filename}")
6
    execute_process(COMMAND bash -c "mkdir -p ${install_dir}")
L
luotao1 已提交
7
    execute_process(COMMAND bash -c "cd ${install_dir} && wget -q ${INFERENCE_URL}/${filename}")
8 9
    execute_process(COMMAND bash -c "cd ${install_dir} && tar xzf ${filename}")
    message(STATUS "finish downloading ${filename}")
10 11
endfunction(inference_download_and_uncompress)

L
luotao1 已提交
12
function(download_model_and_data install_dir model_name data_name)
13
    if (NOT EXISTS ${install_dir} AND WITH_INFERENCE)
L
luotao1 已提交
14 15
        inference_download_and_uncompress(${install_dir} ${model_name})
        inference_download_and_uncompress(${install_dir} ${data_name})
16 17 18 19
    endif()
endfunction()

# RNN1
20 21 22 23 24 25 26 27 28 29
# TODO: fix this test on MACOS
message(WARNING "These tests has been disabled in OSX before being fixed: \n test_analyzer_rnn1")
if(NOT APPLE)
    set(RNN1_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/rnn1")
    download_model_and_data(${RNN1_INSTALL_DIR} "rnn1%2Fmodel.tar.gz" "rnn1%2Fdata.txt.tar.gz")
    inference_analysis_test(test_analyzer_rnn1 SRCS analyzer_rnn1_tester.cc 
        EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
        ARGS --infer_model=${RNN1_INSTALL_DIR}/model
            --infer_data=${RNN1_INSTALL_DIR}/data.txt)
endif(NOT APPLE)
30

L
luotao1 已提交
31 32 33 34 35 36 37 38
# RNN2
set(RNN2_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/rnn2")
download_model_and_data(${RNN2_INSTALL_DIR} "rnn2_model.tar.gz" "rnn2_data.txt.tar.gz")
inference_analysis_test(test_analyzer_rnn2 SRCS analyzer_rnn2_tester.cc
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
    ARGS --infer_model=${RNN2_INSTALL_DIR}/model
         --infer_data=${RNN2_INSTALL_DIR}/data.txt)

39
# chinese_ner
L
luotao1 已提交
40 41
set(CHINESE_NER_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/chinese_ner")
download_model_and_data(${CHINESE_NER_INSTALL_DIR} "chinese_ner_model.tar.gz" "chinese_ner-data.txt.tar.gz")
42
inference_analysis_test(test_analyzer_ner SRCS analyzer_ner_tester.cc
L
luotao1 已提交
43
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
44 45 46 47
    ARGS --infer_model=${CHINESE_NER_INSTALL_DIR}/model
        --infer_data=${CHINESE_NER_INSTALL_DIR}/data.txt)

# lac
L
luotao1 已提交
48 49
set(LAC_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/lac")
download_model_and_data(${LAC_INSTALL_DIR} "lac_model.tar.gz" "lac_data.txt.tar.gz")
50
inference_analysis_test(test_analyzer_lac SRCS analyzer_lac_tester.cc
L
luotao1 已提交
51
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
52 53 54 55
    ARGS --infer_model=${LAC_INSTALL_DIR}/model
        --infer_data=${LAC_INSTALL_DIR}/data.txt)

# text_classification
L
luotao1 已提交
56 57
set(TEXT_CLASSIFICATION_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/text_classification")
download_model_and_data(${TEXT_CLASSIFICATION_INSTALL_DIR} "text-classification-Senta.tar.gz" "text_classification_data.txt.tar.gz")
L
luotao1 已提交
58
inference_analysis_test(test_analyzer_text_classification SRCS analyzer_text_classification_tester.cc
L
luotao1 已提交
59
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
60
    ARGS --infer_model=${TEXT_CLASSIFICATION_INSTALL_DIR}/model
L
luotao1 已提交
61
         --infer_data=${TEXT_CLASSIFICATION_INSTALL_DIR}/data.txt)
T
tensor-tang 已提交
62 63 64 65 66

# ocr
set(OCR_MODEL_URL "http://paddlemodels.cdn.bcebos.com/inference-vis-demos%2Focr.tar.gz")
set(OCR_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo/ocr")
if (NOT EXISTS ${OCR_INSTALL_DIR} AND WITH_INFERENCE)
T
tensor-tang 已提交
67 68 69 70 71 72
    get_filename_component(filename ${OCR_MODEL_URL} NAME)
    message(STATUS "Download inference test stuff ${filename} from ${OCR_MODEL_URL}")
    execute_process(COMMAND bash -c "mkdir -p ${OCR_INSTALL_DIR}")
    execute_process(COMMAND bash -c "cd ${OCR_INSTALL_DIR} && wget -q ${OCR_MODEL_URL}")
    execute_process(COMMAND bash -c "cd ${OCR_INSTALL_DIR} && tar xzf ${filename}")
    message(STATUS "finish downloading ${filename}")
T
tensor-tang 已提交
73 74
endif()
inference_analysis_test(test_analyzer_ocr SRCS analyzer_vis_tester.cc
T
tensor-tang 已提交
75
    EXTRA_DEPS ${INFERENCE_EXTRA_DEPS}
T
tensor-tang 已提交
76 77
    ARGS --infer_model=${OCR_INSTALL_DIR}/model
        --infer_data=${OCR_INSTALL_DIR}/data.txt)