Tensorflowjs React-Native: "TypeError: undefined is not an object (evaluating 'tfNodes.reduce')"
See original GitHub issueHi. 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:
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:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
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
Closing as stale. Please @mention us if this needs more attention.