Ubuntu18.04 lite.ai.toolkit配置、编译、测试

简介

推荐 GitHub 上一款开箱即用的 C++ AI 模型工具箱:Lite.AI.ToolKit,涵盖目标检测、人脸检测、人脸识别、语义分割、抠图等领域。

 

里面包括了 70+ 流行开源模型,如最新的 RVM、YOLOX、YoloV5、DeepLabV3、ArcFace 等模型,对用户友好,简单易用。

GitHub:github.com/DefTruth/lite.ai.toolkit

环境

WSL2 Ubuntu18.04

配置

配置预编译库:

  1. 下载预编译好的库

2 . 配置

通过命令 vim ~/.bashrc 打开.bashrc,然后添加

export LD_LIBRARY_PATH=YOUR-PATH-TO/lite.ai.toolkit/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=YOUR-PATH-TO/lite.ai.toolkit/lib:$LIBRARY_PATH

执行 source ~/.bashrc

注意事项:

lite.ai.toolkit/lib 里面库之间的软连接失效,需要重新创建软连接,否则编译时会报错;

主要修改一下浅蓝色的库:

编译

查看build.sh

#!/bin/bash

BUILD_DIR=build

if [ ! -d "${BUILD_DIR}" ]; then
  mkdir "${BUILD_DIR}"
  echo "creating build dir: ${BUILD_DIR} ..."
else
  echo "build dir: ${BUILD_DIR} directory exist! ..."
fi

cd "${BUILD_DIR}" && pwd && cmake .. \
  -DCMAKE_BUILD_TYPE=MinSizeRel \
  -DINCLUDE_OPENCV=ON \
  -DENABLE_MNN=ON \
  -DENABLE_NCNN=OFF \
  -DENABLE_TNN=OFF &&
  make -j8

设置了-DENABLE_MNN=ON,因为需要配置MNN库和头文件,将MNN-2.0.0/build/install 下面的库和头文件,放置到上面步骤的lite.ai.toolkit文件夹下面的库、头文件目录下即可;

执行编译:

cd lite.ai.toolkit-main
./build.sh

编译完成后,可执行程序在 lite.ai.toolkit-main/build/lite.ai.toolkit/bin;

头文件:lite.ai.toolkit-main/build/lite.ai.toolkit/include

库:lite.ai.toolkit-main/build/lite.ai.toolkit/lib

测试:

root@DL3H:/home/XX/test_net/lite.ai.toolkit-main/build/lite.ai.toolkit/bin# ./lite_yolov5
LITEORT_DEBUG LogId: ../../../hub/onnx/cv/yolov5s.onnx
=============== Input-Dims ==============
input_node_dims: 1
input_node_dims: 3
input_node_dims: 640
input_node_dims: 640
=============== Output-Dims ==============
Output: 0 Name: pred Dim: 0 :1
Output: 0 Name: pred Dim: 1 :25200
Output: 0 Name: pred Dim: 2 :85
Output: 1 Name: output2 Dim: 0 :1
Output: 1 Name: output2 Dim: 1 :3
Output: 1 Name: output2 Dim: 2 :80
Output: 1 Name: output2 Dim: 3 :80
Output: 1 Name: output2 Dim: 4 :85
Output: 2 Name: output3 Dim: 0 :1
Output: 2 Name: output3 Dim: 1 :3
Output: 2 Name: output3 Dim: 2 :40
Output: 2 Name: output3 Dim: 3 :40
Output: 2 Name: output3 Dim: 4 :85
Output: 3 Name: output4 Dim: 0 :1
Output: 3 Name: output4 Dim: 1 :3
Output: 3 Name: output4 Dim: 2 :20
Output: 3 Name: output4 Dim: 3 :20
Output: 3 Name: output4 Dim: 4 :85
========================================
detected num_anchors: 25200
generate_bboxes num: 48
时间消耗:  237ms
Default Version Detected Boxes Num: 5
LITEORT_DEBUG LogId: ../../../hub/onnx/cv/yolov5s.onnx
=============== Input-Dims ==============
input_node_dims: 1
input_node_dims: 3
input_node_dims: 640
input_node_dims: 640
=============== Output-Dims ==============
Output: 0 Name: pred Dim: 0 :1
Output: 0 Name: pred Dim: 1 :25200
Output: 0 Name: pred Dim: 2 :85
Output: 1 Name: output2 Dim: 0 :1
Output: 1 Name: output2 Dim: 1 :3
Output: 1 Name: output2 Dim: 2 :80
Output: 1 Name: output2 Dim: 3 :80
Output: 1 Name: output2 Dim: 4 :85
Output: 2 Name: output3 Dim: 0 :1
Output: 2 Name: output3 Dim: 1 :3
Output: 2 Name: output3 Dim: 2 :40
Output: 2 Name: output3 Dim: 3 :40
Output: 2 Name: output3 Dim: 4 :85
Output: 3 Name: output4 Dim: 0 :1
Output: 3 Name: output4 Dim: 1 :3
Output: 3 Name: output4 Dim: 2 :20
Output: 3 Name: output4 Dim: 3 :20
Output: 3 Name: output4 Dim: 4 :85
========================================
detected num_anchors: 25200
generate_bboxes num: 39
ONNXRuntime Version Detected Boxes Num: 4
LITEMNN_DEBUG LogId: ../../../hub/mnn/cv/yolov5s.mnn
=============== Input-Dims ==============
        **Tensor shape**: 1, 3, 640, 640, 
Dimension Type: (CAFFE/PyTorch/ONNX)NCHW
=============== Output-Dims ==============
getSessionOutputAll done!
Output: output2:        **Tensor shape**: 1, 3, 80, 80, 85, 
Output: output3:        **Tensor shape**: 1, 3, 40, 40, 85, 
Output: output4:        **Tensor shape**: 1, 3, 20, 20, 85, 
Output: pred:   **Tensor shape**: 1, 25200, 85, 
========================================
detected num_anchors: 25200
generate_bboxes num: 39
时间消耗:  253ms
MNN Version Detected Boxes Num: 4

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JoannaJuanCV

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值