簡體   English   中英

TensorFlow重新訓練的初始v3模型在Android上崩潰

[英]TensorFlow retrained inception v3 model crashes on Android

我已經使用我自己的數據集重新訓練了TensorFlow Inception v3模型,如本教程所述

現在我正在嘗試使用我的再培訓模型構建和運行TensorFlow Android示例 我按原樣從示例中構建了本機代碼,將模型(.pb)和標簽(.txt)文件復制到資產目錄並更改了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)

PS我也試過像這樣使用tensorflow/python/tools/strip_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' }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM