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

OnnxSlim support #12681

Open
2 tasks done
inisis opened this issue May 14, 2024 · 14 comments
Open
2 tasks done

OnnxSlim support #12681

inisis opened this issue May 14, 2024 · 14 comments
Labels
enhancement New feature or request

Comments

@inisis
Copy link
Contributor

inisis commented May 14, 2024

Search before asking

  • I have searched the YOLOv8 issues and found no similar feature requests.

Description

Hi, we have developed a tool called onnxslim, which can help slim exported onnx model, and it's pure python, and it works well on yolo, should we intergrate it into awesome ultralytics.

Use case

when export to onnx, we can use onnxslim to slim our exported model

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@inisis inisis added the enhancement New feature or request label May 14, 2024
Copy link

👋 Hello @inisis, 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.

@inisis
Copy link
Contributor Author

inisis commented May 14, 2024

@glenn-jocher Can you take a look, I have tested on yolov8n model, and it works really good for reducing number of operators.

image

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@inisis does OnnxSlim also speed up for TensorRT (since model have to be convert to onnx first) ?

@inisis
Copy link
Contributor Author

inisis commented May 14, 2024

@inisis does OnnxSlim also speed up for TensorRT (since model have to be convert to onnx first) ?

I do believe so, onnxslim depends on nv onnx-graphsurgeon, but have better perfromance.

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@inisis does OnnxSlim also speed up for TensorRT (since model have to be convert to onnx first) ?

I do believe so, onnxslim depends on nv onnx-graphsurgeon, but have better perfromance.

does it works with onnx-simplify?

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@inisis I will make a pull request to apply this in the export function

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@inisis pull request for the integration, thanks for the tool :)

@inisis
Copy link
Contributor Author

inisis commented May 14, 2024

@Kayzwer Hi, CI failed, but I think it's not a problem with onnxslim, and how can I compare the performance with/without onnxslim, and one thing to mention, onnxslim can be used in arm devices.

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@Kayzwer Hi, CI failed, but I think it's not a problem with onnxslim, and how can I compare the performance with/without onnxslim, and one thing to mention, onnxslim can be used in arm devices.

from ultralytics import YOLO

model = YOLO("yolov8n.pt")
model.export(format="onnx", slim=True) # slimmed

model.export(format="onnx")

@Kayzwer
Copy link
Contributor

Kayzwer commented May 14, 2024

@Kayzwer Hi, CI failed, but I think it's not a problem with onnxslim, and how can I compare the performance with/without onnxslim, and one thing to mention, onnxslim can be used in arm devices.

from ultralytics import YOLO

model = YOLO("yolov8n.pt")
model.export(format="onnx", slim=True) # slimmed

model.export(format="onnx")

make sure to rename the output onnx model and run the functions separately

@inisis
Copy link
Contributor Author

inisis commented May 14, 2024

@Kayzwer Hi, CI failed, but I think it's not a problem with onnxslim, and how can I compare the performance with/without onnxslim, and one thing to mention, onnxslim can be used in arm devices.

from ultralytics import YOLO

model = YOLO("yolov8n.pt")
model.export(format="onnx", slim=True) # slimmed

model.export(format="onnx")

make sure to rename the output onnx model and run the functions separately

@Kayzwer thank you! But I think I have seen the benchmark performance before, and it's generated by CI.

@inisis
Copy link
Contributor Author

inisis commented May 15, 2024

@inisis pull request for the integration, thanks for the tool :)

@glenn-jocher can you please review it

@glenn-jocher
Copy link
Member

@inisis Thanks for the heads up! The PR is on Glenn's radar, and he'll review it as soon as possible. Thanks for your contribution! 🚀

@Kayzwer
Copy link
Contributor

Kayzwer commented May 15, 2024

@inisis Thanks for the heads up! The PR is on Glenn's radar, and he'll review it as soon as possible. Thanks for your contribution! 🚀

thanks LLM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants