Ton*_*uze 5 google-vision tensorflow automl tensorflow.js tensorflow2.0
** 我知道类似的问题!!**
我的问题是针对我的特定情况...我使用 Google Vision 训练我自己的模型来检测自定义对象。过去我遇到过类似的形状错误,我通过重塑输入图像解决了这些错误。
这个特殊的错误告诉我我的形状必须是一个空数组或空形状。这甚至可能吗?如果这不是故障,我该如何解决?
这就是我在其他项目中抱怨形状时解决以前错误的方法。此解决方案不适用于空数组/形状
const model = await autoML.loadObjectDetection('./model/model.json');
// const model = await tfjs.loadGraphModel('./model/model.json');
await tfjs.ready();
const tfImg = tfjs.browser.fromPixels(videoElement.current).expandDims(0);
const smallImg = await tfjs.image.resizeBilinear(tfImg, [224, 224]);
const resized = tfjs.cast(smallImg, 'float32');
const t4d = tfjs.tensor4d(Array.from(resized.dataSync()), [1, 224, 224, 3]);
const predictions = await modelRef.current.detect(tfImg, options);
Run Code Online (Sandbox Code Playgroud)
当我将 Vision AI 的 tfjs 模型导出到 tfjs 模型并按照本文加载模型时,我遇到了同样的问题。
解决方法:
作为解决方法,我将模型从 Vision AI 导出为 SavedModel 格式,并按照本指南使用tensorflow_converter将其转换为 tfjs 模型。结果可以按预期加载并且工作正常。
| 归档时间: |
|
| 查看次数: |
570 次 |
| 最近记录: |