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 model to tflite model

See original GitHub issue

I want to run this code on raspberry pi 4. In the first step, I should convert this model to tflite model. I use the following link https://www.tensorflow.org/lite/convert/index to convert the model but it raises the following error. OSError: SavedModel file does not exist at: ./models/mobilenet-float16-stride16/{saved_model.pbtxt|saved_model.pb}

I also use the following code for model conversion python -m tf_bodypix \ convert-to-tflite \ --model-path \ "https://storage.googleapis.com/tfjs-models/savedmodel/bodypix/mobilenet/float/075/model-stride16.json" \ --optimize \ --quantization-type=float16 \ --output-model-file "./mobilenet-float16-stride16.tflite" it works and the model convert to tflite but when I want to use it in tensorflow lite based on this link https://www.tensorflow.org/lite/guide/inference, I found that the input model dimension is array([1, 1, 1, 3], dtype=int32). Can you help me to solve this problem?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
MrRiahicommented, Dec 15, 2021

I created a pull request in the past few days.

1reaction
de-codecommented, Nov 23, 2021

What if you try to use the tflite model with tf-bodypix? If you pass a file ending with .tflite to the load_model method, then it should use the tflite API. You should also be able to use the CLI.

You can find the implementation in the code: https://github.com/de-code/python-tf-bodypix/blob/v0.3.8/tf_bodypix/model.py#L455-L504

The ranks of the input shapes are not always the same, and sometimes it is a 4D tensor, sometimes a 3D tensor (depending on the conversion method). If it is a 4D tensor and you can simply resize the tensor to make it 4D. In that case the first dimension will typically be the batch size. The other feature of tflite or the model is that the width and height is dynamic. With tflite you need to resize the actual tensor (see linked code block).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Model conversion overview | TensorFlow Lite
The TensorFlow Lite converter takes a TensorFlow model and generates a TensorFlow Lite model (an optimized FlatBuffer format identified by the .
Read more >
Tensorflow Lite Converter Example!! | by Maheshwar Ligade
TFLite converter to Convert different tensorflow model on edge devices, mobile devices or embedded devices.
Read more >
TensorFlow Lite converter
The TensorFlow Lite converter takes a TensorFlow model and generates a TensorFlow Lite model (an optimized FlatBuffer format identified by the .tflite file ......
Read more >
Convert your Tensorflow Object Detection model to ...
1. Train an object detection model using the Tensorflow Object Detection API · 2. Convert the model to Tensorflow Lite · 3. Run...
Read more >
How to convert python model to TensorFlow Lite - Mobikul
import tensorflow as tf ; # Convert the model ; converter = tf.lite.TFLiteConverter.from_saved_model(fruits_dir) ; tflite_model = converter.convert() ; # Save the ...
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