You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
YOLOv5-Lite (onnx)(v1.5版本 5月22日) 类似报错:1.ValueError: operands could not be broadcast together with shapes (3,2,80,85) (19200,2) 2. IndexError: index 4 is out of bounds for axis 0 with size 3
#263
Open
inbigtoiletboy opened this issue
May 28, 2024
· 6 comments
报错流程:
1. 使用 YOLOv5-Lite 中 train.py 训练了一个 best.pt
2. 在 export.py 中转换为 best.onnx 模型
3. (第一种报错)使用 python_demo/onnxruntime/v5lite.py 进行推理,报了以下错误:
原因是 best.onnx 的模型输出不匹配(大家可以使用
https://netron.app/
查看自己训练的模型)/----------------第一种报错的解决方法----------------/
第一步:在
2. 在 export.py 中转换为 best.onnx 模型
这一步中,使用 end2end 导出 :假设 你原本是这样运行 export.py 的
那么使用 end2end 导出就是在后面加上 --end2end 如:
这样你的 best.onnx 的输出格式就正确了,如下图:
第二步:修改 python_demo/onnxruntime/v5lite.py 中的代码:
将其全部复制粘贴到 python_demo/onnxruntime/v5lite.py 中,
修改完各项参数后,就可以进行推理了
运行 v5lite.py 结果如图:
推理之后的图片在 python_demo/onnxruntime/save.jpg
如果你(2024/5/20 之前下载的YOLOv5-Lite)通过以上代码无法解决你的问题,你可以重新下载 YOLOv5-Lite.zip
/-------------------------------------------------------------/
第二种报错如下:
如果你也遇到了这样的报错,那你大概率看过这篇文章:
报错原因:
这篇文章的作者使用的摄像头画面推理程序是改写 当时YOLOv5-Lite 中的代码,时间已经过去很久了,
所以不可以使用现在训练出来的 onnx模型 去跑当时的代码。
/----------------第二种报错的解决方法----------------/
首先要解决第一个报错之后,再解决第二个报错
重新写 摄像头画面推理程序
其实很简单,把现在的 python_demo/onnxruntime/v5lite.py 中的
class yolov5_lite() {...}
的代码粘贴到 原来的摄像头画面推理程序 的代码中,然后再照着v5lite.py改一下 main函数 就好了,非常的简单我在此声明:下面的图片是我识别音游的画面,只是用来学习(因为识别出来的画面感很强),所以不会用于制作外挂。
抵制外挂,从你我做起
以下是改完之后的代码,我不建议复制粘贴直接用,自己也试着写写,你可以的
/-------------------------------------------------------------/
以上就是全部内容了
感谢 YOLOv5-Lite 作者 pogg 的大力帮助,非常感谢。
The text was updated successfully, but these errors were encountered: