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 org.tensorflow.lite.task.audio.classifier.AudioClassifier.initJniWithModelFdAndOptions(Native Method)
at org.tensorflow.lite.task.audio.classifier.AudioClassifier.access$000(AudioClassifier.java:74)
at org.tensorflow.lite.task.audio.classifier.AudioClassifier$1.createHandle(AudioClassifier.java:143)
at org.tensorflow.lite.task.audio.classifier.AudioClassifier$1.createHandle(AudioClassifier.java:136)
at org.tensorflow.lite.task.core.TaskJniUtils$1.createHandle(TaskJniUtils.java:70)
at org.tensorflow.lite.task.core.TaskJniUtils.createHandleFromLibrary(TaskJniUtils.java:91)
at org.tensorflow.lite.task.core.TaskJniUtils.createHandleFromFdAndOptions(TaskJniUtils.java:66)
at org.tensorflow.lite.task.audio.classifier.AudioClassifier.createFromFileAndOptions(AudioClassifier.java:134)
at org.tensorflow.lite.task.audio.classifier.AudioClassifier.createFromFile(AudioClassifier.java:91)
at com.samsung.classification.MainActivity.startAudioClassification(MainActivity.java:86)
at com.samsung.classification.MainActivity.lambda$showActivitySelectionDialogue$0$com-samsung-classification-MainActivity(MainActivity.java:51)
at com.samsung.classification.MainActivity$ExternalSyntheticLambda0.onClick(Unknown Source:2)
at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1485)
at android.widget.AdapterView.performItemClick(AdapterView.java:376)
at android.widget.AbsListView.performItemClick(AbsListView.java:1295)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3571)
at android.widget.AbsListView$3.run(AbsListView.java:4751)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
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?
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?
@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?
@George_Soloupis could you please help from where can I get the /gdrive/MyDrive/JWick/gun_shot_wav.zip 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.