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

Convert to ONNX and TensorRT #15

Open
pedrolsantos opened this issue Sep 23, 2024 · 2 comments
Open

Convert to ONNX and TensorRT #15

pedrolsantos opened this issue Sep 23, 2024 · 2 comments

Comments

@pedrolsantos
Copy link

Hi,
Is it possible to convert this model to ONNX or to TensorRT ?
The architecture of this model seems a bit exotic and I'm having trouble converting it to ONNX...
Any experience or information regarding this type of conversion ?

@xiongxyowo
Copy link
Collaborator

Hi, the following demo script works fine in my environment, you can check if it works fine in yours as well:

import torch
from SAM2UNet import SAM2UNet
model = SAM2UNet().cuda()
model.eval()
input_names = ["input_0"]
output_names = ["output_0","output_1","output_2"]
x = torch.randn((1,3,352,352)).cuda()
torch.onnx.export(model,(x,),'sam2unet.onnx',input_names=input_names,output_names=output_names,
                    dynamic_axes={'input_0':[0],'output_0':[0]})
print("Done")

@pedrolsantos
Copy link
Author

yes, this was very helpful
I managed to create the ONNX and exported to TensorRT
Got inference times around 11 ms with a 4060 TI
Thank you

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

No branches or pull requests

2 participants