question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tensorflowjs React-Native: "TypeError: undefined is not an object (evaluating 'tfNodes.reduce')"

See original GitHub issue

Hi. I use Windows 10, my device conected via USB is Xiaomi 9 with Android 10.

I’m working with React-Native CLI and my package.json is here.

In my use case I’ve downloaded the custom models from Google AutoML Vision Edge according to this tutorial. The custom model consists in identifying two different types of plants, and I’ve sent about 30 pics of each one to create the model. When tested on the cloud, it works fine, but then I downloaded the files from my bucket and tried to load that model with a local node http-server as the tutorial says, I’ve got the issue: modelLoadErrorServer8000

I also did try on my RN project, to load the model in the function componentDidMount():

async componentDidMount() {
    this.cameraRollAccess()
    this.cameraAccess()
    try{
    await tf.ready()
    }catch(err){
      throw(err)
    }
    this.setState({
      isTfReady: true
    });

    try{      
      const modelJson =require('./assets/model/model.json');
      const modelWeight1 = require('./assets/model/group1-shard1of3.bin');
      const modelWeight2 = require('./assets/model/group1-shard2of3.bin');
      const modelWeight3 = require('./assets/model/group1-shard3of3.bin');
      this.model = await tf.loadGraphModel(bundleResourceIO(modelJson, [
      modelWeight1, modelWeight2, modelWeight3]));
    }catch(err){
      throw (err)
    }
    this.setState({isModelReady: true})
  }

But still it gets the same error as it did in the local server:

modelLoadErrorNodeRN

The downloaded model.json file is this one

I did some Google on this issue “TypeError: undefined is not an object (evaluating ‘tfNodes.reduce’)” but never got anything related to this. Assuming that modelJson and modelWeights are never empty or undefined, is there anything wrong that I haven’t seen yet?

I’ve got success doing generic image classification with Firebase ML-Vision and with Mobilenet on React-Native, and tested the custom model on Google Platform successfully, but locally with custom model I always get the same issue trying to load the model…

What can it be?

Thanks for any help in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tafsiricommented, Dec 2, 2020

I think this is related to https://github.com/tensorflow/tfjs/issues/4105, there was a bug on the automl side at some point so you may need to re-export the model. We’ll also be pushing a new release with fixes on our side in the near future.

cc @pyu10055

0reactions
google-ml-butler[bot]commented, Jan 19, 2021

Closing as stale. Please @mention us if this needs more attention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Tensorflow.js TypeError: undefined is not an object ...
When I run myCustomModel.executeAsync(tensor), it returns the error "[Unhandled promise rejection: TypeError: undefined is not an object ( ...
Read more >
'Typeerror: Undefined Is Not An Object (Evaluating 'Response ...
I'm working with ReactNative CLI and my package.json is here. Tensorflowjs ReactNative: TypeError: undefined is not an object evaluating I did some Google ......
Read more >
undefined is not an object (evaluating 'store.getState') - YouTube
ERROR TypeError : undefined is not an object ( evaluating 'store.getState')Please do like share and comment if you like the video please do ......
Read more >
Latest TF.js topics - TensorFlow Forum
Topic Replies Views Activity About the SIG TF.js category 0 1158 April 13, 2021 Dynamic optimizer · tfjs , models , help_request 0 362 September...
Read more >
undefined is not an object (evaluating 'navigation.state') - Reddit
I'm getting "TypeError: undefined is not an object (evaluating 'navigation.state')" when I click on Logout tab button, look at
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found