gpt4 book ai didi

tensorflow - model.execute(dict) 中提供的 dict ['ToFloat' ] 的形状必须是 []

转载 作者:行者123 更新时间:2023-12-03 17:10:40 32 4
gpt4 key购买 nike

enter image description here
** 我知道类似的问题!! **
我的问题是针对我的特殊情况...
我使用 Google Vision 训练我自己的模型来检测自定义对象。
过去我遇到过关于形状的类似错误,我通过 reshape 输入图像来解决它们。
这个特殊错误告诉我我的形状必须是空数组或空形状。这甚至可能吗?如果这不是故障,我该如何解决?
这就是我在其他项目中提示形状时解决以前错误的方法。此解决方案不适用于空数组/形状

    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);

最佳答案

当我将 Vision AI 的 tfjs 模型导出到 tfjs 模型并遵循 this article 时,我遇到了同样的问题。加载模型。
解决方法:
作为一种解决方法,我将模型从 Vision AI 导出为 SavedModel 格式,并使用 tensorflow_converter 将其转换为 tfjs 模型。关注 this guide .结果可以按预期加载并且工作正常。

关于tensorflow - model.execute(dict) 中提供的 dict ['ToFloat' ] 的形状必须是 [],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63907113/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com