english | 简体中文
vision-simple
is a cross-platform visual inference library based on C++23, designed to provide out-of-the-box inference capabilities. With Docker, users can quickly set up inference services. This library currently supports popular YOLO models (including YOLOv10 and YOLOv11) and some OCR models (such as PaddleOCR
). It features a built-in HTTP API, making the service more accessible. Additionally, vision-simple
uses the ONNXRuntime
engine, which supports multiple Execution Providers such as DirectML
, CUDA
, TensorRT
, and can be compatible with specific hardware devices (such as RockChip's RKNPU), offering more efficient inference performance.
- Cross-platform: Supports
windows/x64
,linux/x86_64
,linux/arm64
,andlinux/riscv64
- Multi-device: Supports CPU, GPU, and RKNPU
- Small size: The statically compiled version is under 20 MiB, with YOLO and OCR inference occupying 300 MiB of memory
- Fast deployment:
- One-click compilation: Provides verified build scripts for multiple platforms
- Container deployment: One-click deployment with
docker
,podman
, orcontainerd
- HTTP Service: Offers a HTTP API for non-real-time applications
- Start the server project:
docker run -it --rm --name vs -p 11451:11451 lonacn/vision_simple:0.4.1-cpu-x86_64
- Open the Swagger online editor and allow the site’s unsafe content.
- Copy the content from doc/openapi/server.yaml into the Swagger editor.
- On the right panel of the editor, select the APIs you want to test
### Build Project
#### windows/x64
- xmake >= 2.9.7
- msvc with C++23
- Windows 11
```powershell
# pull project
git clone https://github.com/lona-cn/vision-simple.git
cd vision-simple
# setup sln
./scripts/dev-vs.bat
# run server
xmake build server
xmake run server
- xmake >= 2.9.7
- gcc-13
- Debian 12 / Ubuntu 2022
# pull project
git clone https://github.com/lona-cn/vision-simple.git
cd vision-simple
# build release
./scripts/build-release.sh
# run server
xmake build server
xmake run server
All Dockerfiles
are located in the docker/
directory.
# pull project
git clone https://github.com/lona-cn/vision-simple.git
cd vision-simple
# Build the project
docker build -t vision-simple:latest -f docker/Dockerfile.debian-bookworm-x86_64-cpu .
# Run the container, the default configuration will use CPU inference and listen on port 11451
docker run -it --rm -p 11451:11451 --name vs vision-simple
#include <Infer.h>
#include <opencv2/opencv.hpp>
using namespace vision_simple;
template <typename T>
struct DataBuffer
{
std::unique_ptr<T[]> data;
size_t size;
std::span<T> span(){return std::span{data.get(), size};}
};
extern std::expected<DataBuffer<uint8_t>, InferError> ReadAll(const std::string& path);
int main(int argc,char *argv[]){
auto data = ReadAll("assets/hd2-yolo11n-fp32.onnx");
auto image = cv::imread("assets/hd2.png");
auto ctx = InferContext::Create(InferFramework::kONNXRUNTIME, InferEP::kDML);
auto infer_yolo = InferYOLO::Create(**ctx, data->span(), YOLOVersion::kV11);
auto result = infer_yolo->get()->Run(image, 0.625);
// do what u want
return 0;
}
<div align="center">📄 License</div>
The copyrights for the YOLO models and PaddleOCR models in this project belong to the original authors.
This project is licensed under the Apache-2.0 license.