2

I have yolo model as yolov5s.yaml and i have saved my weights file as best.pt . Now want to convert yolo model to ONNX and run on c++ interface . I have gone through this https://github.com/ultralytics/yolov5/issues/251 but not able to do .Any help or useful resources will be helpful . Thanks

k_p
  • 283
  • 6
  • 17

2 Answers2

0

I could run the example mentioned in https://github.com/ultralytics/yolov5/issues/251 successfully. My torch version is 1.8.0.

Probably your weights file best.pt has invalid values. Did you ever try to use the weights file in above link to export the module successfully?

BTW: you can find examples in https://github.com/microsoft/onnxruntime/tree/master/samples/c_cxx for usage of ONNXRuntime C++ api to run it.

Jay Zhang
  • 1
  • 1
  • in the first link no examples is being seen by me can specify any link or resources that will be helpful for me . Weight file i.e. best.pt is correct because it is giving predictions correct but wanna run same in onnx inference . Thanks for help any link or your example will be more useful for me . – k_p May 17 '21 at 09:13
0

I tried run the examples provided in the first link successfully, the statements are: git clone github.com/ultralytics/yolov5 # clone repo cd yolov5 pip install -r requirements.txt # base requirements pip install coremltools>=4.1 onnx>=1.9.0 scikit-learn==0.19.2 # export requirements python models/export.py --weights yolov5s.pt --img 640 --batch 1 # export at 640x640 with batch size 1

It shows the export was successfully. The weight file in above example is yolov5s.pt. What kind of errors did you get by running these statements with your best.pt file?

Jay Zhang
  • 1
  • 1