lite.ai.toolkit

xlite-devGPL-3.0活跃维护

一个轻量级 C++ AI 工具包,集成 100+ 模型,支持 MNN、ONNX Runtime 和 TensorRT 推理,覆盖目标检测、分割、Stable Diffusion、人脸融合等任务。

A lite C++ AI toolkit: 100+ models with MNN, ORT and TRT, including Det, Seg, Stable-Diffusion, Face-Fusion.

v0.3.4发布于 2025-07-02 01:42 UTC4,448star +1 / 7 天784fork同步于 2026-11-10 11:38 UTC

怎么上手

由 README 提炼,执行前请确认
git clone --depth=1 https://github.com/xlite-dev/lite.ai.toolkit.git
cd lite.ai.toolkit && sh ./build.sh
硬件要求按 README 说明

支持 GPU/CPU;TensorRT 后端需 NVIDIA GPU,CPU 推理走 ONNXRuntime、MNN、NCNN、TNN;README 未给出具体显存要求。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

轻量 C++ AI 工具箱,集成 100+ 模型,统一接口跑检测、分割、换脸等任务

一个轻量级 C++ AI 工具包,集成 100+ 模型,支持 MNN、ONNX Runtime 和 TensorRT 推理,覆盖目标检测、分割、Stable Diffusion、人脸融合等任务。

核心能力

  • 统一 lite::cv::Type::Class 调用风格
  • 默认仅依赖 OpenCV 和 ONNXRuntime
  • 支持 ONNXRuntime、MNN、NCNN、TNN 多后端
  • TensorRT 后端支持 GPU 加速推理
  • 覆盖检测、人脸、分割、抠图、StableDiffusion 等

容易踩的坑

