Skip to content

"Uncaught (in promise) TypeError: _this3.signature.inputs is undefined" when trying to predict from UltraLytics YOLOv5 implementation when exported to TFJS #6991

@NormanTUD

Description

@NormanTUD

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Debian 11
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: No
  • TensorFlow.js installed from (npm or script link): No
  • TensorFlow.js version (use command below): 4.0.0
  • Browser version: Firefox 102, Chromium 106.0.5249.91
  • Tensorflow.js Converter Version: 3.15.0

Describe the current behavior

When I'm trying to predict an exported model from UltraLytics YOLOv5 Implementation, which has been exported with python3 export.py --weights runs/train/exp/weights/best.pt --img 640 640 --batch-size 1 --include tfjs and loaded with var model = await tf.loadGraphModel('./model.json') (prediction via var res = await model.executeAsync(img_tensor);), I get the following error message and the program stops execution.

Screenshot_20221031_174702

Describe the expected behavior

I expected the model to "just work".

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.

This problem was fixed by changing line 93481 in tf.js (from https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.0.0/dist/tf.js) from

var signature = _this3.signature ? _this3.signature.inputs[inputName] : null;

to

var signature = Object.keys(_this3).includes("signature") && Object.keys(_this3.signature).includes("inputs") ? _this3.signature.inputs[inputName] : null; 

I have no idea why it fails or where exactly to change this in the "real" TypeScript (not the JS only), and for me this quickfix is enough, since my project works with it and is not meant for external users currently.

But it would be good if it was fixed in the proper version, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions