All Questions
Tagged with tf.keras tensorflow-lite
27
questions
8
votes
3
answers
7k
views
Keras Model AttributeError: 'str' object has no attribute 'call'
I'm trying to convert my Keras hdf5 file into a TensorFlow Lite file with the following code:
import tensorflow as tf
# Convert the model.
converter = tf.lite.TFLiteConverter.from_keras_model("/...
6
votes
3
answers
17k
views
ValueError: Expect x to be a non-empty array or dataset (Tensor Flow lite model maker on Collab)
I am following this tutorial on creating a custom Model using TensorFlow lite Model Maker on Collab.
import pathlib
path = pathlib.Path('/content/employee_pics')
count = len(list(path.glob('*/*.jpg'))...
5
votes
0
answers
665
views
How to convert trained in custom loop subclassed tf.keras.model to tflite?
I have a problem with converting trained subclassed model (tf.keras.Model) in custom loop to TFLite.
Suppose we have small CNN architecture that use input data (x) and additional information that ...
4
votes
1
answer
1k
views
Why is inference using tf.keras 75x slower than using TFLite?
I run a code making some predictions on audio data using a simple CNN.
When using tf.keras.Model.predict I get an an average execution time of 0.17s, and when I use TF.lite.Interpreter I get 0.002s, ...
3
votes
0
answers
510
views
issue with converting the model from colab to tf.keras h5 model
I'm having a really hard time converting this model to s h5 model so I can then convert it to Tensorflow lite Someone managed to do that. I shared the colab here:
I really appreciate any help that ...
2
votes
1
answer
4k
views
ValueError: None is only supported in the 1st dimension. Tensor 'flatbuffer_data' has invalid shape '[None, None, 1, 512]'
I am trying to convert my tensorflow model (2.0) into tensorflow lite format. My model has two input layers as follows:
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras....
2
votes
2
answers
2k
views
How to tokenize input text in android studio to process in NLP model?
When I created NLP model, I used keras tokenizer to tokenize my training data. So every word in training data has a number associated with it. Now I want to run the model in android app. So I ...
2
votes
1
answer
2k
views
Converting Keras RNN model to TensorFlow Lite model in TF2
I am currently trying to convert a RNN model to TF lite. After multiple failed attempts I tried running the example given in the repository found here. This threw errors too due to changes in the ...
2
votes
0
answers
510
views
Memory Leakage tflite models
I have a tensorsorflow lite model (keras) in a flutter application that segments objects in an image (model is trained only on one specific object). With this model I can make 50-60 predictions ...
1
vote
1
answer
414
views
tf.keras HDF5 Model and Keras HDF5 Model
I want to convert a Keras model to Tensorflow Lite model. When I examined the documentation, it is stated that we can use tf.keras HDF5 models as input. Does it mean I can use my saved HDF5 Keras ...
1
vote
0
answers
15
views
Converting .xls data to Python data types to be used as an input of a Tensorflow Lite model
I've captured and saved accelerometer values to an xls worksheet. I want to use these as an input to a Tensorflow Lite model but I'm struggling to do the required data conversions.
A simplified ...
1
vote
0
answers
336
views
TypeError: ('Keyword argument not understood:', 'query_shape') with keras and tensorflow version 2.6.0, implementing a VIT
I am having this issue with the transformation of my model from ".pb" to ".tflite".
The code is the following:
# From PB to h5 -- then load from h5
checkpoint_filepath="drive/...
1
vote
1
answer
367
views
TFLite: `ValueError: Model input is not quantized.`
Problem
I try to convert the crop_and_resize operation to TFLite. I am using the script below. But the conversion fails and the error ValueError: Model input is not quantized. is raised.
Does someone ...
1
vote
0
answers
959
views
Convert Keras Stateful GRU to TFLite Model?
I've got a basic Keras model with a GRU layer where stateful=True. I want to convert my model to a TFLite model and make predictions on data one element at a time, i.e a sequence will be fed to the ...
1
vote
0
answers
567
views
error while converting keras model with 2 input to tflite
I am trying to convert a tf2.keras model to tflite, but get the following error:
ValueError: Invalid input size: expected 2 items got 1 items.
my network is Siamese - it has 2 inputs that both are ...
1
vote
1
answer
2k
views
tflite converter from a custom keras layer
I'm getting a TypeError when trying to convert a keras .h5 file to tflite.
The new layer is a gaussian kernel (Radial Basis Layer).
To be able to save and load the keras model I defined also the ...
0
votes
1
answer
583
views
Convert tf_hub models to tflite
I'm trying to convert a tf_hub model (MUSE) to tflite, but I'm getting a FileNotFoundError which is very strange, and I have no idea how to interpret the error message. Here are my code and the error ...
0
votes
2
answers
4k
views
input_tensor and output_tensor for TFLiteConverter.from_session gives TypeError (Tensor objects are only iterable when eager execution is enabled.)
I am trying to make tflite file of a model while using quantization aware training. I'm making and training the model in keras but I've run into trouble saving it (https://github.com/tensorflow/...
0
votes
1
answer
78
views
TensorFlow Lite converter representative_dataset for Conv2D on accelerometer data
I have a TensorFlow Keras model that looks something like this. Note that this model is too big to run on a microcontroller which is my end goal but this is a starting point. The end goal is to get ...
0
votes
1
answer
310
views
TfLite: Why is from_saved_model() recommended over from_keras_model()?
The tensorflow guide about the Tensorflow Lite Converter states that using TFLiteConverter.from_saved_model() is recommended over TFLiteConverter.from_keras_model().
Why is it recommended?
And what ...
0
votes
0
answers
103
views
RuntimeError: Encountered unresolved custom op: FarthestPointSample
Provide the text output from tflite_convert
I did try pointnet++ https://github.com/charlesq34/pointnet2 , and tried to inference with tf.lite or tflite-runtime, but both of them show the error ...
0
votes
1
answer
155
views
How to do tf.reshape with shape dynamiclly?
i am working on tensorflow 2.x. I want to accept an Integer as one of the Multi-Inputs, and in some stage of the model, i need to do tf.reshape with shape set by the Integer of Input. It is more like:
...
0
votes
0
answers
132
views
Lost connection to device when loading a tflite model flutter
Although I've connected another model in the same code and it works fine. When loading this model, The device gets disconnected. Anybody know what could be wrong? Is it the dimensions entered or is it ...
0
votes
1
answer
2k
views
Model object has no attribute '_is_graph_network', when I try to save my model to tflite
Tensorflow version - 1.14.0
Python version - 3.7.5
This is the model I created
from tensorflow import keras
import tensorflow.python.keras.backend as K
from tensorflow.python.keras import callbacks
...
0
votes
1
answer
394
views
Tensorfow-lite PReLU Fusion and TransposeConv Bias
When we convert a tf.keras model with PReLU with tf 1.15, the PReLU layers becomes ReLU and seem to get fused with previous operators. As a result, the keras h5 file of 28 MB becomes 1.3 MB in size.It ...
0
votes
1
answer
383
views
TFLite: Is it possible to convert a H5 model but with a different input shape using Keras' load_model?
I currently use this script to convert my H5 model to TFLite:
# CONVERTING TO TFLITE FORMAT
g.save(os.path.join(save_dir, 'full_generator_{}_{}.h5'.format(epoch_number, current_loss)), ...
0
votes
1
answer
638
views
tensorflow to tflite - tflite_converted fails with "Axis 0 computes to size 0 for StridedSlice" when converting from .pb to .tflite
I'm having an issue when converting from a saved .pb Tensorflow model to a .tflite Tensorflow Lite model using the Tensorflow (1.13.1) built-in tflite_convert tool, and I was wondering how I might go ...