tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.36k stars 1.92k forks source link

fresh react native install (18.2.0 / 0.74.3) and tfjs 4.20 issue #8344

Closed philippogol closed 2 days ago

philippogol commented 1 month ago

I'm encountering a constant error while fresh starting a new project. These are the dependencies:

"dependencies": { "@react-native-async-storage/async-storage": "^1.24.0", "@tensorflow/tfjs": "^4.20.0", "@tensorflow/tfjs-react-native": "^1.0.0", "react": "18.2.0", "react-native": "0.74.3" }

Making a simple addition using or just loading the package library throws the error "Cannot read property 'isTypedArray' of undefined. I tried different things and is not working, has someone experienced something like this or has a solution? Thanks.

gaikwadrahul8 commented 1 month ago

Hi, @philippogol

I apologize for the delay in my response and if possible could you please give it try with mentioned package dependancies here and see is it resolving your issue or not ?

If issue still persists please help us with complete error log and steps with your Github repo to replicate the same behavior from our end to investigate this issue further.

Thank you for your cooperation and patience.

philippogol commented 1 month ago

hey @gaikwadrahul8 thanks for the coming back, its actually pretty forward and i think it should an easy fix. here are the steps and code im using for a simple tensorflow loading model (im avoiding expo since it should be possible to use tensorflow without any expo package)

  1. npx react-native init tensorflowApp
  2. npm install @react-native-async-storage/async-storage @tensorflow/tfjs @tensorflow/tfjs-react-native
  3. cd ios/ & pod install
  4. all code in App.tsx (starting tensorflow and loading model, see in repo)

In get the error: "Console Warning Possible unhandled promise rejection (id: 0): TypeError: Cannot read property 'fetch' of undefined" (see attachment). IMG_3944

repo: https://github.com/philippogol/reactnative-tensorflow

shmishra99 commented 2 weeks ago

hey @gaikwadrahul8 thanks for the coming back, its actually pretty forward and i think it should an easy fix. here are the steps and code im using for a simple tensorflow loading model (im avoiding expo since it should be possible to use tensorflow without any expo package)

  1. npx react-native init tensorflowApp
  2. npm install @react-native-async-storage/async-storage @tensorflow/tfjs @tensorflow/tfjs-react-native
  3. cd ios/ & pod install
  4. all code in App.tsx (starting tensorflow and loading model, see in repo)

In get the error: "Console Warning Possible unhandled promise rejection (id: 0): TypeError: Cannot read property 'fetch' of undefined" (see attachment). IMG_3944

repo: https://github.com/philippogol/reactnative-tensorflow

Hi @philippogol ,

Apologies for the delayed response. I am unable to replicate the issue on my system, i'm encountering a different error.

The warning message Console Warning Possible unhandled promise rejection (id: 0): suggests that the promise from await tf.ready() might be rejected, which indicates that TensorFlow.js was not successfully initialized. This failure could be causing the error TypeError: Cannot read property 'fetch' of undefined.

You could use following set of code to check what exactly casuing the error.

  tf.ready().then(async  ()=>{
    setIsTfReady(true);
    // Load the MobileNet model
    const model = await tf.loadLayersModel('https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json');
    setModel(model);
  }).catch(e=> console.log('Error while loading the tf dependencies.',e));

Let me know if it helps. Thank You!!!

github-actions[bot] commented 1 week ago

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] commented 2 days ago

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

google-ml-butler[bot] commented 2 days ago

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