【发布时间】:2020-10-15 08:00:22
【问题描述】:
我设法将我的模型转换为 model.JSON 并设法使用 model.executeAsync() 加载它。那么我如何访问输出以获取标签和置信度值以显示它。 model.executeAsync() 给我回一堆数组值
这是我的 index.js
async function init(){
try {
model = await
tf.loadGraphModel('http://localhost/demo7/model/model.json');
} catch (err) {
console.log(err);
}}
async function predict() {
console.log("executing model");
let user_pic = document.querySelector('img');
model.executeAsync(tf.browser.fromPixels(user_pic).cast('int32').expandDims())
console.log('This is your model: ', model, 'This is your prediction: ', prediction) }}
init()
结果: sample result
[[PromiseResult]]: 数组(7) 0:e 数据ID:{} 数据类型:“float32” 编号:3350 isDisposedInternal: 假 保留:假 等级类型:“3” 范围标识:6152 形状:(3) [1, 300, 4] 尺寸:1200 步幅:(2) [1200, 4] 已处置:(...) 等级:(...) 原型:对象 1:e 数据ID:{} 数据类型:“float32” 编号:3372 isDisposedInternal: 假 保留:假 排名类型:“1” 范围标识:6193 形状:1 尺寸:1 步幅:[] 已处置:(...) 等级:(...) 原型:对象 2:e 数据ID:{} 数据类型:“float32” 编号:3367 isDisposedInternal: 假 保留:假 排名类型:“2” 范围标识:6182 形状:(2) [1, 300] 尺寸:300 步幅:[300] 已处置:(...) 等级:(...) 原型:对象 3:e 数据ID:{} 数据类型:“float32” 编号:2254 isDisposedInternal: 假 保留:假 等级类型:“3” 范围标识:3543 形状:(3) [1, 300, 8] 尺寸:2400 步幅:(2) [2400, 8] 已处置:(...) 等级:(...) 原型:对象
【问题讨论】:
-
您能否添加代码的相关部分以输出图片中的内容?顺便说一句,添加代码比添加图像更好,因为人们可以复制您拥有的内容并自行尝试。
-
嗨,我已经用示例代码编辑了这个问题。这是我第一次顺便问,所以不太熟悉如何包含代码等。对不起
标签: tensorflow object-detection tensorflow.js