Input tensor 0 is missing TensorMetadata

This article shows how to add meta_data into a tflite model before running in Android. However, it only shows example for Image classification. I am trying to add meta data for Audio classification. How can I get guide.

I am getting error in Android when running a model.tflite which has no meta data.

Error getting native address of native library: task_audio_jni
java.lang.IllegalArgumentException: Error occurred when initializing AudioClassifier: input tensor 0 is missing TensorMetadata.
at Method)
at org.tensorflow.lite.task.core.TaskJniUtils$1.createHandle(
at org.tensorflow.lite.task.core.TaskJniUtils.createHandleFromLibrary(
at org.tensorflow.lite.task.core.TaskJniUtils.createHandleFromFdAndOptions(
at$ExternalSyntheticLambda0.onClick(Unknown Source:2)
at android.widget.AdapterView.performItemClick(
at android.widget.AbsListView.performItemClick(
at android.widget.AbsListView$
at android.widget.AbsListView$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loopOnce(
at android.os.Looper.loop(

Hi @hissain

Is your python code working ok before trying to convert it to .tflite? What example have you used to train the model? Have you used TF Model Maker or a different approach?
The code for inserting the metadata is the same as the one you have provided. Can you share more info about the normalization and the other info for your model that must be added?

Check here some examples with the TF Lite Model Maker that adds the metadata automatically

Here is the example how TF Lite Model Maker is adding the parameters inside the model.

You can se also which are the parameters based on if it is YamnetSpec or BrowserFftSpec

It was working OK in the same Notebook as I have found evaluation score at around 90% accuracy. I was trying to install tflite_model_maker however, it is failing to install because of dependency conflicts with tflite_support. Is there any guideline on it?

Please refer to the issue I am facing. python - ERROR: Cannot install tflite-model-maker (The conflict is caused by other modules) - Stack Overflow

It is an known issue. Please refer to Future of tflite-model-maker and mediapipe-model-maker or take a look a recent example I wrote
Use TensorFlow Lite Model Maker with a custom dataset | by George Soloupis | Nov, 2023 | Medium
Inside there you can find a python notebook with example of using a conda env inside Colad.


@George_Soloupis your blog provides examples for unix systems. I was trying to run same but tflite model maker installing for indefinite time and storage gets full. Any other suggestions?

@hissain The example is working OK inside a Colab session.
No other suggestions I can think of.

@George_Soloupis can you share any working notebook? I have same issue in colab notebook as well.

Inside the blog post there is a link to a notebook…just before the code snippets

@George_Soloupis could you please help from where can I get the /gdrive/MyDrive/JWick/ file? I was trying to run the colab and it failed to unzip because I have no zip file in my drive. Here is my notepad copied from your git.

All you need to use is inside the blog post!