在javascript中从本地文件系统加载Tensorflow js模型 [英] Load Tensorflow js model from local file system in javascript

查看:522
本文介绍了在javascript中从本地文件系统加载Tensorflow js模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将keras模型转换为tensorflow json格式,并将其保存在本地计算机中.我正在尝试使用以下命令在javascript代码中加载该json模型

I have converted a keras model to tensorflow json format and saved it locally in my computer. I am trying to load that json model in a javascript code using the below command

model = await tf.loadModel('web_model')

但是没有加载模型. 有没有办法从本地文件系统加载tensorflow json模型?

But the model is not getting loaded. Is there a way to load tensorflow json model from local file system?

推荐答案

我知道您正在尝试在浏览器中加载模型,但是如果有人在这里尝试在Node中进行加载,方法如下:

I know you're trying to load your model in a browser but if anybody lands here that's trying to do it in Node, here's how:

const tf = require("@tensorflow/tfjs");
const tfn = require("@tensorflow/tfjs-node");
const handler = tfn.io.fileSystem("./path/to/your/model.json");
const model = await tf.loadModel(handler);

这篇关于在javascript中从本地文件系统加载Tensorflow js模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