Giter Site home page Giter Site logo

joshuacwnewton / onnx-to-tflite Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 4.0 23.95 MB

Converting the ONNX model representation to the TensorFlow Lite representation.

Home Page: https://colab.research.google.com/github/joshuacwnewton/ONNX-to-TFLite/blob/master/onnx_to_tflite.ipynb

Jupyter Notebook 100.00%
deep-learning machine-learning matlab neural-network onnx onnx-tf tensorflow tensorflow-examples tensorflow-lite tensorflow-tutorials tflite

onnx-to-tflite's Introduction

Hi! I'm an open source maintainer working for the NeuroPoly research lab at Polytechnique Montreal. ๐Ÿ‘‹

For the past 3 years, I've maintained the Spinal Cord Toolbox, a highly-regarded Python-based software package in a niche, data-driven research field. Our user base is small but meaningful; we serve the needs of medical researchers by providing them with a wealth of spinal cord image processing tools, with our work serving as the backbone for countless vital clinical studies published in many high-impact journals.

onnx-to-tflite's People

Contributors

joshuacwnewton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

onnx-to-tflite's Issues

ValueError: Invalid tensors 'input' were found.

All works fine till using

converter = tf.compat.v1.lite.TFLiteConverter.from_saved_model(pb_path,
                                                      input_arrays=input_nodes,
                                                      output_arrays=output_nodes,
                                                               )
tflite_rep = converter.convert()

log

[/usr/local/lib/python3.10/dist-packages/tensorflow/lite/python/util.py](https://localhost:8080/#) in get_tensors_from_tensor_names(graph, tensor_names)
    164   # Throw ValueError if any user input names are not valid tensors.
    165   if invalid_tensors:
--> 166     raise ValueError("Invalid tensors '{}' were found.".format(
    167         ",".join(invalid_tensors)))
    168   return tensors

ValueError: Invalid tensors 'input' were found.

Stuck in step 2.2 while running on Colab

Step 2.2 is currently not only spitting warnings, it seems to not work at all unfortunately:

import onnx
from onnx_tf.backend import prepare

onnx_model = onnx.load(onnx_path)
tf_rep = prepare(onnx_model)

results in:

/usr/local/lib/python3.7/dist-packages/tensorflow_addons/utils/ensure_tf_install.py:67: UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.3.0 and strictly below 2.5.0 (nightly versions are not supported). 
 The versions of TensorFlow you are currently using is 1.15.2 and is not supported. 
Some things might work, some things might not.
If you were to encounter a bug, do not file an issue.
If you want to make sure you're using a tested and supported configuration, either change the TensorFlow version or the TensorFlow Addons's version. 
You can find the compatibility matrix in TensorFlow Addon's readme:
https://github.com/tensorflow/addons
  UserWarning,
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-f6cf1dfe42ba> in <module>()
      1 import onnx
----> 2 from onnx_tf.backend import prepare
      3 
      4 onnx_model = onnx.load(onnx_path)
      5 tf_rep = prepare(onnx_model)

7 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_addons/utils/types.py in <module>()
     21 
     22 # TODO: Remove once https://github.com/tensorflow/tensorflow/issues/44613 is resolved
---> 23 from tensorflow.python.keras.engine import keras_tensor
     24 
     25 

ImportError: cannot import name 'keras_tensor' from 'tensorflow.python.keras.engine' (/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.