4

I've trained a model on Google Cloud AutoML. And I've used it on this code:

<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>

I'm using this on the browser. But it gives this error:

graph_executor.ts:109 Uncaught (in promise) Error: This execution contains the node 'Preprocessor/map/while/Exit_2', which has the dynamic op 'Exit'.

Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [Preprocessor/map/TensorArrayStack/TensorArrayGatherV3]

When I use executeAsync() instead of classify() I'm having another issue:

index2.html:7 Uncaught (in promise) TypeError: model.executeAsync is not a function at run

Community
  • 1
  • 1
sundowatch
  • 3,012
  • 3
  • 38
  • 66

0 Answers0