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

ONNX Version #237

Closed
1 task done
adoksu opened this issue Apr 25, 2023 · 14 comments
Closed
1 task done

ONNX Version #237

adoksu opened this issue Apr 25, 2023 · 14 comments
Assignees
Labels
question A HUB question that does not involve a bug Stale

Comments

@adoksu
Copy link

adoksu commented Apr 25, 2023

Search before asking

Question

How to export the model to the ONNX format with the --Opset=15 flag?

Additional

No response

@adoksu adoksu added the question A HUB question that does not involve a bug label Apr 25, 2023
@kalenmike
Copy link
Member

@adoksu Thanks for the question. We are finalizing some changes to HUB that will allow you to set advanced flags for exports.

@ultralytics ultralytics deleted a comment from github-actions bot Apr 25, 2023
@kalenmike kalenmike self-assigned this Apr 25, 2023
@adoksu
Copy link
Author

adoksu commented Apr 25, 2023 via email

@kalenmike
Copy link
Member

kalenmike commented Apr 25, 2023

@adoksu Yes you can download the pytorch model from HUB and convert it into onnx with the ultralytics package:

pip install ultralytics
from ultralytics import YOLO

# Load a model
model = YOLO('path/to/weights.pt')  

# Export the model
model.export(format='onnx', opset=15)

You can find the available arguments here:
https://docs.ultralytics.com/modes/export/#arguments

@adoksu
Copy link
Author

adoksu commented Apr 25, 2023 via email

@adoksu
Copy link
Author

adoksu commented Apr 25, 2023 via email

@glenn-jocher
Copy link
Member

@adoksu to load a .pt model from your D: drive and export it via ultralytics, you need to provide the full path to the .pt file in the YOLO constructor. You can do this as follows:

from ultralytics import YOLO

# Load a model
model = YOLO('D:/path/to/weights.pt')  

# Export the model
model.export(format='onnx', opset=15)

Note that you need to use forward slashes (/) instead of backward slashes () in the file path.

@glenn-jocher
Copy link
Member

@adoksu to load a .pt model from your D: drive and export it via ultralytics, you can provide the full path to the .pt file in the YOLO constructor. Here's an example code snippet:

from ultralytics import YOLO

# Load a model
model = YOLO('D:/path/to/weights.pt')  

# Export the model
model.export(format='onnx', opset=15)

Make sure to use forward slashes (/) instead of backward slashes () in the file path. You can find more information on ultralytics in the official documentation at https://docs.ultralytics.com/.

@adoksu
Copy link
Author

adoksu commented Apr 25, 2023 via email

@glenn-jocher
Copy link
Member

@adoksu it seems that the path you provided for the .pt file is incorrect. Double-check the file path and make sure you are providing the correct path to the .pt file on your D: drive. Also, ensure that you are using forward slashes (/) instead of backward slashes () in the file path.

@adoksu
Copy link
Author

adoksu commented Apr 25, 2023 via email

@glenn-jocher
Copy link
Member

@adoksu it could be that the issue is related to the differences in file systems between your local machine and Google Colab. Try uploading the .pt file to Google Drive and mounting it in Colab, then access the file using the mounted drive instead of the local file path. Here is an example of how to mount Google Drive in Colab:

from google.colab import drive
drive.mount('/content/drive')

You can then access your Google Drive files using the path /content/drive/MyDrive/....

If the issue persists, please provide more details about the error message you are seeing.

@adoksu
Copy link
Author

adoksu commented Apr 26, 2023 via email

@kalenmike kalenmike assigned glenn-jocher and unassigned kalenmike Apr 26, 2023
@adoksu
Copy link
Author

adoksu commented Apr 26, 2023 via email

@github-actions github-actions bot added the Stale label May 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2023
@UltralyticsAssistant
Copy link
Member

@adoksu dear Okan,

It's great to hear that you were able to convert the model to ONNX format. Regarding the issue with the .NET C# application, it's possible that the conversion process may have introduced some discrepancies that are not compatible with the .NET ONNX runtime.

One suggestion would be to ensure that the ONNX model exported matches the version expected by the .NET application. Additionally, you might want to verify that the input and output tensors are correctly configured and that the preprocessing steps in your .NET application match those expected by the model.

If the model downloaded directly from Ultralytics works, you could compare the ONNX versions and operator sets used in both models to identify any differences. Ensuring consistency in these aspects could help resolve the issue.

For further assistance, you might also consider reaching out to the .NET community or the maintainers of the ONNX runtime you are using, as they might have more insights into the specific error message you're encountering.

@ultralytics ultralytics deleted a comment from github-actions bot Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A HUB question that does not involve a bug Stale
Projects
None yet
Development

No branches or pull requests

4 participants