Tensorflow无法重塑图像



嗨,我无法使用tensorflow和移动网络来解码和分类url。我在图像的discord.js中获取url,并使用节点提取来提取它,然后缓冲它,然后解码它。任何人都能告诉我这个错误意味着什么分辨率,这样我就可以调整它的大小吗?我有这个代码

const fetch = require('node-fetch')
const mobilenet = require('@tensorflow-models/mobilenet');
const tfnode = require('@tensorflow/tfjs-node')
module.exports.run = async(client, message) => {
message.reply('kk')
let filter = m => m.author.id === message.author.id
const collector = new MessageCollector(message.channel, filter, {max: 1})
collector.on('end', async m => {
m.forEach(async(m)=> {    
m.attachments.forEach(async(u) => {console.log(u.url)            
let res=  await fetch(u.url)
const buffer = await res.buffer()
const tens = tfnode.node.decodeImage(buffer)
const model = await mobilenet.load();
const predictions = await model.classify(tens);

console.log('Predictions: ');
console.log(predictions);
})
})

})
};

module.exports.help = {
name: "classify",
aliases: ["cl"],
description: "classify images",
usage: "(command name)",
category: "Ai-commands",
cooldown: 0// Counted in MS
};
module.exports.config = {
restricted: false,
ownerOnly: false
};

并且得到这个错误

[UNHANDLED REJECTION] Error: Invalid TF_Status: 3
Message: Input to reshape is a tensor with 200704 values, but the requested shape requires a multiple of 150528

使用jimp将其调整为720p并将其提供给tfjs

相关内容

  • 没有找到相关文章

最新更新