question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

convert pytorch model( pytorch_model.pt) to onnx

See original GitHub issue

i have, PROJECT(folder) ├── pytorch_model.bin ├── bert_config.json └── vocab.txt

i would like to convert it to model.onnx

thanks a lot.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TMVectorcommented, May 6, 2020

@pumpkinband I’m guessing your code is erroring on the line dummy_output = model(dummy_input)? What I meant was: the dummy input needs to be valid input.

You need to provide a valid model input from somewhere:

import torch
import torch.onnx

model = torch.load('./pytorch_model.pt')

dummy_input = XXX # You need to provide the correct input here!

# Check it's valid by running the PyTorch model
dummy_output = model(dummy_input)
print("Input is valid")

# If the input is valid, then exporting should work
torch.onnx.export(model, dummy_input, "pytorch_model.onnx")
0reactions
pumpkinbandcommented, May 8, 2020

i have graph.pbtxt i’ll try that !

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Convert a PyTorch Model to ONNX in 5 Minutes - Deci AI
Converting deep learning models from PyTorch to ONNX is quite straightforward. Start by loading a pre-trained ResNet-50 model from PyTorch's ...
Read more >
Convert your PyTorch training model to ONNX - Microsoft Learn
How to Convert your PyTorch model to the ONNX model format, ... To export a model, you will use the torch.onnx.export() function.
Read more >
Convert PyTorch Model to ONNX Model - Documentation
To convert a PyTorch model to an ONNX model, you need both the PyTorch model and the source code that generates the PyTorch...
Read more >
(optional) Exporting a Model from PyTorch to ONNX and ...
In this tutorial, we describe how to convert a model defined in PyTorch into the ONNX format and then run it with ONNX...
Read more >
Convert Your PyTorch Framework to ONNX Using Wallaroo
Wallaroo's integrated model conversion allows you to keep your preferred framework, such as PyTorch while maintaining a standardized ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found