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

Custom model cannot export onnx from pt file #13126

Closed
1 task done
thinker310 opened this issue May 25, 2024 · 3 comments
Closed
1 task done

Custom model cannot export onnx from pt file #13126

thinker310 opened this issue May 25, 2024 · 3 comments
Labels
question Further information is requested Stale

Comments

@thinker310
Copy link

Search before asking

Question

I add a new moudule into YOLOv8 and trained it. The pretrained model was saved as a .pt file and I want to export it to .onnx file. But an IndexError happended as the picture showed below:
image
the convert code as follows:
from ultralytics import YOLO
model=YOLO('./best.pt')
model.export(format='onnx',opset=17)
Additionally, I tried many arguments (opset=17,16,15... or imgsz=[640,640]) for exporting but it didnot work.
Could you help me? Thank you in advance!

Additional

No response

@thinker310 thinker310 added the question Further information is requested label May 25, 2024
Copy link

👋 Hello @thinker310, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

Hi there! 👋

It looks like you're encountering an issue with exporting your custom YOLOv8 model to ONNX. The error might be related to the new module you added. Here's a quick suggestion to help you troubleshoot:

  1. Check the Custom Module: Ensure that the custom module you added is compatible with ONNX export. Some PyTorch operations may not be supported by ONNX.

  2. Simplify the Export: Try exporting without additional arguments first to see if the basic export works:

    from ultralytics import YOLO
    
    model = YOLO('./best.pt')
    model.export(format='onnx')
  3. Debugging: If the error persists, you might want to isolate the issue by removing the custom module temporarily and trying the export again.

If you continue to face issues, please share more details about the custom module or any specific operations it includes. This will help us provide more targeted assistance.

Good luck, and feel free to reach out if you need further help! 😊

Copy link

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale label Jun 26, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants