TNTWEN / OpenVINO-YOLOV4

This is implementation of YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l,Scaled-YOLOv4 and INT8 Quantization in OpenVINO2021.3
MIT License
239 stars 66 forks source link
openvino scaledyolov4 tensorflow yolov4 yolov4-relu yolov4-tiny yolov4-tiny-3l

OpenVINO-YOLOV4

Introduction

This is full implementation of YOLOV4 series in OpenVINO2021.3.

Based on https://github.com/mystic123/tensorflow-yolo-v3

Supported model

Supported device

Supported model precision

Supported inference demo

Development log

FAQ

FAQ

Environment

How to use

★ This repository provides python inference demo for different OpenVINO version.pythondemo

★ Choose the right demo before you run object_detection_demo_yolov3_async.py

★ You could also use C++ inference demo provided by OpenVINO.

(OpenVINO2021.3 default C++ demo path:C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\open_model_zoo\demos\multi_channel_object_detection_demo_yolov3\cpp)

YOLOV4

download yolov4.weights .

#windows  default OpenVINO path

python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4.weights --data_format NHWC

"C:\Program Files (x86)\Intel\openvino_2021\bin\setupvars.bat"

python "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1 --reverse_input_channels

python object_detection_demo_yolov3_async.py -i cam -m frozen_darknet_yolov4_model.xml  -d CPU

OpenVINOyolov4

Compared with darknet: darknetyolov4

YOLOV4-relu

prepare yolov4.weights .

#windows  default OpenVINO path
cd yolov4-relu

python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4.weights --data_format NHWC

"C:\Program Files (x86)\Intel\openvino_2021\bin\setupvars.bat"

python "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1 --reverse_input_channels

python object_detection_demo_yolov3_async.py -i cam -m frozen_darknet_yolov4_model.xml  -d CPU

YOLOV4-tiny

download yolov4-tiny.weights .

#windows  default OpenVINO path

python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4-tiny.weights --data_format NHWC --tiny

"C:\Program Files (x86)\Intel\openvino_2021\bin\setupvars.bat"

python "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolo_v4_tiny.json --batch 1 --reverse_input_channels

python object_detection_demo_yolov3_async.py -i cam -m frozen_darknet_yolov4_model.xml  -d CPU

OpenVINOyolov4tiny

Compared with darknet: darknetyolov4tiny

INT8 Quantization

Thanks for Jacky's excellent work!

Ref:https://docs.openvinotoolkit.org/latest/pot_README.html

Environment:

Step 1:Dataset Conversion

we should convert YOLO dataset to OpenVINO supported formats first.

|--annotations

​ |-- output.json #output of convert.py , COCO-JSON format

|--images

​ |-- *.jpg #put all the images here

|--labels

​ |--*.txt #put all the YOLO format .txt labels here

|--classes.txt

we use coco128 for example:

cd INT8
python3 convert.py --root_dir coco128 --save_path output.json

Step 2: Install Accuracy-checker and POT

sudo apt-get install python3 python3-dev python3-setuptools python3-pip

cd /opt/intel/openvino_2021.3.394/deployment_tools/open_model_zoo/tools/accuracy_checker 
sudo python3 setup.py install

cd /opt/intel/openvino_2021.3.394/deployment_tools/tools/post_training_optimization_toolkit
sudo python3 setup.py install

Step 3: INT8 Quantization using POT

​ Prepare your yolo IR model(FP32/FP16) first.

source '/opt/intel/openvino_2021.3.394/bin/setupvars.sh'

pot -c yolov4_416x416_qtz.json --output-dir backup -e

​ Parameters you need to set in yolov4_416x416_qtz.json:

Step 4: Test IR model's map using Accuracy-checker

#source '/opt/intel/openvino_2021.3.394/bin/setupvars.sh'
accuracy_check -c yolov4_416x416_coco.yml -td CPU #-td GPU will be faster

​ Parameters you need to set in yolov4_416x416_qtz.json: