C++ YOLO v7 ONNX Runtime inference code for object detection in a Video.
- OpenCV 4.x
- ONNXRuntime 1.11+
- OS: Tested on MacOS
- CUDA 11+ [Optional]
brew install onnxruntime
brew install opencv
To build the project you should run the following commands.
mkdir build
cd build
cmake ..
make
Before running the executable you should convert your PyTorch model to ONNX if you haven't done it yet tutorial.
On MacOS
: to run the executable you should add OpenCV and ONNX Runtime libraries which we did using Homebrew
Change file path and names.
const std::string classNamesPath = "../models/coco.names";
const std::vector<std::string> classNames = utils::loadNames(classNamesPath);
const std::string videopath = "../videos/media01.mp4";
const std::string modelPath = "../models/yolov7s.onnx";
Note:- current directory should be the build.
Run from CLI:
./yolo_ort
- YOLOv7 repo: https://github.com/WongKinYiu/yolov7
- ONNXRuntime Inference examples: https://github.com/microsoft/onnxruntime-inference-examples