0

Demo is available by Tensorflow in following link :

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/java/demo

Please change labels.txt file in above file by adding or removing a text(class) , It'll crash the application.

It's making the given solution unable to change output's size.

Please address the solution, how can we change the label.txt file with some constants like INPUT_SIZE or OUTPUT_SIZE that makes this bug solved.

Note

Application works fine as it is, but crash upon changing label.txt file, e.g. adding or removing names in the file.

Crash :

Cannot copy between a TensorFlowLite tensor with shape [1, 1001] and a Java object with shape [1, 1000].

****Above demo is build by using already present gradle configuration setting.**

Feature request: Changing label file size & work accordingly through parameter is available in IOS demo with this
output_size = 1000;
This feature should be in Android version as well.

Thanks.

Milad Bahmanabadi
  • 946
  • 11
  • 27
  • The above scenario is really above the documentation available, please provide some link if it could solve the issue?? Thanks – Shahid Ahmad Dec 05 '18 at 14:14
  • It seems like you should report this issue to that github project. This question appears to be asking SO to debug this project. – Dirk Dec 08 '18 at 06:46

1 Answers1

0

As a feature request, you should generally file things to Github.

If you're looking for a local fix, I'm guessing the issue is that the model outputs a 1x1000 and you'll need to modify the actual model to be 1x1001 (and all the shapes of everything that comes before it).

Alan Chiao
  • 161
  • 3
  • Thanks, I'm not sure, if it's possible to re-shape or refactor number of classes (=1000) programmatically in Tensorflow Android SDK, Otherwise I have to train model again for specific number of classes. – Shahid Ahmad Feb 08 '19 at 07:34
  • Yes, you wouldn't be able to programmatically do so and training the model may be the simplest path if you have it setup. What you can consider is manually modify the model (see https://stackoverflow.com/questions/50764572/how-can-i-test-a-tflite-model-to-prove-that-it-behaves-as-the-original-model-us for how to produce a json version of the model). However, I would assume that the model has several layers that assume the output shape being 1000, so unless there is something special, you'll have to start from training the model. – Alan Chiao Feb 09 '19 at 02:56
  • Otherwise, if there's a label you don't want, just remove it and add the one you want .. and then use transfer learning/retraining instead of training the model from scratch. – Alan Chiao Feb 09 '19 at 02:58