仅支持 Linux,README 称在 Ubuntu 20.04.6 LTS 上测试过;模型权重需从 Model-Zoo 或 Release 单独下载;TensorRT 支持需用 bash ./build.sh tensorrt 单独构建;运行前要把 opencv、onnxruntime 等库路径加入 LD_LIBRARY_PATH。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.3.4
  1. v0.3.4最新正式版2025-07-02 · 2025-07-02 01:42 UTC

    What's Changed

    Full Changelog: https://github.com/xlite-dev/lite.ai.toolkit/compare/v0.3.3...v0.3.4

  2. v0.3.32025-04-28 · 2025-04-28 06:08 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/xlite-dev/lite.ai.toolkit/compare/v0.3.2...v0.3.3

  3. v0.3.22025-04-10 · 2025-04-10 06:03 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/xlite-dev/lite.ai.toolkit/compare/v0.3.1...v0.3.2

  4. v0.3.1.post12025-02-05 · 2025-02-05 07:42 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/DefTruth/lite.ai.toolkit/compare/v0.3.1...v0.3.1.post1

  5. v0.3.12024-12-02 · 2024-12-02 05:31 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/DefTruth/lite.ai.toolkit/compare/v0.2.0...v0.3.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    lite-ai-toolkit

    🛠Lite.Ai.ToolKit: A lite C++ toolkit of 100+ Awesome AI models, such as Object Detection, Face Detection, Face Recognition, Segmentation, Matting, etc. See Model Zoo and ONNX Hub, MNN Hub, TNN Hub, NCNN Hub. Welcome to 🌟👆🏻star this repo to support me, many thanks ~ 🎉🎉

    📖 News 🔥🔥

    • [2026/03] Cache-DiT 🎉v1.3.0 release is ready, the major updates including: Ring Attention w/ batched P2P, USP (Hybrid Ring and Ulysses), Hybrid 2D and 3D Parallelism (💥USP + TP), VAE-P Comm overhead reduce.

    arch

    Citations 🎉🎉

    @misc{lite.ai.toolkit@2021,
      title={lite.ai.toolkit: A lite C++ toolkit of 100+ Awesome AI models.},
      url={https://github.com/xlite-dev/lite.ai.toolkit},
      note={Open-source software available at https://github.com/xlite-dev/lite.ai.toolkit},
      author={xlite-dev, wangzijian1010 etc},
      year={2021}
    }
    

    Features 👏👋

    • Simply and User friendly. Simply and Consistent syntax like lite::cv::Type::Class, see examples.
    • Minimum Dependencies. Only OpenCV and ONNXRuntime are required by default, see build.
    • Many Models Supported. 300+ C++ implementations and 500+ weights 👉 Supported-Matrix.

    Build 👇👇

    Download prebuilt lite.ai.toolkit library from tag/v0.2.0, or just build it from source:

    git clone --depth=1 https://github.com/xlite-dev/lite.ai.toolkit.git  # latest
    cd lite.ai.toolkit && sh ./build.sh # >= 0.2.0, support Linux only, tested on Ubuntu 20.04.6 LTS
    

    Quick Start 🌟🌟

    Example0: Object Detection using YOLOv5. Download model from Model-Zoo2.
    #include "lite/lite.h"
    
    int main(int argc, char *argv[]) {
      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;
    }
    

    You can download the prebuilt lite.ai.tooklit library and test resources from tag/v0.2.0.

    export LITE_AI_TAG_URL=https://github.com/xlite-dev/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
    
    🎉🎉TensorRT: Boost inference performance with NVIDIA GPU via TensorRT.

    Run bash ./build.sh tensorrt to build lite.ai.toolkit with TensorRT support, and then test yolov5 with the codes below. NOTE: lite.ai.toolkit need TensorRT 10.x (or later) and CUDA 12.x (or later). Please check build.sh, tensorrt-linux-x86_64-install.zh.md, test_lite_yolov5.cpp and NVIDIA/TensorRT for more details.

    // trtexec --onnx=yolov5s.onnx --saveEngine=yolov5s.engine
    auto *yolov5 = new lite::trt::cv::detection::YOLOV5(engine_path);
    

    Quick Setup 👀

    To quickly setup lite.ai.toolkit, you can follow the CMakeLists.txt listed as belows. 👇👀

    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})
    

    Mixed with MNN or ONNXRuntime 👇👇

    The goal of lite.ai.toolkit is not to abstract on top of MNN and ONNXRuntime. So, you can use lite.ai.toolkit mixed with MNN(-DENABLE_MNN=ON, default OFF) or ONNXRuntime(-DENABLE_ONNXRUNTIME=ON, default ON). The lite.ai.toolkit installation package contains complete MNN and ONNXRuntime. The workflow may looks like:

    #include "lite/lite.h"
    // 0. use yolov5 from lite.ai.toolkit to detect objs.
    auto *yolov5 = new lite::cv::detection::YoloV5(onnx_path);
    // 1. use OnnxRuntime or MNN to implement your own classfier.
    interpreter = std::shared_ptr<MNN::Interpreter>(MNN::Interpreter::createFromFile(mnn_path));
    // or: session = new Ort::Session(ort_env, onnx_path, session_options);
    classfier = interpreter->createSession(schedule_config);
    // 2. then, classify the detected objs use your own classfier ...
    

    The included headers of MNN and ONNXRuntime can be found at mnn_config.h and ort_config.h.

    Download resources

    You can download the prebuilt lite.ai.tooklit library and test resources from tag/v0.2.0.

    export LITE_AI_TAG_URL=https://github.com/xlite-dev/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
    tar -zxvf lite-ort1.17.1+ocv4.9.0+ffmpeg4.2.2-linux-x86_64.tgz
    

    Write test code

    write YOLOv5 example codes and name it test_lite_yolov5.cpp:

    #include "lite/lite.h"
    
    int main(int argc, char *argv[]) {
      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;
    }
    

    Setup CMakeLists.txt

    cmake_minimum_required(VERSION 3.10)
    project(lite_yolov5)
    set(CMAKE_CXX_STANDARD 17)
    
    set(lite.ai.toolkit_DIR YOUR-PATH-TO-LITE-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})
    

    Build example

    mkdir build && cd build && cmake .. && make -j1
    

    Then, export the lib paths to LD_LIBRARY_PATH which listed by lite.ai.toolkit_LIBS_DIRS.

    export LD_LIBRARY_PATH=YOUR-PATH-TO-LITE-INSTALL/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=YOUR-PATH-TO-LITE-INSTALL/third_party/opencv/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=YOUR-PATH-TO-LITE-INSTALL/third_party/onnxruntime/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=YOUR-PATH-TO-LITE-INSTALL/third_party/MNN/lib:$LD_LIBRARY_PATH # if -DENABLE_MNN=ON
    

    Run binary:

    cp ../yolov5s.onnx ../test_yolov.jpg .
    ./lite_yolov5
    

    The output logs:

    LITEORT_DEBUG LogId: ../examples/hub/onnx/cv/yolov5s.onnx
    =============== Input-Dims ==============
    Name: images
    Dims: 1
    Dims: 3
    Dims: 640
    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: 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
    

    Supported Models Matrix

    • / = not supported now.
    • ✅ = known work and official supported now.
    • ✔️ = known work, but unofficial supported now.
    • ❔ = in my plan, but not coming soon, maybe a few months later.

    NVIDIA GPU Inference: TensorRT

    ClassClassClassClassClassSystemEngine
    ✅YOLOv5✅YOLOv6✅YOLOv8✅YOLOv8Face✅YOLOv5FaceLinuxTensorRT
    ✅YOLOX✅YOLOv5BlazeFace✅StableDiffusion✅FaceFusion/LinuxTensorRT

    CPU Inference: ONNXRuntime, MNN, NCNN and TNN

    ClassSizeTypeDemoONNXRuntimeMNNNCNNTNNLinuxMacOSWindowsAndroid
    YoloV528Mdetectiondemo✅✅✅✅✅✔️✔️❔
    YoloV3236Mdetectiondemo✅///✅✔️✔️/
    TinyYoloV333Mdetectiondemo✅///✅✔️✔️/
    YoloV4176Mdetectiondemo✅///✅✔️✔️/
    SSD76Mdetectiondemo✅///✅✔️✔️/
    SSDMobileNetV127Mdetectiondemo✅///✅✔️✔️/
    YoloX3.5Mdetectiondemo✅✅✅✅✅✔️✔️❔
    TinyYoloV4VOC22Mdetectiondemo✅///✅✔️✔️/
    TinyYoloV4COCO22Mdetectiondemo✅///✅✔️✔️/
    YoloR39Mdetectiondemo✅✅✅✅✅✔️✔️❔
    ScaledYoloV4270Mdetectiondemo✅///✅✔️✔️/
    EfficientDet15Mdetectiondemo✅///✅✔️✔️/
    EfficientDetD7220Mdetectiondemo✅///✅✔️✔️/
    EfficientDetD8322Mdetectiondemo✅///✅✔️✔️/
    YOLOP30Mdetectiondemo✅✅✅✅✅✔️✔️❔
    NanoDet1.1Mdetectiondemo✅✅✅✅✅✔️✔️❔
    NanoDetPlus4.5Mdetectiondemo✅✅✅✅✅✔️✔️❔
    NanoDetEffi...12Mdetectiondemo✅✅✅✅✅✔️✔️❔
    YoloX_V_0_1_13.5Mdetectiondemo✅✅✅✅✅✔️✔️❔
    YoloV5_V_6_07.5Mdetectiondemo✅✅✅✅✅✔️✔️❔
    GlintArcFace92Mfaceiddemo✅✅✅✅✅✔️✔️❔
    GlintCosFace92Mfaceiddemo✅✅✅✅✅✔️✔️/
    GlintPartialFC170Mfaceiddemo✅✅✅✅✅✔️✔️/
    FaceNet89Mfaceiddemo✅✅✅✅✅✔️✔️/
    FocalArcFace166Mfaceiddemo✅✅✅✅✅✔️✔️/
    FocalAsiaArcFace166Mfaceiddemo✅✅✅✅✅✔️✔️/
    TencentCurricularFace249Mfaceiddemo✅✅✅✅✅✔️✔️/
    TencentCifpFace130Mfaceiddemo✅✅✅✅✅✔️✔️/
    CenterLossFace280Mfaceiddemo✅✅✅✅✅✔️✔️/
    SphereFace80Mfaceiddemo✅✅✅✅✅✔️✔️/
    PoseRobustFace92Mfaceiddemo✅///✅✔️✔️/
    NaivePoseRobustFace43Mfaceiddemo✅///✅✔️✔️/
    MobileFaceNet3.8Mfaceiddemo✅✅✅✅✅✔️✔️❔
    CavaGhostArcFace15Mfaceiddemo✅✅✅✅✅✔️✔️❔
    CavaCombinedFace250Mfaceiddemo✅✅✅✅✅✔️✔️/
    MobileSEFocalFace4.5Mfaceiddemo✅✅✅✅✅✔️✔️❔
    RobustVideoMatting14Mmattingdemo✅✅/✅✅✔️✔️❔
    MGMatting113Mmattingdemo✅✅/✅✅✔️✔️/
    MODNet24Mmattingdemo✅✅✅✅✅✔️✔️/
    MODNetDyn24Mmattingdemo✅///✅✔️✔️/
    BackgroundMattingV220Mmattingdemo✅✅/✅✅✔️✔️/
    BackgroundMattingV2Dyn20Mmattingdemo✅///✅✔️✔️/
    UltraFace1.1Mface::detectdemo✅✅✅✅✅✔️✔️❔
    RetinaFace1.6Mface::detectdemo✅✅✅✅✅✔️✔️❔
    FaceBoxes3.8Mface::detectdemo✅✅✅✅✅✔️✔️❔
    FaceBoxesV23.8Mface::detectdemo✅✅✅✅✅✔️✔️❔
    SCRFD2.5Mface::detectdemo✅✅✅✅✅✔️✔️❔
    YOLO5Face4.8Mface::detectdemo✅✅✅✅✅✔️✔️❔
    PFLD1.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PFLD984.8Mface::aligndemo✅✅✅✅✅✔️✔️❔
    MobileNetV2689.4Mface::aligndemo✅✅✅✅✅✔️✔️❔
    MobileNetV2SE6811Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PFLD682.8Mface::aligndemo✅✅✅✅✅✔️✔️❔
    FaceLandmark10002.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PIPNet9844.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PIPNet6844.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PIPNet2944.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    PIPNet1944.0Mface::aligndemo✅✅✅✅✅✔️✔️❔
    FSANet1.2Mface::posedemo✅✅/✅✅✔️✔️❔
    AgeGoogleNet23Mface::attrdemo✅✅✅✅✅✔️✔️❔
    GenderGoogleNet23Mface::attrdemo✅✅✅✅✅✔️✔️❔
    EmotionFerPlus33Mface::attrdemo✅✅✅✅✅✔️✔️❔
    VGG16Age514Mface::attrdemo✅✅✅✅✅✔️✔️/
    VGG16Gender512Mface::attrdemo✅✅✅✅✅✔️✔️/
    SSRNet190Kface::attrdemo✅✅/✅✅✔️✔️❔
    EfficientEmotion715Mface::attrdemo✅✅✅✅✅✔️✔️❔
    EfficientEmotion815Mface::attrdemo✅✅✅✅✅✔️✔️❔
    MobileEmotion713Mface::attrdemo✅✅✅✅✅✔️✔️❔
    ReXNetEmotion730Mface::attrdemo✅✅/✅✅✔️✔️/
    EfficientNetLite449Mclassificationdemo✅✅/✅✅✔️✔️/
    ShuffleNetV28.7Mclassificationdemo✅✅✅✅✅✔️✔️❔
    DenseNet12130.7Mclassificationdemo✅✅✅✅✅✔️✔️/
    GhostNet20Mclassificationdemo✅✅✅✅✅✔️✔️❔
    HdrDNet13Mclassificationdemo✅✅✅✅✅✔️✔️❔
    IBNNet97Mclassificationdemo✅✅✅✅✅✔️✔️/
    MobileNetV213Mclassificationdemo✅✅✅✅✅✔️✔️❔
    ResNet44Mclassificationdemo✅✅✅✅✅✔️✔️/
    ResNeXt95Mclassificationdemo✅✅✅✅✅✔️✔️/
    DeepLabV3ResNet101232Msegmentationdemo✅✅✅✅✅✔️✔️/
    FCNResNet101207Msegmentationdemo✅✅✅✅✅✔️✔️/
    FastStyleTransfer6.4Mstyledemo✅✅✅✅✅✔️✔️❔
    Colorizer123Mcolorizationdemo✅✅/✅✅✔️✔️/
    SubPixelCNN234Kresolutiondemo✅✅/✅✅✔️✔️❔
    SubPixelCNN234Kresolutiondemo✅✅/✅✅✔️✔️❔
    InsectDet27Mdetectiondemo✅✅/✅✅✔️✔️❔
    InsectID22Mclassificationdemo✅✅✅✅✅✔️✔️✔️
    PlantID30Mclassificationdemo✅✅✅✅✅✔️✔️✔️
    YOLOv5BlazeFace3.4Mface::detectdemo✅✅//✅✔️✔️❔
    YoloV5_V_6_17.5Mdetectiondemo✅✅//✅✔️✔️❔
    HeadSeg31Msegmentationdemo✅✅/✅✅✔️✔️❔
    FemalePhoto2Cartoon15Mstyledemo✅✅/✅✅✔️✔️❔
    FastPortraitSeg400ksegmentationdemo✅✅//✅✔️✔️❔
    PortraitSegSINet380ksegmentationdemo✅✅//✅✔️✔️❔
    PortraitSegExtremeC3Net180ksegmentationdemo✅✅//✅✔️✔️❔
    FaceHairSeg18Msegmentationdemo✅✅//✅✔️✔️❔
    HairSeg18Msegmentationdemo✅✅//✅✔️✔️❔
    MobileHumanMatting3Mmattingdemo✅✅//✅✔️✔️❔
    MobileHairSeg14Msegmentationdemo✅✅//✅✔️✔️❔
    YOLOv617Mdetectiondemo✅✅✅✅✅✔️✔️❔
    FaceParsingBiSeNet50Msegmentationdemo✅✅✅✅✅✔️✔️❔
    FaceParsingBiSeNetDyn50Msegmentationdemo✅////✔️✔️❔

    Model Zoo.

    Lite.Ai.ToolKit contains almost 100+ AI models with 500+ frozen pretrained files now. Most of the files are converted by myself. You can use it through lite::cv::Type::Class syntax, such as lite::cv::detection::YoloV5. More details can be found at Examples for Lite.Ai.ToolKit. Note, for Google Drive, I can not upload all the *.onnx files because of the storage limitation (15G).

    FileBaidu DriveGoogle DriveDocker HubHub (Docs)
    ONNXBaidu Drive code: 8ginGoogle DriveONNX Docker v0.1.22.01.08 (28G), v0.1.22.02.02 (400M)ONNX Hub
    MNNBaidu Drive code: 9v63❔MNN Docker v0.1.22.01.08 (11G), v0.1.22.02.02 (213M)MNN Hub
    NCNNBaidu Drive code: sc7f❔NCNN Docker v0.1.22.01.08 (9G), v0.1.22.02.02 (197M)NCNN Hub
    TNNBaidu Drive code: 6o6k❔TNN Docker v0.1.22.01.08 (11G), v0.1.22.02.02 (217M)TNN Hub
      docker pull qyjdefdocker/lite.ai.toolkit-onnx-hub:v0.1.22.01.08  # (28G)
      docker pull qyjdefdocker/lite.ai.toolkit-mnn-hub:v0.1.22.01.08   # (11G)
      docker pull qyjdefdocker/lite.ai.toolkit-ncnn-hub:v0.1.22.01.08  # (9G)
      docker pull qyjdefdocker/lite.ai.toolkit-tnn-hub:v0.1.22.01.08   # (11G)
      docker pull qyjdefdocker/lite.ai.toolkit-onnx-hub:v0.1.22.02.02  # (400M) + YOLO5Face
      docker pull qyjdefdocker/lite.ai.toolkit-mnn-hub:v0.1.22.02.02   # (213M) + YOLO5Face
      docker pull qyjdefdocker/lite.ai.toolkit-ncnn-hub:v0.1.22.02.02  # (197M) + YOLO5Face
      docker pull qyjdefdocker/lite.ai.toolkit-tnn-hub:v0.1.22.02.02   # (217M) + YOLO5Face
    

    🔑️ How to download Model Zoo from Docker Hub?

    • Firstly, pull the image from docker hub.
      docker pull qyjdefdocker/lite.ai.toolkit-mnn-hub:v0.1.22.01.08 # (11G)
      docker pull qyjdefdocker/lite.ai.toolkit-ncnn-hub:v0.1.22.01.08 # (9G)
      docker pull qyjdefdocker/lite.ai.toolkit-tnn-hub:v0.1.22.01.08 # (11G)
      docker pull qyjdefdocker/lite.ai.toolkit-onnx-hub:v0.1.22.01.08 # (28G)
      
    • Secondly, run the container with local share dir using docker run -idt xxx. A minimum example will show you as follows.
      • make a share dir in your local device.
      mkdir share # any name is ok.
      
      • write run_mnn_docker_hub.sh script like:
      #!/bin/bash  
      PORT1=6072
      PORT2=6084
      SERVICE_DIR=/Users/xxx/Desktop/your-path-to/share
      CONRAINER_DIR=/home/hub/share
      CONRAINER_NAME=mnn_docker_hub_d
      
      docker run -idt -p ${PORT2}:${PORT1} -v ${SERVICE_DIR}:${CONRAINER_DIR} --shm-size=16gb --name ${CONRAINER_NAME} qyjdefdocker/lite.ai.toolkit-mnn-hub:v0.1.22.01.08
      
      
    • Finally, copy the model weights from /home/hub/mnn/cv to your local share dir.
      # activate mnn docker.
      sh ./run_mnn_docker_hub.sh
      docker exec -it mnn_docker_hub_d /bin/bash
      # copy the models to the share dir.
      cd /home/hub 
      cp -rf mnn/cv share/
      

    Model Hubs

    The pretrained and converted ONNX files provide by lite.ai.toolkit are listed as follows. Also, see Model Zoo and ONNX Hub, MNN Hub, TNN Hub, NCNN Hub for more details.

    🔑️ More Examples.

    More examples can be found at examples.

    Example0: Object Detection using YOLOv5. Download model from Model-Zoo2.
    #include "lite/lite.h"
    
    static void test_default()
    {
      std::string onnx_path = "../../../examples/hub/onnx/cv/yolov5s.onnx";
      std::string test_img_path = "../../../examples/lite/resources/test_lite_yolov5_1.jpg";
      std::string save_img_path = "../../../examples/logs/test_lite_yolov5_1.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;
    }
    

    The output is:

    Or you can use Newest 🔥🔥 ! YOLO series's detector YOLOX or YoloR. They got the similar results.

    More classes for general object detection (80 classes, COCO).

    auto *detector = new lite::cv::detection::YoloX(onnx_path);  // Newest YOLO detector !!! 2021-07
    auto *detector = new lite::cv::detection::YoloV4(onnx_path); 
    auto *detector = new lite::cv::detection::YoloV3(onnx_path); 
    auto *detector = new lite::cv::detection::TinyYoloV3(onnx_path); 
    auto *detector = new lite::cv::detection::SSD(onnx_path); 
    auto *detector = new lite::cv::detection::YoloV5(onnx_path); 
    auto *detector = new lite::cv::detection::YoloR(onnx_path);  // Newest YOLO detector !!! 2021-05
    auto *detector = new lite::cv::detection::TinyYoloV4VOC(onnx_path); 
    auto *detector = new lite::cv::detection::TinyYoloV4COCO(onnx_path); 
    auto *detector = new lite::cv::detection::ScaledYoloV4(onnx_path); 
    auto *detector = new lite::cv::detection::EfficientDet(onnx_path); 
    auto *detector = new lite::cv::detection::EfficientDetD7(onnx_path); 
    auto *detector = new lite::cv::detection::EfficientDetD8(onnx_path); 
    auto *detector = new lite::cv::detection::YOLOP(onnx_path);
    auto *detector = new lite::cv::detection::NanoDet(onnx_path); // Super fast and tiny!
    auto *detector = new lite::cv::detection::NanoDetPlus(onnx_path); // Super fast and tiny! 2021/12/25
    auto *detector = new lite::cv::detection::NanoDetEfficientNetLite(onnx_path); // Super fast and tiny!
    auto *detector = new lite::cv::detection::YoloV5_V_6_0(onnx_path); 
    auto *detector = new lite::cv::detection::YoloV5_V_6_1(onnx_path); 
    auto *detector = new lite::cv::detection::YoloX_V_0_1_1(onnx_path);  // Newest YOLO detector !!! 2021-07
    auto *detector = new lite::cv::detection::YOLOv6(onnx_path);  // Newest 2022 YOLO detector !!!
    

    Example1: Video Matting using RobustVideoMatting2021🔥🔥🔥. Download model from Model-Zoo2.
    #include "lite/lite.h"
    
    static void test_default()
    {
      std::string onnx_path = "../../../examples/hub/onnx/cv/rvm_mobilenetv3_fp32.onnx";
      std::string video_path = "../../../examples/lite/resources/test_lite_rvm_0.mp4";
      std::string output_path = "../../../examples/logs/test_lite_rvm_0.mp4";
      std::string background_path = "../../../examples/lite/resources/test_lite_matting_bgr.jpg";
      
      auto *rvm = new lite::cv::matting::RobustVideoMatting(onnx_path, 16); // 16 threads
      std::vector<lite::types::MattingContent> contents;
      
      // 1. video matting.
      cv::Mat background = cv::imread(background_path);
      rvm->detect_video(video_path, output_path, contents, false, 0.4f,
                        20, true, true, background);
      
      delete rvm;
    }
    

    The output is:

    More classes for matting (image matting, video matting, trimap/mask-free, trimap/mask-based)

    auto *matting = new lite::cv::matting::RobustVideoMatting:(onnx_path);  //  W