Skip to content

Geekgineer/YOLOs-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

223 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

YOLOs-CPP

YOLOs-CPP

Production-Ready YOLO Inference Engine for C++

A blazing-fast, unified C++ inference library for the entire YOLO family

Stars Forks Release License CI

Quick Start Β· Features Β· Models Β· API Β· Benchmarks Β· Docs


πŸ“° Latest News

  • [2026.04.11] YOLOE open-vocabulary detection and segmentation in C++ β€” see Model Guide, image_yoloe_seg / video_yoloe_seg.
  • [2026.01.22] YOLOs-CPP-TensorRT released achive 530+ fps using NVIDIA GPUs and Jetson Boards. YOLOs-CPP-TensorRT
  • [2026.01.22] CPP Implementation of popular MOT trackers released. motcpp
  • [2026.01.22] ROS 2 integration released. ros2_yolos_cpp
  • [2026.01.18] Production-ready v1.0.0 released. Watch video
  • [2025.05.15] Classification support added.
  • [2025.04.04] Depths-CPP - New project for real-time metric depth estimation.
  • [2025.03.16] Pose estimation support added.
  • [2025.02.19] YOLOv12 support for object detection.
  • [2025.02.11] Oriented bounding box (OBB) format support added.
  • [2025.01.29] YOLOv9 support for object detection.
  • [2025.01.26] Segmentation support for YOLOv9.
  • [2025.01.26] Segmentation support for YOLOv8 and YOLOv11 with quantized models.
  • [2024.10.23] Initial release v0.0.1 with object detection support.

Why YOLOs-CPP?

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

The Problem

  • Fragmented ecosystem: Each YOLO version has different C++ implementations
  • Inconsistent APIs: Different interfaces for detection, segmentation, pose
  • Production gaps: Most implementations lack proper error handling, testing, and optimization

The Solution

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, YOLOE open-vocabulary
Battle-Tested 36 automated tests, CI/CD pipeline
Optimized Zero-copy preprocessing, batched NMS, GPU acceleration
Cross-Platform Linux, Windows, macOS, Docker

🎬 Demo

Instance Segmentation
Instance Segmentation
Pose Estimation
Pose Estimation
Object Detection
Real-time Detection
Multi-Object Detection and Segmentation
Multi-Object Detection

⚑ Quick Start

Prerequisites

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

Installation

# 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.jpg
πŸ“¦ Manual 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

🎯 Features

Supported Models

Version Detection Segmentation Pose OBB Classification
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.

Core Capabilities

  • πŸš€ High Performance: Zero-copy preprocessing, optimized NMS, GPU acceleration
  • 🎯 Precision Matched: Identical results to Ultralytics Python (validated by 36 automated tests)
  • πŸ“¦ Self-Contained: No Python runtime, no external dependencies at runtime
  • πŸ”Œ Easy Integration: Header-based library, modern C++17 API
  • βš™οΈ Flexible: CPU/GPU, dynamic/static input shapes, configurable thresholds

πŸ“– API Reference

Object Detection

#include "yolos/yolos.hpp"

// Initialize
yolos::det::YOLODetector detector("model.onnx", "coco.names", /*gpu=*/true);

// Detect
cv::Mat frame = cv::imread("image.jpg");
auto detections = detector.detect(frame, /*conf=*/0.25f, /*iou=*/0.45f);

// Process results
for (const auto& det : detections) {
    std::cout << "Class: " << det.className 
              << " Conf: " << det.confidence 
              << " Box: " << det.box << std::endl;
}

// Visualize
detector.drawDetections(frame, detections);

Instance Segmentation

yolos::seg::YOLOSegDetector detector("yolo11n-seg.onnx", "coco.names", true);
auto segments = detector.segment(frame);
detector.drawSegmentations(frame, segments, /*maskAlpha=*/0.5f);

Pose Estimation

yolos::pose::YOLOPoseDetector detector("yolo11n-pose.onnx", "", true);
auto poses = detector.detect(frame);
detector.drawPoses(frame, poses);

Oriented Bounding Boxes (OBB)

yolos::obb::YOLOOBBDetector detector("yolo11n-obb.onnx", "dota.names", true);
auto boxes = detector.detect(frame);
detector.drawOBBs(frame, boxes);

Image Classification

yolos::cls::YOLOClassifier classifier("yolo11n-cls.onnx", "imagenet.names", true);
auto result = classifier.classify(frame);
std::cout << "Predicted: " << result.className << " (" << result.confidence * 100 << "%)" << std::endl;

YOLOE (open-vocabulary segmentation)

See Model Guide β€” YOLOE for export and benchmarks.

#include "yolos/tasks/yoloe.hpp"
yolos::yoloe::YOLOESegDetector det("models/yoloe-26s-seg-text.onnx",
    {"person", "car", "bus", "bicycle", "motorcycle", "truck"}, /*gpu=*/true);
auto segs = det.segment(frame);
det.drawSegmentations(frame, segs);
# Image β†’ image (JPEG/PNG …)
./build/image_yoloe_seg data/photo.jpg out.jpg models/yoloe-26n-seg.onnx "person,car,bus" 0

# Video β†’ MP4
./build/video_yoloe_seg data/Transmission.mp4 out.mp4 models/yoloe-26n-seg.onnx "person,car,bus" 1

πŸ“Š Benchmarks

Tested on Intel i7-12700H (CPU) / NVIDIA RTX 3060 (GPU), 640Γ—640 input:

Model Task Device FPS Latency Memory
YOLOv11n Detection CPU 15 67ms 48MB
YOLOv11n Detection GPU 97 10ms 412MB
YOLOv8n Detection GPU 86 12ms 398MB
YOLO26n Detection GPU 78 13ms 425MB
YOLOv11n-seg Segmentation GPU 65 15ms 524MB
YOLOv11n-pose Pose GPU 80 12ms 445MB
Run Your Own Benchmarks
cd benchmarks
./auto_bench.sh 1.20.1 0 yolo11n,yolov8n,yolo26n

Results are saved to benchmarks/results/.


πŸ—οΈ Architecture

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
β”‚   β”‚   └── 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

πŸ“š Documentation

Guide Description
Installation System requirements, build options, troubleshooting
Usage Guide API reference, code examples, best practices
Model Guide Supported models, ONNX export, quantization
Development Architecture, extending the library, debugging
Contributing Code style, PR process, testing
Windows Setup Windows-specific build instructions

πŸ§ͺ Testing

YOLOs-CPP includes a comprehensive test suite that validates C++ inference against Ultralytics Python:

cd tests
./test_all.sh    # Run all tests
./test_detection.sh  # Run detection tests only
Task Tests Status
Detection 8 βœ…
Segmentation 8 βœ…
Pose 7 βœ…
OBB 7 βœ…
Classification 6 βœ…
Total 36 βœ…

🀝 Contributing

We welcome contributions! See our Contributing Guide for details.

# 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-feature

πŸ“„ License

This 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.


πŸ™ Acknowledgments

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

About

Cross-Platform Production-ready C++ inference engine for YOLO models (v5-v12, YOLO26). Unified API for detection, segmentation, pose estimation, OBB, and classification. Built on ONNX Runtime and OpenCV. Optimized for CPU/GPU with quantization support.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors