将 tensorflow js 对象检测 executeAsync 输出格式化为人类可读
formating tensorflowjs object detection executeAsync output to human reabale
我想知道如何格式化 executeAsync 张量流对象检测 executeAsync 方法输出,使其看起来像这样:
我当前的输出看起来像这样,无法通过浏览阅读:
一直在浏览coco-ssd.js,不知为何写的很烂。
https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd
当然这需要美化,但之后几乎没有一个变量被它的名字调用,它基本上是字母表中的所有字母。
我的预测是这样的(未格式化):
async function asyncCall() {
const modelUrl = 'http://192.168.0.14:8000/web_model_4/model.json';
const img = document.getElementById('img');
const imgTensor = tf.browser.fromPixels(img);
const t4d = imgTensor.expandDims(0);
const model = await tf.loadGraphModel(modelUrl).then(model => {
predictions = model.executeAsync(t4d, ['detection_classes']).then(predictions=> { //, 'detection_classes', 'detection_scores'
console.log('Predictions: ', predictions);
})
})
}
asyncCall();
感谢您的帮助。我敢肯定还有其他人在使用 coco ssd 训练自定义模型时遇到问题。
谢谢!
您正在执行自己的模型,因此需要以人类可读的方式格式化您的输出。如果您使用的是 tfjs 模型 coco-ssd (https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd),您将立即获得格式设置。
关于你所说的written terribly
,是因为js的缩小
回到最初的问题:如何格式化输出?查看控制台中打印的内容,我们可以看到它是一个张量。所以如果你要打印它,你首先需要先下载它的数据:
predictions = model.executeAsync(t4d, ['detection_classes']).then(predictions=> {
const data = predictions.dataSync() // you can also use arraySync or their equivalents async methods
console.log('Predictions: ', data);
})
我想知道如何格式化 executeAsync 张量流对象检测 executeAsync 方法输出,使其看起来像这样:
我当前的输出看起来像这样,无法通过浏览阅读:
一直在浏览coco-ssd.js,不知为何写的很烂。 https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd 当然这需要美化,但之后几乎没有一个变量被它的名字调用,它基本上是字母表中的所有字母。
我的预测是这样的(未格式化):
async function asyncCall() {
const modelUrl = 'http://192.168.0.14:8000/web_model_4/model.json';
const img = document.getElementById('img');
const imgTensor = tf.browser.fromPixels(img);
const t4d = imgTensor.expandDims(0);
const model = await tf.loadGraphModel(modelUrl).then(model => {
predictions = model.executeAsync(t4d, ['detection_classes']).then(predictions=> { //, 'detection_classes', 'detection_scores'
console.log('Predictions: ', predictions);
})
})
}
asyncCall();
感谢您的帮助。我敢肯定还有其他人在使用 coco ssd 训练自定义模型时遇到问题。 谢谢!
您正在执行自己的模型,因此需要以人类可读的方式格式化您的输出。如果您使用的是 tfjs 模型 coco-ssd (https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd),您将立即获得格式设置。
关于你所说的written terribly
,是因为js的缩小
回到最初的问题:如何格式化输出?查看控制台中打印的内容,我们可以看到它是一个张量。所以如果你要打印它,你首先需要先下载它的数据:
predictions = model.executeAsync(t4d, ['detection_classes']).then(predictions=> {
const data = predictions.dataSync() // you can also use arraySync or their equivalents async methods
console.log('Predictions: ', data);
})