冻结TensorFlow图形以在iOS应用程序中使用

问题描述 投票:1回答:1

我有以下文件:1。retrained_graph.pb 2. retrained_labels.txt 3. _retrain_checkpoint.meta 4. _retrain_checkpoint.index 5. _retrain_checkpoint.data-00000-of-00001 6. checkpoint

执行命令:

python freeze_graph.py 
--input_graph=/Users/saurav/Desktop/example/tmp/retrained_graph.pb 
--input_checkpoint=./_retrain_checkpoint 
--output_graph=/Users/saurav/Desktop/example/tmp/frozen_graph.pb --output_node_names=softmax

获取错误:UnicodeDecodeError:'utf-8'编解码器无法解码44位的字节0xff:无效的起始字节

以下是截图:enter image description here

tensorflow coreml tensorflow-lite mlmodel
1个回答
1
投票

最后我找到了答案。要冻结图形,您需要使用“bazel”构建。 1.使用自制软件安装bazel。 brew install bazel 2.如果你没有自制软件,请安装它。

/usr/bin/ruby -e "$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/master/install)" 
  1. 通过命令git clone https://github.com/tensorflow/tensorflow克隆张量流
  2. 将目录更改为终端中的tensorflow
  3. 运行命令./Configure。它根据您的需要回答几个问题。他们中的大多数你可以输入“NO”。它询问Python的默认路径,您需要指定路径或只需点击“输入”。
  4. 现在使用命令:bazel build tensorflow/python/tools:freeze_graph为freeze_graph构建bazel
  5. 将重新训练的图形和检查点保留在文件夹中。
  6. 运行bazel命令冻结图形。

bazel-bin/tensorflow/python/tools/freeze_graph \ --input_graph=YouDirectory/retrained_graph.pb \ --input_checkpoint=YouDirectory/_retrain_checkpoint \ --output_graph=YouDirectory/frozen_graph.pb

© www.soinside.com 2019 - 2024. All rights reserved.