-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Universal Sentence Encoder] Not working in NodeJS (Failed to fetch) #7536
Comments
@cfpwastaken you can try to include 'node-fetch' package in your project. |
simply installing the package doesnt change anything, changing the global fetch object to it results in a different error: node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:2978
return env().platform.isTypedArray(a);
^
TypeError: env(...).platform.isTypedArray is not a function
at isTypedArray (node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:2978:27)
at inferShape (node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:5428:9)
at Module.tensor2d (node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:18580:25)
at file:///main.js:27:23
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.7.0 |
Hi, @cfpwastaken Apologize for the delayed response and I was able to replicate the same issue without any error. It seems like there is some issue with latest Could you please try with Here is details of
|
Yep. that seems to fix it. However i need to set the global fetch again, which you did not do in your example in order to get it to work: import _fetch from "node-fetch";
import * as tf from "@tensorflow/tfjs";
import * as use from "@tensorflow-models/universal-sentence-encoder";
global.fetch = _fetch;
await use.load();
console.log("Works!"); That really shouldn't be needed since node comes with fetch preinstalled, why is it acting differently? The USE should also get support for the latest node version, since that will become LTS sometime. |
Now I am running into another weird issue though. import * as tf from "@tensorflow/tfjs";
tf.tensor2d([1, 2, 3, 4], [2, 2]).print();
console.log("Works!");
// Works import * as tf from "@tensorflow/tfjs";
import * as use from "@tensorflow-models/universal-sentence-encoder";
tf.tensor2d([1, 2, 3, 4], [2, 2]).print();
console.log("Works!");
// Doesnt work Its that |
I tried the below code with
Here is output log:
|
@gaikwadrahul8's issue should be fixed in the next release. Sorry for the issues this has caused. For details, see #7489 The original issue with node fetch still exists. Downgrading node below 18 should fix it, but we're looking into a more permanent fix for newer versions. |
great to hear! |
Hi, @cfpwastaken We have published new release Could you please confirm if this issue is resolved for you ? Please feel free to close the issue if it is resolved ? If issue still persists please let us know ? Thank you! |
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. |
Sorry for the late response, it is working as expected now! |
System information
Describe the current behavior
When running the code below, it fails with this error:
Describe the expected behavior
The USE should load just fine, just like in the Browser.
Standalone code to reproduce the issue
Other info / logs
See above
The text was updated successfully, but these errors were encountered: