# OpenVINO-YOLOV4
## Introduction
This is full implementation of [YOLOV4 series](https://github.com/AlexeyAB/darknet) in OpenVINO2021.3.
Based on https://github.com/mystic123/tensorflow-yolo-v3
**Supported model**
- YOLOv4
- YOLOv4-relu
- YOLOv4-tiny
- [YOLOv4-tiny-3l](https://github.com/TNTWEN/OpenVINO-YOLOV4/tree/v4-tiny-3l)
- [YOLOv4-csp](https://github.com/TNTWEN/OpenVINO-YOLOV4/tree/ScaledYOLOv4)
- [YOLOv4x-mish](https://github.com/TNTWEN/OpenVINO-YOLOV4/tree/ScaledYOLOv4)
**Supported device**
- Intel CPU
- Intel GPU
- HDDL VPU
- NCS2
- ... ...
**Supported model precision**
- FP32
- FP16
- [INT8 Quantization](https://github.com/TNTWEN/OpenVINO-YOLOV4#int8-quantization)
**Supported inference demo**
- Python demo:all models
- C++ demo:YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l
## Environment
- OpenVINO2021.3 :https://docs.openvinotoolkit.org/latest/index.html or OpenVINO2020.4
- If you want to use yolov4+GPU+FP16,please don't use OpenVINO 2021.1 and OpenVINO2021.2
- Win or Ubuntu
- Python 3.6.5
- Tensorflow 1.15.5 (1.12.0 for OpenVINO2020.4 )
- YOLOV4:https://github.com/AlexeyAB/darknet train your own model
- *Convert YOLOV3/2/1 model :https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html
## How to use
★ This repository provides python inference demo for different OpenVINO version.[pythondemo](https://github.com/TNTWEN/OpenVINO-YOLOV4/tree/master/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](assets/yolov4-416.png)
Compared with darknet:
![darknetyolov4](assets/darknet-v4-416.jpg)
### 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](assets/yolov4tiny416.png)
Compared with darknet:
![darknetyolov4tiny](assets/darknet-v4tiny-416.jpg)
## INT8 Quantization
Thanks for [Jacky](https://github.com/jayer95)'s excellent work!
Ref:https://docs.openvinotoolkit.org/latest/pot_README.html
Environment:
- OpenVINO2021.3
- Ubuntu 18.04/20.04 ★
- Intel CPU/GPU
**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:
- Line 4,5 :Set FP32/FP16 YOLO IR model 's path
```
"model":"models/yolov4/FP16/frozen_darknet_yolov4_model.xml",
"weights":"models/yolov4/FP16/frozen_darknet_yolov4_model.bin"
```
- Line 29,30 :Set image width and height
```
"dst_width": 416,
"dst_height": 416
```
- Line 38: Annotation_file(COCO JSON file)
```
"annotation_file": "./coco128/annotations/output.json"
```
- Line 40: Path of images
```
"data_source": "./coco128/images",
```
- There are many other quantization strategies to choose from, and the relevant parameters are annotated in yolov4_416x416_qtz.json.Select the strategy you want to replace the default strategy and try by yourself!
**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:
- Line 5,6 : Set IR model 's path
```
model: models/yolov4/FP16/frozen_darknet_yolov4_model.xml
weights: models/yolov4/FP16/frozen_darknet_yolov4_model.bin
```
- Line 12: number of classes
```
classes: 80
```
- Line 25: Image size
```
size: 416
```
- Line 38:Annotation_file(COCO JSON file)
```
annotation_file: ./coco128/annotations/output.json
```
- Line 39: Path of images
```
data_source: ./coco128/images
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
算法部署-使用Openvino部署YOLOv4目标检测算法-支持INT8量化-优质算法部署项目实战.zip (299个子文件)
yolov4-relu.cfg 12KB
yolov4-relu.cfg 12KB
yolov4.cfg 12KB
yolov4.cfg 12KB
yolov4-tiny.cfg 3KB
yolov4-tiny.cfg 3KB
monitors_extension.cpp 6KB
monitors_extension.cpp 6KB
darknet-v4-416.jpg 591KB
darknet-v4tiny-416.jpg 543KB
000000000575.jpg 530KB
000000000034.jpg 397KB
000000000061.jpg 391KB
000000000073.jpg 375KB
000000000151.jpg 374KB
000000000368.jpg 341KB
000000000309.jpg 330KB
000000000397.jpg 313KB
000000000605.jpg 311KB
000000000312.jpg 293KB
000000000307.jpg 292KB
000000000502.jpg 287KB
000000000629.jpg 286KB
000000000389.jpg 260KB
000000000036.jpg 254KB
000000000540.jpg 252KB
000000000113.jpg 250KB
000000000395.jpg 241KB
000000000599.jpg 240KB
000000000400.jpg 240KB
000000000072.jpg 234KB
000000000138.jpg 229KB
000000000109.jpg 229KB
000000000192.jpg 225KB
000000000165.jpg 224KB
000000000529.jpg 223KB
000000000144.jpg 220KB
000000000094.jpg 220KB
000000000263.jpg 219KB
000000000009.jpg 219KB
000000000064.jpg 216KB
000000000438.jpg 215KB
000000000486.jpg 212KB
000000000071.jpg 209KB
000000000532.jpg 209KB
000000000042.jpg 208KB
000000000450.jpg 208KB
000000000078.jpg 205KB
000000000641.jpg 204KB
000000000257.jpg 204KB
000000000127.jpg 201KB
000000000394.jpg 199KB
000000000110.jpg 196KB
000000000194.jpg 192KB
000000000025.jpg 192KB
000000000459.jpg 190KB
000000000086.jpg 188KB
000000000581.jpg 184KB
000000000544.jpg 184KB
000000000315.jpg 180KB
000000000595.jpg 176KB
000000000321.jpg 173KB
000000000074.jpg 172KB
000000000404.jpg 172KB
000000000636.jpg 171KB
000000000597.jpg 170KB
000000000208.jpg 170KB
000000000612.jpg 170KB
000000000625.jpg 167KB
000000000510.jpg 165KB
000000000387.jpg 162KB
000000000089.jpg 160KB
000000000133.jpg 160KB
000000000164.jpg 157KB
000000000328.jpg 156KB
000000000201.jpg 156KB
000000000077.jpg 155KB
000000000196.jpg 155KB
000000000247.jpg 155KB
000000000626.jpg 154KB
000000000584.jpg 151KB
000000000419.jpg 149KB
000000000431.jpg 145KB
000000000508.jpg 145KB
000000000283.jpg 143KB
000000000154.jpg 139KB
000000000382.jpg 136KB
000000000308.jpg 135KB
000000000436.jpg 135KB
000000000384.jpg 133KB
000000000490.jpg 132KB
000000000474.jpg 128KB
000000000357.jpg 128KB
000000000542.jpg 128KB
000000000564.jpg 127KB
000000000569.jpg 127KB
000000000620.jpg 125KB
000000000514.jpg 124KB
000000000049.jpg 122KB
000000000332.jpg 119KB
共 299 条
- 1
- 2
- 3
资源评论
__AtYou__
- 粉丝: 3506
- 资源: 2175
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功