当我尝试加载我在 Python 中训练的模型时,当我使用 loadModel() 函数 tensorflow.js 时出现以下错误:
Failed to load resource: 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)
任何帮助将不胜感激!!
请您参考如下方法:
如果你想在 tfjs 中加载本地文件,你需要使用文件类型 file:/// 并且为了这个工作你需要 tfjs 的节点扩展。您可以通过在您的程序中安装并要求 node-fetch 来加载它。
