This repo using OpenVINO POT tool to quantize yolo-v7 series or yolo-v5 series onnx model to IR model
pip install openvino-dev==2022.1
- download yolo repo
Yolo v5:
git clone https://github.com/ultralytics/yolov5
Yolo v7:
git clone https://github.com/WongKinYiu/yolov7
- download pre trained weights (tiny version for example)
Yolo v5:
wget https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5s.pt
Yolo v7:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
-
place
yolovX_quantize.py
into Yolo root folder -
execute
train / test / val
script to createlabels.cache
-
(Optional) for yolo v5 replace code
self.segments[i][:, 0] = 0
toself.segments[i][0][:, 0] = 0
into file<yolo_v5_repo>/utils/dataloaders.py
-
Pytorch to ONNX
Yolo v5:
python export.py --weights <path_to_model>.pt --include torchscript onnx
Yolo v7:
python export.py --weights <path_to_model>.pt --grid --simplify --img-size 640 640
- ONNX to OpenVINO IR model
mo.exe --input_model <path_to_model>.onnx
-
modify config (model & dataset path) in
yolovX_quantize.py
-
python yolovX_quantize.py