Salad Detection Model Crashing Android App


I’m using the example Android app from Build and Deploy a Custom Object Detection.

I’m having problems with the App crashing while using the salad detector model that is trained using the Colab tutorial here:

When using other generic tflite models the app works fine.

Here is an example of a working and not working tflite model

Working - generic-working.tflite - Google Drive
Not Working - salad-detector-not-working.tflite - Google Drive

I have tried turning off compression in the gradle

    aaptOptions {
        noCompress "generic.tflite"

From what I’ve read this might have something to do with colab using the latest version of model maker (rather than 2.5)

Any help on how to get this Collab to work would be greatly appreciated. Or maybe even just inspecting the two tflite models to determine why one works and one doesn’t?

Might is have something to do with the meta data of the files?

Any help, greatly appreciated.



On further inspection of working and non working models in Netron do we think the order of these outputs might be incorrect? (In red box on attached image)

Side by side meta data

I seem to recall reading this in a different post somewhere in the forum.

Can anyone provide some instructions on how to change this output order?

Do you mean this one:

Hey Bhack,

Yeah thats the post. I did try all the problem solving that Winton went through, finishing up with his post in Nov 21

Post #24

I can’t seem to figure out how these instructions work. If anyone has some further elaboration on these steps?

Maybe someone has a bit of a guide of getting a Colab to work with TF 2.5 without having the compatibility errors that come up from other dependencies when using TF 2.5?


This is due to the order of output changed after tf 2.6. If you are using task library in your android app, please update to the latest version.

1 Like

Hi Yuqi,

Thanks for the reply :grinning:

I have updated to 0.3.0 as below

implementation 'org.tensorflow:tensorflow-lite-task-vision:0.3.0'

But am still having the app crash with recently trained models.

I’m currently using a modified version of the collab Salad Detection App so the Task Library build variants arent the same (are possibly not being used) as they are in other example app builds I’ve played around with.

Any other tips to change the class output order or to install tf 2.5 and avoid dependency clashes?

The order is handled by the tensor name in TFLite metadata. Please see code tflite-support/ at master · tensorflow/tflite-support · GitHub for more detail.

Alternatively, you can use tf 2.5 instead to handle the output issue as you mentioned.