I think I’ve got it all sussed in my head now and might lay it out here for anyone that stumbles across this thread later on trying to fix the Salad Detector example Android app crashing with custom trained models. This information is relevant for anyone doing this after Nov 2021.
This is the tutorial to follow if you are looking to build an Android app using a transfer learned model - known as a the Salad Detector tutorial.
The Android example apps have been updated in Jan 2022 to work successfully with models trained on TensorFlow 2.6 and Model Maker 0.3.4.
The only problem with this tutorial is it doesn’t link to the correct Colab file for transfer learning on Step 7: Train a custom object detection model. DO NOT follow the links to the Colab on this step.
The correct Colab to train a working tflite model is the updated one located here.
They look very similar but have a few changes that make it work and not crash the app. There are also a few variations of the Android example app floating around out there as well. You want to use the on in this step of the tutorial here.
Hopefully all this information is correct as of Feb 2022.
Tutorial to follow for building Android App with Salad Detector
Step with the updated Android example app
Step with non-working Colab for training your own model
Correct Colab/Tutorial for training your own model
Its 2022 - and I get the same problem (deploying with android lead to error of
java.lang.IllegalArgumentException: Error occurred when initializing ObjectDetector: Output tensor at index 0 is expected to have 3 dimensions, found 2.
Greetings, everyone. I am new to TensorFlow and I am currently developing a real-time object detection application. I have trained an object detection model on my custom dataset using tflite model maker, but when I try to use the model in my app, the following error occurred.
Caused by: java.lang.IllegalArgumentException: Cannot copy from a TensorFlowLite tensor (StatefulPartitionedCall:1) with shape [1, 25] to a Java object with shape [1, 25, 4].
May I know if is it caused by the output order? As I used the Netron to visualize my model and found that the bounding box output order of my model is different from the sample model (which works fine in my app).
Greetings Everyone. I am also working on object detection. I trained my model from Teachable Machine. I am getting same error. Did anyone error got resolved because I have been trying to for days but nothing is working.