@tensorflow-models/mobilenet does not work under Node.js
See original GitHub issueTrying to use the @tensorflow-models/mobilenet
package under Node.js throws the following exception:
2018-09-27 15:25:56.699190: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA (node:98265) Warning: N-API is an experimental feature and could change at any time. (node:98265) UnhandledPromiseRejectionWarning: Error: browserHTTPRequest is not supported outside the web browser without a fetch polyfill. at new BrowserHTTPRequest (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-core/dist/io/browser_http.js:46:19) at Object.browserHTTPRequest (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-core/dist/io/browser_http.js:247:12) at Object.<anonymous> (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:98:50) at step (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:42:23) at Object.next (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:23:53) at /Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:17:71 at new Promise (<anonymous>) at __awaiter (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:13:12) at Object.loadModelInternal (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/models.js:92:12) at Object.loadModel (/Users/kreeger/workspace/mn-test/node_modules/@tensorflow/tfjs-layers/dist/exports.js:16:21) (node:98265) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4) (node:98265) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (4 by maintainers)
Top GitHub Comments
I finally worked it out.
I use
global.fetch = require('node-fetch')
. Inscript.sh
I change the loading mode script fromfile
tohttps
:Then I met with an error
Error: Unknown feature TENSORLIKE_CHECK_SHAPE_CONSISTENCY.
And then , I bump tfjs to the latest release:
It works for me now.
If people come across this issue, I found a (relatively) simple workaround using the
node-fetch
library from NPM. https://www.npmjs.com/package/node-fetch