WongKinYiu / ScaledYOLOv4

Scaled-YOLOv4: Scaling Cross Stage Partial Network
GNU General Public License v3.0
2.02k stars 574 forks source link

Is there anyway I can convert csp pytorch trained model to ONNX? #270

Open huyhoangle86 opened 3 years ago

huyhoangle86 commented 3 years ago

Actually I'm struggling with this. I’m trying to export my trained model that in .pt format to ONNX but after I execute the script the program output bunch of logging stuff like in the pic below and the converted onnx format seems not appear in my local disk I don’t know what I got wrong here? I tried to give it full path but no luck.

image

And I just read a website it says about onnx " However, whenever a model contains control flow, like for loops or if statements, the tracer method will fail, simply because the tracer(onnx) is never aware of the existence of the control flow statements, it faithfully records the flow based on the supplied input." . Is that correct?

WongKinYiu commented 3 years ago

https://github.com/linghu8812/tensorrt_inference/tree/master/Yolov4

huyhoangle86 commented 3 years ago

@WongKinYiu oh Come on..... I'm using Scaled Yolov4 that was written in pytorch and .pt format I see that repo only support Darknet and .weights format.

WongKinYiu commented 3 years ago

just convert .pt to .weights by from models import *; convert('your.cfg', 'your.pt', 'your.weights')

huyhoangle86 commented 3 years ago

@WongKinYiu Thank you. The convert was successfully One more question. Do you know how do I inference the model that was just converted to Onnx format?

WongKinYiu commented 3 years ago

i do not know how to inference onnx model.

huyhoangle86 commented 3 years ago

thank you btw :D

jaideep11061982 commented 3 years ago

just convert .pt to .weights by from models import *; convert('your.cfg', 'your.pt', 'your.weights')

@huyhoangle86 @WongKinYiu could u please help understand this discussion.. Onnx is some thing new for me. I am usign Pytorch , do i need any weight conversion ?

huyhoangle86 commented 3 years ago

@jaideep11061982 No , you don't, just gg search for Onnx, try to convert if you feel interested in.

lantudou commented 2 years ago

@huyhoangle86 I hope it is still helpful for you even if it seems too late. https://github.com/WongKinYiu/ScaledYOLOv4/issues/371