51

I have created a custom tensorflow lite model using retrain.py from https://github.com/tensorflow/hub/blob/master/examples/image_retraining/retrain.py using the following command

python retrain.py --image_dir newImageDirectory --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/1

Then I convert using toco the output_graph.pb file to a lite file. Using the below command:

bazel run tensorflow/contrib/lite/toco:toco -- --input_file=/tmp/output_graph.pb --output_file=/tmp/optimized.lite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --inpute_shape=1,224,224,3 --input_array=input --output_array=final_result --inference_type=FLOAT --input_data_type=FLOAT

Then I take the new lite file and the labels.txt file and put them in tensorflow for poets 2 https://github.com/googlecodelabs/tensorflow-for-poets-2 to see if I can have it start to classify new categories. When the application launches I receive the following error:

Caused by: java.lang.NullPointerException: Can not allocate memory for the interpreter                                                                                            at org.tensorflow.lite.NativeInterpreterWrapper.createInterpreter(Native Method)
                                                                      at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:63)
                                                                                        at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:51)
                                                                                        at org.tensorflow.lite.Interpreter.<init>(Interpreter.java:90)
                                                                                        at com.example.android.tflitecamerademo.ImageClassifier.<init>(ImageClassifier.java:97)
3
  • I've been running into this issue when trying to use a retrained InceptionV3 model, I thought it was caused by the model size (about 80 MB), but it must be something else when this error occurs even with these smaller MobileNet models. Commented Jul 11, 2018 at 15:27
  • Were you able to solve this? Commented Jul 16, 2018 at 20:24
  • This problem has been reported here github.com/tensorflow/tensorflow/issues/19982 Commented Mar 4, 2021 at 18:09

1 Answer 1

1

This is due to the computer you are using, make sure you have enough ram to allocate for the program, or try increasing your swap file size?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.