This repo contains code for training Yolo(v1, v3, v5) architectures using different quantization. It utilizes Brevitas which is a Pytorch research library for quantization-aware training (QAT) from Xilinx. The code is developed on top of YOLOV5.
$ git clone git@github.com:sefaburakokcu/quantized-yolov5.git
$ cd yolov5
$ pip install -r requirements.txt
detect.py
runs inference on a variety of sources and saving results to runs/detect
.
$ python detect.py --weights /path-to-weights-folder
--source 0 # webcam
file.jpg # image
file.mp4 # video
path/ # directory
path/*.jpg # glob
'https://youtu.be/NUsoVlDFqZg' # YouTube
'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream
Run commands below to reproduce results on Widerface dataset.
$ python train.py --data widerface.yaml --cfg models/hub/yolov1-tiny-quant.yaml --weights '' --batch-size 128
Sigmoid activation is used in detect layer when training whereas HardTanh is used when exporting the model for FINN.
$ python export.py --data widerface.yaml --weights runs/train/exp1/weights/best.pt --nodetect