ONNX object from PyTorch model without exporting

528 views Asked by At

Is it possible to convert the PyTorch Model to ONNX without exporting and further use it as an ONNX object directly in the script.

1

There are 1 answers

0
Sergii Dymchenko On

You can export to memory, something like this:

import io
f = io.BytesIO()
torch.onnx.export(model, sample_inputs, f, ...)
onnx_model = onnx.load_model_from_string(f.getvalue())