In this example, we’re going to retrain the model to detect barcodes, using the barcode-detector dataset from Kaggle. After the retraining process, we’re going to convert the model to HEF and test it on the Raspberry Pi 5 AI Kit.
Hardware:
- CPU: Intel i7-6850K
- GPU: RTX 4080
Software:
- OS: Ubuntu 20.04
- Hailo DFC version: 3.27.0
- Hailo Model-Zoo: 2.11.0
- Install the Hailo AI SW-Suite from the Developer Zone. Alternatively, you can download and install the DFC and the model-zoo into the same virtual environment.
- Follow the instructions on the YOLOv8 retraining page: YOLOv8 Retraining
- Note in this example we added volume mount with the name
data
to the Docker container. - Download the barcode-detector dataset from Kaggle. Make sure that it’s either mapped into the retraining Docker, or copied inside.
On my RTX 4080, it took about 3 hours:
yolo detect train data=/data/barcode-detect/data.yaml model=yolov8s.pt name=retrain_yolov8s epochs=20 batch=8
After the final epoch has finished, you should see a message like this:
yolo predict task=detect source=/data/barcode-detect/valid/images/05102009190_jpg.rf.e9661dd52bd50001b08e7a510978560b.jpg model=./runs/detect/retrain_yolov8s/weights/best.pt
yolo export model=/workspace/ultralytics/runs/detect/retrain_yolov8s/weights/best.pt imgsz=640 format=onnx opset=11
cp ./runs/detect/retrain_yolov8s/weights/best.onnx /data/barcode-detection.onnx
Use the Hailo Model Zoo command (this can take up to 30 minutes):
hailomz compile yolov8s --ckpt=barcode-detection.onnx --hw-arch hailo8l --calib-path barcode-detect/test/images/ --classes 2 --performance
You should get a message like this:
For deployment instructions, see Using Retrained Models.