Questions tagged [onnx]

ONNX is an open format to represent deep learning models and enable interoperability between different frameworks.

ONNX

The Open Neural Network Exchange (ONNX) is an open-source artificial intelligence ecosystem. With ONNX, AI developers can more easily move models between state-of-the-art tools and choose the combination that is best for them. ONNX is widely supported and can be found in many frameworks, tools, and hardware. It is developed and supported by a community of partners.

Official resources

809 questions
4
votes
1 answer

Change input size of ONNX model

I need to change the input size of an ONNX model from [1024,2048,3] to [1,1024,2048,3]. For this, I've tried using update_inputs_outputs_dims by ONNX import onnx from onnx.tools import update_model_dims model =…
Rani
  • 483
  • 7
  • 17
4
votes
1 answer

How to use onnxruntime with .ort model in Android Studio

I'm trying to create an Android App that incorporates a Machine Learning Model. I had an onnx model, along with a Python script file, two json files with the label names, and some numpy data for mel spectrograms computation. I tried to go with…
4
votes
1 answer

while exporting T5 model to onnx using fastT5 getting "RuntimeError:output with shape [5, 8, 1, 2] doesn't match the broadcast shape [5, 8, 2, 2]"

i'm trying to convert T5 model to onnx using the fastT5 library, but getting an error while running the following code from fastT5 import export_and_get_onnx_model from transformers import AutoTokenizer model_name = 't5-small' model =…
4
votes
0 answers

RuntimeError: Exporting the operator cdist to ONNX opset version 9 is not supported

I want to convert Prototypical Networks for Few-shot Learning to onnx. Export onnx: torch.onnx.export(model,(example_query_images, example_query_labels, x_pred), "super_resolution.onnx") And it raise error 'RuntimeError: Exporting the operator…
evirdthk
  • 41
  • 1
4
votes
1 answer

Converting ONNX model to TensorFlow Lite

I've got some models for the ONNX Model Zoo. I'd like to use models from here in a TensorFlow Lite (Android) application and I'm running into problems figuring out how to get the models converted. From what I've read, the process I need to follow is…
Joel
  • 2,230
  • 1
  • 20
  • 28
4
votes
1 answer

Why use Caffe2 or Core-ML instead of LibTorch(.pt file) on iOS?

It seems like there are several ways to run Pytorch models on iOS. PyTorch(.pt) -> onnx -> caffe2 PyTorch(.pt) -> onnx -> Core-ML (.mlmodel) PyTorch(.pt) -> LibTorch (.pt) PyTorch Mobile? What is the difference between the above methods? Why…
Kjyong
  • 195
  • 1
  • 8
4
votes
2 answers

How to convert Tensorflow 2.* trained with Keras model to .onnx format?

I use the Python 3.7.4 with TensorFlow 2.0 and Keras 2.2.4-tf to train my own CNN model. Everything goes fine. I can use e.g. model.save(my_model), and then use it in other Python scripts. Problem appears when I want to use trained model in OpenCV…
Mimi
  • 95
  • 1
  • 10
4
votes
1 answer

Best way to run a trained PyTorch LSTM/GRU model fully in the browser

I'm looking into running a trained PyTorch model (containing LSTM/GRU layers) fully in the browser (no backend) as part of an interactive blog post. I've looked at ONNX.js, and that works great, but not for a model containing a GRU layer. I saw…
Bart
  • 1,077
  • 1
  • 12
  • 22
4
votes
1 answer

Create Tensors from Image for ONNX.js

I am trying to use ONNX.js to run a ONNX object detection model in browser. I know that in Tensorflow.js you have to pass only an Image Object to model and Tensorflow automatically create Tensor required by the model, but in ONNX we have to create…
Aakash Bhadana
  • 302
  • 2
  • 17
4
votes
1 answer

Convert onnx model to keras

I try to convert an ONNX model to Keras, but when I call the conversion function I receive the following error message "TypeError: unhashable type: 'google.protobuf.pyext._message.RepeatedScalarContainer'" ONNX Model Input: input_1 You can see the…
Emanuel Covaci
  • 81
  • 2
  • 2
  • 4
4
votes
1 answer

Convertion of tflite model to ONNX model

I have a tflite model and i want to convert it into tensorflow or keras or ONNX format. Is there a way? I can import it using tf interpreter and run it on python. However i want to convert it into one of the above formats. import tensorflow as…
Sachin A
  • 41
  • 2
4
votes
3 answers

Trouble Converting LSTM Pytorch Model to ONNX

I am trying to export my LSTM Anomally-Detection Pytorch model to ONNX, but I'm experiencing errors. Please take a look at my code below. Note: My data is shaped as [2685, 5, 6]. Here is where I define my model: class Model(torch.nn.Module): def…
Shawn Zhang
  • 1,719
  • 2
  • 14
  • 20
4
votes
2 answers

How to obtain input data from ONNX model?

I have exported my PyTorch model to ONNX. Now, is there a way for me to obtain the input layer from that ONNX model? Exporting PyTorch model to ONNX import torch.onnx checkpoint =…
Shawn Zhang
  • 1,719
  • 2
  • 14
  • 20
3
votes
0 answers

tf_rep.export_graph() gives me KeyError: 'input.1'

I've written pytorch model,than converted it to .onnx format, buit a tf representation, tried to convert it to tflite and while exporting graph error occured this is how I saved the model and converted it to .onnx: (LeNet5 is the name of the model…
3
votes
1 answer

Convert TensorFlow to ONNX: Current implementation of RFFT or FFT only allows ComplexAbs as consumer not {'Imag', 'Real'}

I am trying to convert this TensorFlow model to onnx. But I get an error message: > python -m tf2onnx.convert --saved-model .\spice --output model.onnx --opset 11 --verbose ... 2023-04-08 18:33:10,811 - ERROR - tf2onnx.tfonnx: Tensorflow op [Real:…
mihca
  • 997
  • 1
  • 10
  • 29