This commit is contained in:
Dragon Fire
2021-03-22 18:29:34 -04:00
parent 1ab7bd4563
commit bbe2702397
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ module.exports = class NsfwCommand extends Command {
try {
const { body } = await request.get(image);
const prediction = await isImageNSFW(this.client.nsfwModel, body, false);
return msg.reply(`I'm **${prediction.probability}%** sure this image is: **${prediction.className}**.`);
const prob = Math.round(prediction.probability * 100);
return msg.reply(`I'm **${prob}%** sure this image is: **${prediction.className}**.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+1 -1
View File
@@ -221,7 +221,7 @@ module.exports = class Util {
const img = await tf.node.decodeImage(image, 3);
const predictions = await model.classify(img, 1);
img.dispose();
return bool ? predictions[0] !== 'Neutral' && predictions[0] !== 'Drawing' : predictions[0];
return bool ? predictions[0].className !== 'Neutral' && predictions[0].className !== 'Drawing' : predictions[0];
}
static async reactIfAble(msg, user, emoji, fallbackEmoji) {