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 model to onnxruntime #10

Open
vuhungtvt2018 opened this issue Dec 13, 2022 · 1 comment
Open

convert model to onnxruntime #10

vuhungtvt2018 opened this issue Dec 13, 2022 · 1 comment

Comments

@vuhungtvt2018
Copy link

how do you convert my model to onnxruntime?
please help me to resolve this problem!

@bayueyaoshao
Copy link

from models.unet import UNet
import torch
use_cuda = torch.cuda.is_available()
device = torch.device('cuda' if use_cuda else 'cpu')
model = UNet().to(device)
model_path = r"D:\Work\doc\RIAD\best.pt"
export_path = r"D:\Work\doc\RIAD\RIAD_model_320.onnx"
check_point = torch.load(model_path, map_location=device)
model.load_state_dict(check_point['model'])
inputs = torch.randn(1, 3, 320, 320)

if name == 'main':
torch.onnx.export(
model,
inputs,
export_path,
opset_version=12,
do_constant_folding=True,
input_names=['input'],
output_names=['output'],
dynamic_axes=None
)

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