yolov5 detect.py 调用onnx报错

PS D:\deep_learning\yolov5-master> D:\anaconda3\envs\pytorch\python.exe D:/deep_learning/yolov5-master/detect.py --weights side_defect.onnx --source D:\dee
p_learning\side_defect_val_img --device 0

PS D:\deep_learning\yolov5-master> D:\anaconda3\envs\pytorch\python.exe D:/deep_learning/yolov5-master/detect.py --weights side_defect.onnx --source D:\dee
p_learning\side_defect_val_img --device cpu

 

File "D:\anaconda3\envs\pytorch\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 370, in _create_inference_session
sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from side_defect.onnx failed:D:\a\_work\1\s\onnxruntime\core/g
raph/model_load_utils.h:57 onnxruntime::model_load_utils::ValidateOpsetForDomain ONNX Runtime only *guarantees* support for models stamped with official re
leased onnx opset versions. Opset 17 is under development and support for this is limited. The operator schemas and or other functionality may change befor
e next ONNX release and in this case ONNX Runtime will not guarantee backward compatibility. Current official support for domain ai.onnx is till opset 16.

使用export.py导出onnx的版本过高,修改导出版本即可

image

 参考:

https://txwtech.blog.csdn.net/article/details/154686374

导出方法:

https://www.cnblogs.com/txwtech/p/18816066

 

posted @ 2025-11-11 09:23  txwtech  阅读(13)  评论(8)    收藏  举报