修正 "检查您的 Graph def 解释二进制文件是否与您的 Graph def 生成二进制文件保持一致" 。

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

我正在用 react native 运行 tensorflow。我有一个重新训练的Inception V3图。我使用GitHub repo的例子来测试我自己的模型以外的模型是否可以工作,它的功能非常好。当我试图使用我自己的模型时,我得到了Error: "检查你的GraphDef解释二进制是否与GraphDef生成二进制保持一致"

开发信息{Python 3.5, react-Native 0.59, tensorflow 2.0.0a0, protobuf 3.7.1}从我看到的情况来看,我已经尝试在旧版本的tensorflow上训练我的模型,(我用的是1.13.1,我试过1.8.0)。我听说我的tensorflow版本和protobuf可能太高,无法解释我的.pb文件。但这并不奏效,我收到了完全相同的错误。

下面是识别代码:async recognizeImage() {

try {
  const tfImageRecognition = new TfImageRecognition({
    model:require('./assets/retrained_graph.pb'),
    labels: require('./assets/retrained_labels.txt')
  })

  const results = await tfImageRecognition.recognize({
    image: this.image
  })
python tensorflow react-native-android
1个回答
2
投票

在我的docker容器上(我运行tensorflow serving的地方),我有。

TensorFlow ModelServer: 2.1.0-rc1
TensorFlow Library: 2.1.0

这个问题与你本地的tensorflow版本有关,你用它来导出protobuf模型。我知道如果你用 tf 版本 1.14.0、2.1.0 和 2.2.0 来导出你的 h5 模型,你会在执行推理时遇到这个问题。你可以尝试使用tf版本>1.15.0和小于1.8.0。我认为这是因为某些tensorflow版本在导出时不支持特定的层。

要改变你本地的 tensorflow 版本,你可以做以下操作

pip install tensorflow==1.15.0

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