-
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
"response.arrayBuffer is not a function" while loadLayersModel (Node.js) #2029
Comments
@kqtus getting a CORS exception while loading , can you please check. |
@rthadur hmm, strange. I tried loadLayersModel and through Postman on both model.json and bin on another PC, and files seem to download without CORS exceptions. -- Edit 1. -- Edit 2. |
Any estimations on when it will be fixed? From what I understand, Node.js doesn't support arrayBuffer(). You'd need to change this: weights_loader.ts, line 60: to this: |
@kangyizhang any thoughts on above comments from @kqtus ? |
Ok I think I solved it the proper way, having replaced global fetch.
It is strange though, because previously I tried passing it as a fetchFunc, but it didn't trigger. |
thanks for the update , closing this issue. |
tf.loadLayersModel() should automatically use node-fetch when it's in Node environment. @dsmilkov any thoughts why |
@kqtus We'd like to understand why you had to manually do Can you provide a bit more info:
Thank you! |
Another idea. Can you double-check the node-fetch version you had installed before? It is possible that you had manually installed node-fetch 1.x which lacks |
|
@kqtus can you provide your node version and which operating system you are using? |
@kangyizhang Node v10.16.3, Windows 10 1903. Here's also package.json: https://pastebin.com/swpTke2q. One additional thing came to my mind - we are having frontend app and backend in the same project (Express + React). Frontend is being transpiled and backend is run as-is - maybe that causes ambiguity. |
TensorFlow.js version
1.2.9
Browser version
any
Describe the problem or feature request
I have exported a Keras model written in Python, then converted it with tensorflowjs_converter and uploaded it to server. Then, I get error while loading it. I have tried it with @tensorflow/tfjs-node' as well as @tensorflow/tfjs'.
TypeError: response.arrayBuffer is not a function at f:\Developer\x\node_modules\@tensorflow\tfjs-core\dist\io\weights_loader.js:97:90 at Array.map (<anonymous>) at Object.<anonymous> (f:\Developer\x\node_modules\@tensorflow\tfjs-core\dist\io\weights_loader.js:97:48) at step (f:\Developer\x\node_modules\@tensorflow\tfjs-core\dist\io\weights_loader.js:48:23) at Object.next (f:\Developer\x\node_modules\@tensorflow\tfjs-core\dist\io\weights_loader.js:29:53) at fulfilled (f:\Developer\x\node_modules\@tensorflow\tfjs-core\dist\io\weights_loader.js:20:58) at process._tickCallback (internal/process/next_tick.js:68:7)
Code to reproduce the bug / link to feature request
File is publicly available, bin file also resides there.
const tf = require('@tensorflow/tfjs-node');
model = await tf.loadLayersModel('https://storage.googleapis.com/valid-ship-252510.appspot.com/1568271407928-tfjs_model_1/model.json');
The text was updated successfully, but these errors were encountered: