tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Error related to ops when using automl.LoadImageClassification

Open jenperson opened this issue 1 year ago • 7 comments

Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Cloud Shell Environment console.cloud.google.com/?cloudshell=true
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow.js installed from (npm or script link): Script
  • TensorFlow.js version (use command below):
  • Browser version: Chrome Version 103.0.5060.134 (Official Build) (arm64)
  • Tensorflow.js Converter Version: N/A

Describe the current behavior When completing this tutorial, I follow these steps:

  • Create the AutoML model
  • Export to TFJS
  • Add the code snippet provided by the tutorial
  • Serve the page

Upon serving the page, the console logs show the following error:

tfjs:17 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]
    at t.compile (tfjs:17:762997)
    at t.execute (tfjs:17:764453)
    at t.execute (tfjs:17:777974)
    at t.predict (tfjs:17:777254)
    at tfjs-automl:82:38
    at tfjs:17:159835
    at t.scopedRun (tfjs:17:159964)
    at t.tidy (tfjs:17:159732)
    at Object.pI [as tidy] (tfjs:17:220533)
    at ImageClassificationModel.classify (tfjs-automl:80:35)

I tried switching the script tags listed in the tutorial with the following scripts, since these are listed in our documentation:

The result was the same.

Describe the expected behavior Identify the flower in the image

Standalone code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem. If possible, please share a link to Colab/CodePen/any notebook. glitch demo of the issue Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

Related StackOverflow question

jenperson avatar Aug 04 '22 18:08 jenperson

It looks like img_classification.ts from tfjs-automl is using model.predict instead of model.executeAsync. This prevents models with dynamic ops from working. I'll see if I can change it to model.executeAsync.

mattsoulanille avatar Aug 04 '22 18:08 mattsoulanille

@jenperson The model used in the demo has two output nodes, 'scores' and 'boxes'. Currently, img_classification.ts assumes there is only one output tensor for scores. Do you know why the model has a 'boxes' output?

mattsoulanille avatar Aug 04 '22 20:08 mattsoulanille

@jenperson @mattsoulanille Given the model contains two outputs, my guess it might not be a pure automl image classification model, or there are changes to the structure of the model.

pyu10055 avatar Aug 04 '22 20:08 pyu10055

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Aug 31 '22 20:08 google-ml-butler[bot]

@pyu10055 any idea how that would happen? I followed the directions in the guide.

jenperson avatar Sep 01 '22 16:09 jenperson

The signature of this model looks like object detection model, instead of image classification model. Can you share how you have created this model?

pyu10055 avatar Sep 01 '22 18:09 pyu10055

I followed the directions provided in the AutoML TFJS tutorial https://cloud.google.com/vision/automl/docs/tensorflow-js-tutorial which directs you to create the model using the quickstart https://cloud.google.com/vision/automl/docs/label-images-edge-model

jenperson avatar Sep 01 '22 19:09 jenperson

Hi, @jenperson

Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.

The TFJs team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TFJs version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.

Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow.js space.

Thank you for your support and cooperation.

gaikwadrahul8 avatar Sep 03 '23 23:09 gaikwadrahul8

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Sep 11 '23 01:09 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar Sep 19 '23 01:09 github-actions[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Sep 19 '23 01:09 google-ml-butler[bot]