Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export YOLOV8 models from Keras to onnx #2016

Open
AleksNet5 opened this issue Dec 9, 2024 · 5 comments
Open

Export YOLOV8 models from Keras to onnx #2016

AleksNet5 opened this issue Dec 9, 2024 · 5 comments
Assignees

Comments

@AleksNet5
Copy link

Hello everyone!
I’ve trying to export yolov8 models to other frameworks, to onnx and to tflite. I got some point in exporting to onnx but now model has very bad ocurasy.

If I try to convert it just by tf2onnx it gives me error about YOLOV8Detection layer.

@AleksNet5 AleksNet5 changed the title Export YOLOV8 models from Jerad to onnx Export YOLOV8 models from Keras to onnx Dec 10, 2024
@mehtamansi29 mehtamansi29 self-assigned this Dec 11, 2024
@mehtamansi29
Copy link
Collaborator

Hi @AleksNet5 -

Thanks for reporting the issue.

If I try to convert it just by tf2onnx it gives me error about YOLOV8Detection layer.

Can you help me with sample code for model creation or if possible share sample model and also error traceback to dig this issue more ?

@AleksNet5
Copy link
Author

Hello!
Sorry for delay, I have successfully converted model to onnx but it works correctly only with preprocessing with TF and imageio.v3 using:
Read by imageio
Resize_with_padding with tf
Add batch dimension with tf

Otherwise if I use code from YOLOV8 outputs decoding function I got zero results

@AleksNet5
Copy link
Author

Hi @mehtamansi29!
I think that it is core question, bc I now trying to make it work with decoding that I copied from YOLOV8 decoding functions, and with depthai. And I get zero outputs, even though I tested it in onnx and it suppose to work the same in their framework
The only thing is input parameters, I need to specify mean, scale values and channels order(rgb or bgr) for the NN input

Copy link

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Dec 29, 2024
@mehtamansi29
Copy link
Collaborator

Hi @AleksNet5 -

Sorry for the delay. Here you can export the Yolov8 models from other frameworks to onnx or tflite :

from ultralytics import YOLO
model = YOLO("yolov8n.pt")
#export yolo model to onnx
model.export(format="onnx", dynamic=True,  opset=13)
# export model to tflite
model.export(format="tflite")

Attached gist here fro reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants