问题
I am trying to load a local tensorflowjs model on my Node server but am getting the error:
UnhandledPromiseRejectionWarning: TypeError: Only HTTP(S) protocols are supported.
This is how I am importing the Tensorflowjs packages:
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');
global.fetch = require('node-fetch')
and loading the model like this:
const ssd_model_path =
'file://models/ssd_model/model.json'
this.model = await tf.loadLayersModel(ssd_model_path);
My dependencies are as follows:
"dependencies": {
"@tensorflow/tfjs": "^1.5.2",
"@tensorflow/tfjs-core": "^1.2.11",
"@tensorflow/tfjs-node": "^1.2.3",
"electron-reload": "^1.5.0",
"esm": "^3.2.25",
"jimp": "^0.9.3",
"node-fetch": "^2.6.0"
}
回答1:
I think tfjs-node
is for NodeJS, and tfjs
is for the web browser. You shouldn't use both at the same time, because tfjs-node
has every thing as dependencies for NodeJS.
If you look at a NodeJS example, then you'll see doesn't use tfjs
https://github.com/tensorflow/tfjs-examples/tree/master/mnist-node
来源:https://stackoverflow.com/questions/60137483/tensorflow-node-js-typeerror-only-https-protocols-are-supported