I am trying mobilenetv3_large_cityscapes_trainfine (http://download.tensorflow.org/models/deeplab_mnv3_large_cityscapes_trainfine_2019_11_15.tar.gz) in my flutter app. I am using flutter_tensorflow_lite package.
- Downloaded .gz from the above URL.
- Uncompressed it.
- Generated saved_model
- Generated .tflite
- Running segmentation on Android phone => recognitions = await Tflite.runSegmentationOnImage().
It crashes after inference is completed.
D/skia (20855): SkJpegCodec::onGetPixels + (513, 513)
D/skia (20855): SkJpegCodec::onGetPixels -
D/skia (20855): onGetGainmapInfo: false.
W/System (20855): A resource failed to call close.
W/System (20855): A resource failed to call close.
V/time (20855): Inference took 1211
D/AndroidRuntime(20855): Shutting down VM
E/AndroidRuntime(20855): FATAL EXCEPTION: main
E/AndroidRuntime(20855): Process: com.example.third_tflite_app, PID: 20855
E/AndroidRuntime(20855): java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
E/AndroidRuntime(20855): at sq.flutter.tflite.TflitePlugin.fetchArgmax(TflitePlugin.java:1169)
E/AndroidRuntime(20855): at sq.flutter.tflite.TflitePlugin$RunSegmentationOnImage.onRunTfliteDone(TflitePlugin.java:1071)
E/AndroidRuntime(20855): at sq.flutter.tflite.TflitePlugin$TfliteTask.onPostExecute(TflitePlugin.java:513)
E/AndroidRuntime(20855): at sq.flutter.tflite.TflitePlugin$TfliteTask.onPostExecute(TflitePlugin.java:481)
E/AndroidRuntime(20855): at android.os.AsyncTask.finish(AsyncTask.java:771)
The line at TflitePlugin.java:1169 is:
int outputChannels = outputTensor.shape()[3];
I am new to this, so do not know all technical details. I tried various options while generating saved_model and tflite model including input and output and data type (uint8 etc.).
It will be really helpful, if someone could guide me on right steps to generate a TFLite model for segmentation task. So, far I just used the pre-trained model. I have not tried custom model.
NOTE: In my app I have option to select different tasks like - object detection, segmentation, algorithms - SSD mobilenet, YOLO, Deeplab.
SSD mobilenet and YOLO worked fine. I am struggling with Deeplab segmentation.
Thanks in advance.
Milan