Tensorflow自定义TFLite java.lang.NullPointerException:无法为解释器分配内存

Ton*_*ony 10 python android tensorflow

我使用以下命令从https://github.com/tensorflow/hub/blob/master/examples/image_retraining/retrain.py使用retrain.py创建了一个自定义tensorflow lite模型

python retrain.py --image_dir newImageDirectory --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/1
Run Code Online (Sandbox Code Playgroud)

然后我使用toco将output_graph.pb文件转换为lite文件.使用以下命令

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
Run Code Online (Sandbox Code Playgroud)

然后我拿新的lite文件和labels.txt文件并将它们放在tensorsflow中为诗人2 https://github.com/googlecodelabs/tensorflow-for-poets-2看看我是否可以让它开始分类新的类别.应用程序启动时,我收到以下错误.

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)
Run Code Online (Sandbox Code Playgroud)

小智 1

这是由于您使用的计算机所致,请确保您有足够的内存来为程序分配,或者尝试增加交换文件大小?