Cross-Platform Production-ready C++ inference engine for YOLO models (v5-v12, YOLO26). Unified API for detection, segmentation, pose estimation, OBB, and classi
Cross-Platform Production-ready C++ inference engine for YOLO models (v5-v12, YOLO26). Unified API for detection, segmentation, pose estimation, OBB, and classi
YOLOs-CPP
Production-Ready YOLO Inference Engine for C++
A blazing-fast, unified C++ inference library for the entire YOLO family
Quick Start · Features · Models · API · Benchmarks · Docs
yolos::depth::YOLODepthEstimator and the image_depth_inference example.batchDetect, batchSegment, and batchClassify, plus in-memory model loading across all supported tasks.image_yoloe_seg / video_yoloe_seg examples.YOLOs-CPP is a production-grade inference engine that brings the entire YOLO ecosystem to C++. Unlike scattered implementations, YOLOs-CPP provides a unified, consistent API across all YOLO versions and tasks.
#include "yolos/yolos.hpp"
// One API for all YOLO versions and tasks
auto detector = yolos::det::YOLODetector("yolo11n.onnx", "coco.names");
auto detections = detector.detect(frame);YOLOs-CPP unifies everything under one roof:
| What You Get | Description |
|---|---|
| Unified API | Same interface for YOLOv5 through YOLO26 |
| All Tasks | Detection, Segmentation, Pose, OBB, Classification, Depth, YOLOE open-vocabulary |
| Battle-Tested | 50 Ultralytics-parity tests + 57 self-contained tests, CI/CD pipeline |
| Optimized | Zero-copy preprocessing, batched NMS, GPU acceleration |
| Batch Inference | batchDetect / batchSegment / batchClassify in one ONNX call, with fallback |
| Flexible Loading | Models from a file path or straight from memory (encrypted stores, network streams, embedded resources) |
| Cross-Platform | Linux, Windows, macOS, Docker |
Instance Segmentation
Pose Estimation
Real-time Detection
Multi-Object Detection
| Requirement | Version | Notes |
|---|---|---|
| C++ Compiler | C++17 | GCC 9+, Clang 10+, MSVC 2019+ |
| CMake | ≥ 3.16 | |
| OpenCV | ≥ 4.5 | Core, ImgProc, HighGUI |
| ONNX Runtime | ≥ 1.16 | Auto-downloaded by build script |
# Clone
git clone https://github.com/Geekgineer/YOLOs-CPP.git
cd YOLOs-CPP
# Build (auto-downloads ONNX Runtime)
./build.sh 1.20.1 0 # CPU build
./build.sh 1.20.1 1 # GPU build (requires CUDA)
# Run
./build/image_inference models/yolo11n.onnx data/dog.jpgManual CMake Build
# Download ONNX Runtime
wget https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-1.20.1.tgz
tar -xzf onnxruntime-linux-x64-1.20.1.tgz
# Configure and build
mkdir build && cd build
cmake .. -DONNXRUNTIME_DIR=../onnxruntime-linux-x64-1.20.1 -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)Docker
# CPU
docker build -f Dockerfile.cpu -t yolos-cpp:cpu .
docker run --rm -it yolos-cpp:cpu
# GPU (requires nvidia-docker)
docker build -t yolos-cpp:gpu .
docker run --gpus all --rm -it yolos-cpp:gpu| Version | Detection | Segmentation | Pose | OBB | Classification | Depth |
|---|---|---|---|---|---|---|
| YOLOv5 | ✅ | — | — | — | — | — |
| YOLOv6 | ✅ | — | — | — | — | — |
| YOLOv7 | ✅ | — | — | — | — | — |
| YOLOv8 | ✅ | ✅ | ✅ | ✅ | ✅ | — |
| YOLOv9 | ✅ | — | — | — | — | — |
| YOLOv10 | ✅ | — | — | — | — | — |
| YOLOv11 | ✅ | ✅ | ✅ | ✅ | ✅ | — |
| YOLOv12 | ✅ | — | — | — | — | — |
| YOLO26 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| YOLOE (open-vocab) | ✅ | ✅ | — | — | — | — |
Open-vocabulary YOLOE uses ONNX exported after set_classes() (text) or prompt-free *-pf checkpoints; see the guide for how that differs from interactive Python prompts. Export with scripts/export_yoloe_onnx.py, then run ./build/image_yoloe_seg or ./build/video_yoloe_seg, or the benchmarks yoloe-seg task.
Depth estimation is YOLO26-only (
yolo26{n,s,m,l,x}-depth). See Depth Estimation.
…./build/batch_image_inference models/yolo11n.onnx data/ models/coco.namesFor encrypted stores, network streams and resources embedded in the binary — the model never needs to exist as a file. See In-Memory Model Loading.
// Bytes from anywhere: decryption, download, embedded array
std::vector bytes = yolos::utils::readFileBytes("yolo11n.onnx");
// Class names come in as a vector, so no labels file is needed either
yolos::det::YOLODetector detector(bytes.data(), bytes.size(), {"person", "bicycle", "car"});
// ONNX Runtime copied the buffer during construction — safe to wipe it now
auto detections = detector.detect(frame);yolos::depth::YOLODepthEstimator estimator("yolo26n-depth.onnx", true);
cv::Mat depth = estimator.estimate(frame); // CV_32FC1, meters
std::cout (y, x)
Run Your Own Benchmarks
```bash
cd benchmarks
./auto_bench.sh 1.20.1 0 yolo11n,yolov8n,yolo26nResults are saved to benchmarks/results/.
YOLOs-CPP/
├── include/yolos/ # Core library
│ ├── core/ # Shared utilities
│ │ ├── types.hpp # Detection, Segmentation result types
│ │ ├── preprocessing.hpp # Letterbox, normalization
│ │ ├── nms.hpp # Non-maximum suppression
│ │ ├── drawing.hpp # Visualization utilities
│ │ └── version.hpp # YOLO version detection
│ ├── tasks/ # Task implementations
│ │ ├── detection.hpp # Object detection
│ │ ├── segmentation.hpp # Instance segmentation
│ │ ├── pose.hpp # Pose estimation
│ │ ├── obb.hpp # Oriented bounding boxes
│ │ ├── classification.hpp
│ │ ├── depth.hpp # Monocular metric depth (YOLO26)
│ │ └── yoloe.hpp # YOLOE open-vocabulary (det/seg)
│ └── yolos.hpp # Main include (includes all)
├── src/ # Example applications
├── examples/ # Task-specific examples
├── tests/ # Automated test suite
├── benchmarks/ # Performance benchmarking
└── models/ # Sample models & labels
…
bash
cd tests
./test_all.sh # Run all suites
./test_detection.sh # Run detection only
…
bash
# Fork, clone, branch
git checkout -b feature/amazing-feature
# Make changes, test
./tests/test_all.sh
# Commit and PR
git commit -m "feat: add amazing feature"
git push origin feature/amazing-featureThis project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE for details.
For commercial licensing options, please contact the maintainers.
YOLOs-CPP builds on the shoulders of giants:
⭐ If YOLOs-CPP helps your project, consider giving it a star!
Made with ❤️ by the YOLOs-CPP Team
No open issues yet, or sync has not completed.