Skip to content

Python scripts performing object detection using the YOLOv6 model in ONNX.

License

Notifications You must be signed in to change notification settings

ibaiGorordo/ONNX-YOLOv6-Object-Detection

Repository files navigation

ONNX YOLOv6 Object Detection

Python scripts performing object detection using the YOLOv6 model in ONNX.

! ONNX YOLOv6 Object Detection Original image: https://commons.wikimedia.org/wiki/File:Motorcyclists_lane_splitting_in_Bangkok,_Thailand.jpg

Important

  • About the YOLOv6 name: https://github.com/meituan/YOLOv6/blob/main/docs/About_naming_yolov6.md
  • The input images are directly resized to match the input size of the model. I skipped adding the pad to the input image, it might affect the accuracy of the model if the input image has a different aspect ratio compared to the input size of the model. Always try to get an input size with a ratio close to the input images you will use.
  • The original YOLOv6 repository is still in development, so things might not work in the future.

Requirements

  • Check the requirements.txt file.
  • For ONNX, if you have a NVIDIA GPU, then install the onnxruntime-gpu, otherwise use the onnxruntime library.

Installation

git clone https://github.com/ibaiGorordo/ONNX-YOLOv6-Object-Detection.git
cd ONNX-YOLOv6-Object-Detection
pip install -r requirements.txt

ONNX Runtime

For Nvidia GPU computers: pip install onnxruntime-gpu

Otherwise: pip install onnxruntime

ONNX model

The original model was converted to ONNX using the following Colab notebook from the original repository, run the notebook and save the download model into the models folder:

  • Convert YOLOv6 ONNX for Inference Open In Colab

You can find the ONNX models in the Assets section of the official repository Releases (e.g. Release 2.1). Download the ONNX file and save the download model into the models folder:

Pytorch model

The original Pytorch model can be found in this repository: YOLOv6 Repository

Examples

  • Image inference:
python image_object_detection.py
  • Webcam inference:
python webcam_object_detection.py
python video_object_detection.py

!YOLOv6 detection video

Original video: https://youtu.be/yXEb0fWLJIY

python comparison_with_yolov5.py

Convert YOLOv5 model to ONNX: Open In Colab

References:

About

Python scripts performing object detection using the YOLOv6 model in ONNX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages