python scripts for rknn object detection for Orange pi 5
Python3.12 required
- Clone the yolov5 github repo
- Setup a venv to use with the toolkit
- Install all the requirements
pip install -r requirements.txt
- Verify that it works (or just wait until you obtain the dataset to train)
You can manually make a dataset, or use roboflow. Make sure the image dimensions match how you are going to train it
- Get the correct dataset format downloaded and in the same folder as the yolov5 toolkit
- Find the
.yaml
file for that dataset. You might want to rename it. - In that yaml file, update the paths for the
train
andvalid
folders so that they are correct
- Run the following command (make sure you are using your inputs. For testing, do a 3 epoch training first)
python train.py --img 640 --epochs 30 --data data.yaml --weights yolov5.pt
- If you are on a silicon mac using m1 or m2 (m3 not supported yet), add
--device mps
. If you are on a cuda device (Nvidia GPU) add--device cuda
. If you encounter issues, remove the flag to train on cpu - Once the training is finished, verify that you have a
runs/train/exp/weights/best.pt
file. Note that theexp
folder may becomeexp2
orexp3
if you ran multiple trainings. The highest number is the latest training - You can upload the model to roboflow using
upload.py
. Make sure to change the version and expNum variables. After uploading, use the visualize tool on roboflow to test your model
- Once training is finished, run
python export.py --weights /runs/train/exp/weights/best.pt --include onnx
- Find the output onnx file in the same directory was your
best.pt
file
- Setup a linux x86 device with python3.10. Install the RKNN toolkit python package from here
- Upload your
best.onnx
file to that device - Run
convert.py
to get the outputmodel.rknn
file
This is a mystery. Yet to be resolved