问题描述
我要做什么:我想从mobileNet的TensorFlow.js图像分类中获得可能性最高的className。我想将className作为字符串获取。
问题:我不知道如何将className隔离为字符串。有命令吗?还是您知道我该如何解决我的问题?
我的代码:
theAi();
async function theAi() {
const tf = require('@tensorflow/tfjs'),mobilenet = require('@tensorflow-models/mobilenet'),tfnode = require('@tensorflow/tfjs-node'),fs = require('fs-extra');
const imageBuffer = await fs.readFile("./jesus.jpg"),tfimage = tfnode.node.decodeImage(imageBuffer),mobilenetModel = await mobilenet.load();
const results = await mobilenetModel.classify(tfimage);
console.log(results);
};
和输出:
[
{
className: 'chain mail,ring mail,mail,chain armor,chain armour,ring armor,ring armour',probability: 0.5979475378990173
},{ className: 'vestment',probability: 0.14261281490325928 },{ className: 'fountain',probability: 0.03441018983721733 }
]
因此,在这种情况下,我想获取字符串(“锁子甲,环信,邮件,链甲,链甲,环甲,环甲”)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)