openvino-dev-samples / YOLOv7_OpenVINO_cpp-python

This repository will demostrate how to deploy a offical YOLOv7 pre-trained model with OpenVINO runtime api
60 stars 15 forks source link
cpp deep-learning inference openvino python yolo yolov7

YOLOv7_OpenVINO

This repository will demostrate how to deploy a offical YOLOv7 pre-trained model with OpenVINO runtime api

1. Install requirements

1.1 Python

  $ pip install -r python/requirements.txt

1.2 C++ (Ubuntu)

Please follow the Guides to install OpenVINO and OpenCV

2. Prepare the model

Download YOLOv7 pre-trained weight from YOLOv7

3. Export the ONNX model and convert it to OpenVINO IR

  $ git clone git@github.com:WongKinYiu/yolov7.git
  $ cd yolov7
  $ pip install -r requirements
  $ python export.py --weights yolov7.pt
  $ ovc yolov7.onnx

4. Run inference

The input image can be found in YOLOv7's repository

4.1 Python

  $ python python/image.py -m path_to/yolov7.xml -i data/horse.jpg -d "CPU"

You can also try running the code with Preprocessing API for performance optimization.

  $ python python/image.py -m path_to/yolov7.xml -i data/horse.jpg -d "CPU" -p

Run inference

  $ yolov7 path_to/yolov7.xml ../../data/horses.jpg 'CPU'

5. Results

horse_res

6. Run with webcam

You can also run the sample with webcam for real-time detection

  $ python python/webcam.py -m path_to/yolov7.xml -i 0

Tips: you can switch the device name to "GPU" to improve the performance.

7. Further optimization

Try this notebook (yolov7-optimization) and quantize your YOLOv7 model to INT8.