CMakeLists.txt 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

16 17 18 19 20
option(WITH_INFERENCE_DEMO "Compile with Inference demo" OFF)
if(NOT WITH_INFERENCE_DEMO)
  return()
endif()

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
set(DEMO_INSTALL_DIR "${PADDLE_BINARY_DIR}/inference_demo")
set(URL_ROOT http://paddlemodels.bj.bcebos.com/inference-vis-demos%2F)

function(inference_download_test_demo TARGET)
    if (NOT WITH_TESTING)
        return()
    endif()
    set(options "")
    set(oneValueArgs URL)
    set(multiValueArgs SRCS)
    cmake_parse_arguments(tests "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    set(test_dir "${DEMO_INSTALL_DIR}/${TARGET}")
    message(STATUS "inference demo ${test_dir}")

    if(NOT EXISTS "${test_dir}")
        message(STATUS "Download ${TARGET} model from ${tests_URL}")
        execute_process(COMMAND bash -c "mkdir -p ${test_dir}")
        execute_process(COMMAND bash -c "cd ${test_dir}; wget -q ${tests_URL}")
        execute_process(COMMAND bash -c "cd ${test_dir}; tar xzf *.tar.gz")
    endif()

    cc_test(${TARGET} SRCS "${tests_SRCS}"
        DEPS paddle_inference_api paddle_fluid
        ARGS --data=${test_dir}/data.txt
             --modeldir=${test_dir}/model
             --refer=${test_dir}/result.txt)
endfunction()

# disable mobilenet test
#inference_download_test_demo(mobilenet_inference_demo
#    SRCS vis_demo.cc
#    URL ${URL_ROOT}mobilenet.tar.gz)
inference_download_test_demo(se_resnext50_inference_demo
    SRCS vis_demo.cc
    URL ${URL_ROOT}se_resnext50.tar.gz)
inference_download_test_demo(ocr_inference_demo
    SRCS vis_demo.cc
    URL ${URL_ROOT}ocr.tar.gz)