Lite AI Toolkit 使用教程

Lite AI Toolkit 使用教程

lite.ai.toolkit🛠 A lite C++ toolkit of awesome AI models with ONNXRuntime, NCNN, MNN and TNN. YOLOv5, YOLOX, YOLOP, YOLOv6, YOLOR, MODNet, YOLOX, YOLOv7, YOLOv8. MNN, NCNN, TNN, ONNXRuntime.项目地址:https://gitcode.com/gh_mirrors/li/lite.ai.toolkit

项目介绍

Lite AI Toolkit 是一个轻量级的 C++ 工具包,支持多种 AI 模型,包括 ONNXRuntime、MNN、TNN 和 TensorRT。该项目旨在提供一个简单易用的接口,以便开发者可以快速集成和部署 AI 模型。Lite AI Toolkit 不仅提供了预构建的库和测试资源,还支持混合使用 MNN 和 ONNXRuntime,使得开发者可以根据需要选择合适的后端。

项目快速启动

下载和安装

首先,从 GitHub 下载 Lite AI Toolkit 的预构建库和测试资源:

export LITE_AI_TAG_URL=https://github.com/DefTruth/lite.ai.toolkit/releases/download/v0.2.0
wget ${LITE_AI_TAG_URL}/lite-ort1.17.1+ocv4.9.0+ffmpeg4.2.2-linux-x86_64.tgz
wget ${LITE_AI_TAG_URL}/yolov5s.onnx
wget ${LITE_AI_TAG_URL}/test_yolov5.jpg

编译和运行示例

  1. 设置 CMakeLists.txt 文件:
set(lite_ai_toolkit_DIR YOUR-PATH-TO-LITE-INSTALL)
find_package(lite_ai_toolkit REQUIRED PATHS ${lite_ai_toolkit_DIR})
add_executable(lite_yolov5 test_lite_yolov5.cpp)
target_link_libraries(lite_yolov5 ${lite_ai_toolkit_LIBS})
  1. 编译测试工程:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j8
  1. 运行测试:
./lite_yolov5

应用案例和最佳实践

目标检测示例

以下是一个使用 YoloV5 进行目标检测的示例代码:

#include "lite/lite.h"

int main() {
    std::string onnx_path = "yolov5s.onnx";
    std::string test_img_path = "test_yolov5.jpg";
    std::string save_img_path = "test_results.jpg";

    auto *yolov5 = new lite::cv::detection::YoloV5(onnx_path);
    std::vector<lite::types::Boxf> detected_boxes;
    cv::Mat img_bgr = cv::imread(test_img_path);
    yolov5->detect(img_bgr, detected_boxes);
    lite::utils::draw_boxes_inplace(img_bgr, detected_boxes);
    cv::imwrite(save_img_path, img_bgr);
    delete yolov5;
    return 0;
}

混合使用 MNN 和 ONNXRuntime

Lite AI Toolkit 支持混合使用 MNN 和 ONNXRuntime。以下是一个示例:

#include "lite/lite.h"

int main() {
    // 使用 YoloV5 进行目标检测
    std::string onnx_path = "yolov5s.onnx";
    auto *yolov5 = new lite::cv::detection::YoloV5(onnx_path);

    // 使用 ONNXRuntime 或 MNN 实现自定义分类器
    // ...

    delete yolov5;
    return 0;
}

典型生态项目

相关项目

  • ONNXRuntime: 一个高性能的推理引擎,支持多种硬件平台。
  • MNN: 一个轻量级的深度学习推理引擎,适用于移动设备。
  • TNN: 腾讯优图实验室推出的高性能、轻量级的深度学习推理引擎。
  • TensorRT: NVIDIA 推出的高性能深度学习推理优化器和运行时库。

这些项目与 Lite AI Toolkit 结合使用,可以进一步提升 AI 模型的性能和部署灵活性。

lite.ai.toolkit🛠 A lite C++ toolkit of awesome AI models with ONNXRuntime, NCNN, MNN and TNN. YOLOv5, YOLOX, YOLOP, YOLOv6, YOLOR, MODNet, YOLOX, YOLOv7, YOLOv8. MNN, NCNN, TNN, ONNXRuntime.项目地址:https://gitcode.com/gh_mirrors/li/lite.ai.toolkit

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

苗眉妲Nora

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

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

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

打赏作者

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

抵扣说明:

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

余额充值