gpt4 book ai didi

javascript - 无法在 tensorflow.js 中加载 python 训练模型

转载 作者:太空宇宙 更新时间:2023-11-04 08:30:56 24 4
gpt4 key购买 nike

当我尝试加载我在 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 来加载它。

关于javascript - 无法在 tensorflow.js 中加载 python 训练模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53031887/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com