我正在使用可教学机器导出模型。
const modelJson = require("./assets/models/model.json");
const modelWeights = require("./assets/models/weights.bin");
useEffect(() => {
let checkTf = async () => {
await tf.ready();
const model = await tf.loadLayersModel(bundleResourceIO(modelJson, modelWeights));
setModel(model);
setDisplayText("loaded Models");
setTfReady(true);
};
checkTf();
}, []);
预测图像异步函数中加载的模型:
const imageTensor = images.next().value;
const prediction = (await model.predict())[0]; //ERROR
const highestPropPred = prediction[0];
无法加载预测此错误:
[Unhandled promise rejection: Error: Error when checking : expected input_1 to have 4 dimension(s), but got array with shape [200,152,3]]
我建议您尝试使用重塑功能将图像重塑为 [1 ,200 , 150, 3] 。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)