Tensorflow JS:错误:无效的TF_Status:3消息:In[0]和In[1]具有不同的ndims:[1,8



我将保存的模型转换为Tensorflow JS&正在尝试从中获取结果。我正在使用NodeJS加载model.json文件。我为它创建了一个端点,并向它发送了一个图像url

const tf = require("@tensorflow/tfjs-node");
var model;
loadModel();
async function loadModel() {
model = await tf.loadGraphModel('https://LinkTo/YourModel/model.json');
console.log("Model Loading Done!!")
}
async function detectcellPhone(imgurl) {
const imgTensor = tf.node.decodeImage(new Uint8Array(fs.readFileSync(imgurl)), 3);
const predictions = await model.executeAsync(imgTensor.expandDims(0));
return predictions;
}

我能够成功地加载模型,但当我试图从中获得预测时,我遇到了以下错误:

Error: Invalid TF_Status: 3 Message: In[0] and In[1] has different ndims: [1,8,8,64,2] vs. [2,1]

我在下面回答了我自己的问题。

花了几个小时找出错误后,我意识到@tensorflow/tfjs-node的版本是3.13.0。将其更新为3.13.19的最新版本后,错误消失。也许没什么大不了的,但我想我应该把它发布出来,这样其他人就能从中受益。

最新更新