Training YOLOv5 Model and Deploying to DEBIX

2025.6.13by debix.io

Installation

Clone the repository and install the dependencies in a Python>=3.8.0 environment. Ensure that PyTorch>=1.8 is installed.

git clone https://github.com/ultralytics/yolov5

cd yolov5

pip install -r requirements.txt

Training

Start training using the YOLO CLI. If the dataset and pre-trained model are not available locally, they will be automatically downloaded from the latest YOLOv5.

yolo detect train data=coco128.yaml model=yolov5n.pt epochs=100 imgsz=640

Exporting

Export the trained model to an ONNX intermediate model.

python .\export.py --weights .\runs\detect\train2\weights\best.pt --include onnx --int8 --opset 12


Conversion

Convert the exported ONNX model to a TFlite model.

1、 Download the NXP eIQ toolchain:https://www.nxp.com.cn/design/design-center/software/eiq-ai-development-environment/eiq-toolkit-for-end-to-end-model-development-and-deployment:EIQ-TOOLKIT

2、 Open the eIQ Portal, select the model tool, and open the converted best.onnx.

3、 Select convert,TensorFlow Lite


After the conversion is complete, you will obtain the best_converted.tflite.


Testing

Copy the exported best_converted.tflite to DEBIX.

Enter the /usr/bin/tensorflow-lite-2.16.2/examples directory via the command line, and run the benchmark

To use NPU acceleration, add the parameter, --external_delegate_path=/usr/lib/libvx_delegate.so

./benchmark_model --graph=/root/best_converted.tflite --enable_op_profiling=true --external_delegate_path=/usr/lib/libvx_delegate.so