【发布时间】:2018-12-14 05:02:56
【问题描述】:
当我使用loadModel() 函数 tensorflow.js 尝试加载我在 Python 中训练的模型时遇到以下错误:
加载资源失败:net::ERR_NAME_NOT_RESOLVED
Uncaught (in promise) TypeError: Failed to fetch
下面是 predict.js 文件
console.log ("hello");
let model;
(async function () {
model = await tf.loadModel("http://keras_model/model.json");
$(".progress-bar").hide();
console.log("it works");
})();
目录结构:
main
-dataset (contains images for training the model)
-training_scripts (python scripts to train the model)
-user_interface
--server.js (server made using node.js(and express))
--static (this folder contains the trained keras model)
--index.html (html file to be served)
--predict.js
--keras_model(this folder contains the model.json file)
任何帮助将不胜感激!
【问题讨论】:
-
如果您使用
http://作为文件类型,您的网址必须是绝对网址 -
或者如果你使用node并且想要加载一个本地文件你必须使用文件类型
file:/// -
我正在使用节点,但出现此错误。
Fetch API cannot load file:///keras_model/model.json. URL scheme must be "http" or "https" for CORS request.我这里也必须使用绝对路径吗?? -
您需要
tfjs-node吗? -
嘿,谢谢你的帮助。它现在正在工作。
标签: javascript python tensorflow tensorflow.js