Skip to content

Use YOLO with your favorite language and computer vision library. This example includes ONNX runtime for better weights support.

Notifications You must be signed in to change notification settings

developer239/yolo-cmake-opencv-onnx-cpp

Repository files navigation

YOLO CMake OpenCV ONNX CPP

master

Object detection implementation is inspired by hpc203/yolov7-opencv-onnxrun-cpp-py

This repository serves mostly as documentation for my personal use, demonstrating how to use ONNX and OpenCV with CMake on MacOS.

How to run

  1. Install dependencies:
$ brew install cmake
$ brew install onnxruntime 
$ brew install opencv
  1. If you are on M1 then you are good to go 🎉

  2. If you are not using an M1 processor, download ONNX Runtime.

  • Either select the correct version from the releases available here
  • If you are unsure which version to download, you can use the official optimize inferencing picker here
  1. Put ONNX runtime files to external/

  2. Set ONNXRUNTIME_ROOT .env variable to your onnxruntime folder name

Model

  • This example utilizes a custom-trained model. If you wish to train your own model, you can create a dataset using Roboflow and then use one of their official notebooks to perform the training. There are also many comprehensive tutorials in the official ultralytics/yolov5 repository
  • You are free to use any model you prefer, but be sure to update the class.names file accordingly. Additionally, for instance segmentation, it is important to pass SegNetConfig with proper parameters.

Preview

Object detection dataset information:

  • 186 training images
  • 57 validation images
  • 25 test images

Instance segmentation dataset information:

  • 540 training images (AUGMENTATION rotation: Between -15° and +15°)
  • 53 validation images
  • 28 test images

preview-detection-1 preview-segmentation-1

preview-detection-2 preview-segmentation-2

preview-detection-3 preview-segmentation-3

About

Use YOLO with your favorite language and computer vision library. This example includes ONNX runtime for better weights support.

Topics

Resources

Stars

Watchers

Forks