I have exported the yolov5s PyTorch model from ultralytics/yolov5 and converted it to ONNX, using Google Colab, so that I can convert it to rknn in my rk3588 Radxa Rock 5c module.
%cd /content/
!pip unistall torch
!git clone https://github.com/ultralytics/yolov5
%cd yolov5
%pip install -qr requirements.txt comet_ml
onnx_model_path = '/content/drive/MyDrive/documents/kaderetrack_datasets/yolov5n_fixed.onnx'
rknn_model_path = '/content/drive/MyDrive/documents/kaderetrack_datasets/yolov5n_rk3566.rknn'
import torch
import utils
display = utils.notebook_init()
!python export.py --weights yolov5s.pt --include onnx --imgsz 640 --opset 12 --simplify
I am using the rknn_model_zoo library to convert and test the model.
python convert.py ../model/yolov5s.onnx rk3588 i8 ../model/yolov5s_rk3588.rknn
The conversion from my ONNX model to rknn model is converted successfully but when I try to use the rknn model, the model's output seems to have a different size format than the post-processing expected in the yolov5.py script in the rknn_model_zoo examples.
python yolov5.py --model_path ../model/yolov5s_rk3588.rknn --img_save
ValueError: cannot reshape array of size 2142000 into shape (3,newaxis,25200,85). How can convert the model to be compatible to the script?