Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TensorFlow重新训练的inception v3模型在Android上崩溃_Android_Machine Learning_Android Ndk_Tensorflow - Fatal编程技术网

TensorFlow重新训练的inception v3模型在Android上崩溃

TensorFlow重新训练的inception v3模型在Android上崩溃,android,machine-learning,android-ndk,tensorflow,Android,Machine Learning,Android Ndk,Tensorflow,我用我自己的数据集重新训练了TensorFlow Inception v3模型,如本文所述 现在,我正在尝试使用我重新训练过的模型构建和运行TensorFlow。我按照原样从示例中构建了本机代码,将模型(.pb)和标签(.txt)文件复制到assets目录中,并在TensorFlowImageListener.java中更改了模型参数: private static final int NUM_CLASSES = 5; // number of categories private static

我用我自己的数据集重新训练了TensorFlow Inception v3模型,如本文所述

现在,我正在尝试使用我重新训练过的模型构建和运行TensorFlow。我按照原样从示例中构建了本机代码,将模型(.pb)和标签(.txt)文件复制到assets目录中,并在
TensorFlowImageListener.java
中更改了模型参数:

private static final int NUM_CLASSES = 5; // number of categories
private static final int INPUT_SIZE = 299;
private static final int IMAGE_MEAN = 128;
private static final float IMAGE_STD = 128;
private static final String INPUT_NAME = "Mul:0";
private static final String OUTPUT_NAME = "final_result:0";
但解析从资产加载的模型文件时,应用程序崩溃:

08-12 16:02:08.258 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:115 Loading TensorFlow.
08-12 16:02:08.258 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:117 Making new SessionOptions.
08-12 16:02:08.259 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:120 Got config, 0 devices
08-12 16:02:08.264 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:123 Session created.
08-12 16:02:08.264 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:126 Graph created.
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:130 Acquired AssetManager.
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: tensorflow_jni.cc:132 Reading file to proto: file:///android_asset/tensorflow_inception_graph.pb
08-12 16:02:08.265 25253-25253/com.iliakplv.tensorflow I/native: jni_utils.cc:120 Opening asset tensorflow_inception_graph.pb from disk with copy.
08-12 16:02:09.382 25253-25253/com.iliakplv.tensorflow A/native: jni_utils.cc:123 Check failed: message->ParseFromArray(memory, data_size) 
08-12 16:02:09.382 25253-25253/com.iliakplv.tensorflow A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 25253 (tech.tensorflow)
另外,我还尝试过使用
tensorflow/python/tools/strip\u unused.py
(正如它所建议的那样):

bazel build tensorflow/python/tools:strip_unused && \
bazel-bin/tensorflow/python/tools/strip_unused \
--input_graph=some_graph_def.pb \
--output_graph=/tmp/stripped_graph.pb \
--input_node_names=Mul
--output_node_names=final_result

没有帮助。

问题在于gradle压缩资产文件导致模型解析失败。我禁用了
.pb
文件的压缩:

aaptOptions { noCompress 'pb' }

我已将此添加到我的gradle文件中,但问题没有解决。@MuhammadHannan我在TensorFlow和Android应用程序上使用在一个特定版本上重新训练的模型,并在另一个版本上构建本机LIB时,遇到了类似的模型解析问题。由于TensorFlow正在进行密集的开发,最好检查一下特定的发布分支,并对其进行所有的实验。