Tensorflow Node-js, TypeError: Only HTTP(S) protocols are supported

你说的曾经没有我的故事 提交于 2021-01-28 02:09:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!