Tensorflow.js预训练的Google AutoML模型不起作用

时间:2020-03-09 06:48:19

标签: tensorflow google-cloud-platform tensorflow.js automl google-cloud-automl-nl

我已经在Google Cloud AutoML上训练了一个模型。我在以下代码上使用了它:

<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow/tfjs-automl"></script>
<img id="test" crossorigin="anonymous" src="test.jpg"><script>
async function run() {
  const model = await tf.automl.loadImageClassification('model3/model.json');
  const image = document.getElementById('test');
  const predictions = await model.classify(image);
  console.log(predictions);
  // Show the resulting object on the page.
  const pre = document.createElement('pre');
  pre.textContent = JSON.stringify(predictions, null, 2);
  document.body.append(pre);
}
run();
</script>

我正在浏览器上使用它。但这给出了这个错误:

graph_executor.ts:109未捕获(已承诺)错误:此执行包含节点“ Preprocessor / map / while / Exit_2”,该节点具有动态操作“ Exit”。

请改用model.executeAsync()。或者,为避免动态操作,请指定输入[Preprocessor / map / TensorArrayStack / TensorArrayGatherV3]

当我使用executeAsync()而不是classify()时,我遇到了另一个问题:

index2.html:7未捕获(承诺)TypeError:model.executeAsync不是运行时的函数

0 个答案:

没有答案