DefTruth / lite.ai.toolkit

🛠 A lite C++ toolkit of awesome AI models, support ONNXRuntime, MNN. Contains YOLOv5, YOLOv6, YOLOX, YOLOv8, FaceDet, HeadSeg, HeadPose, Matting etc. Engine: ONNXRuntime, MNN.
https://github.com/DefTruth/lite.ai.toolkit
GNU General Public License v3.0
3.53k stars 672 forks source link

[BUG]libopencv_imgproc.so.409: cannot open shared object file: No such file or directory #402

Closed Flamse closed 1 week ago

Flamse commented 4 months ago

依照项目部署命令

git clone --depth=1 https://github.com/DefTruth/lite.ai.toolkit.git  # latest
cd lite.ai.toolkit && sh ./build.sh # >= 0.2.0, support Linux only.

和output check代码

cmake_minimum_required(VERSION 3.10)
project(lite_yolov5)
set(CMAKE_CXX_STANDARD 17)

set(lite.ai.toolkit_DIR YOUR-PATH-TO/lite.ai.toolkit/build/install)
find_package(lite.ai.toolkit REQUIRED PATHS ${lite.ai.toolkit_DIR})
if (lite.ai.toolkit_Found)
    message(STATUS "lite.ai.toolkit_INCLUDE_DIRS: ${lite.ai.toolkit_INCLUDE_DIRS}")
    message(STATUS "lite.ai.toolkit_LIBS: ${lite.ai.toolkit_LIBS}")
endif()
add_executable(lite_yolov5 test_lite_yolov5.cpp)
target_link_libraries(lite_yolov5 ${lite.ai.toolkit_LIBS})
mkdir build && cd build && cmake .. && make -j1
./lite_yolov5

OpenCVonnxruntime所有相关的.so文件复制到.exe相同路径下,但是报错:

./lite_yolov5: error while loading shared libraries: libopencv_imgproc.so.409: cannot open shared object file: No such file or directory

会是我的c++编译器和cmake版本问题导致的吗?这两个软件都是通过apt直接安装的。

DefTruth commented 4 months ago

需要在可执行文件目录下,export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

DefTruth commented 4 months ago

重新编译一下库,编译案例的时候输出ite.ai.toolkit_LIBS_DIRS:

cmake_minimum_required(VERSION 3.10)
project(lite_yolov5)
set(CMAKE_CXX_STANDARD 17)

set(lite.ai.toolkit_DIR YOUR-PATH-TO/lite.ai.toolkit/build/install)
find_package(lite.ai.toolkit REQUIRED PATHS ${lite.ai.toolkit_DIR})
if (lite.ai.toolkit_Found)
    message(STATUS "lite.ai.toolkit_INCLUDE_DIRS: ${lite.ai.toolkit_INCLUDE_DIRS}")
    message(STATUS "        lite.ai.toolkit_LIBS: ${lite.ai.toolkit_LIBS}")
    message(STATUS "   lite.ai.toolkit_LIBS_DIRS: ${lite.ai.toolkit_LIBS_DIRS}")
endif()
add_executable(lite_yolov5 test_lite_yolov5.cpp)
target_link_libraries(lite_yolov5 ${lite.ai.toolkit_LIBS})

然后把相关的路径export一下即可

Flamse commented 4 months ago

感谢,模型已经成功加载并计算完成。提几个点:

  1. 模型和图片地址根据需要修改
    std::string onnx_path = "../../../../examples/hub/onnx/cv/yolov5s.onnx";
    // ...
  2. 项目对模型输入做了规范,下载项目给出的模型可以完成测试,其他资源处下载的模型可以使用Python对onnx模型文件的输入格式进行修改
    terminate called after throwing an instance of 'Ort::Exception'
    what():  Unexpected input data type. Actual: (tensor(float)) , expected: (tensor(float16))
  3. 该项目支持GPU计算吗?
DefTruth commented 4 months ago

GPU后续版本会继续支持。也可以通过修改依赖库和lite.ai.toolkit的源码加支持,很好改。