From bbe27023972e6842abe53c2450af98b15948c44b Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 22 Mar 2021 18:29:34 -0400 Subject: [PATCH] Fix --- commands/analyze/nsfw.js | 3 ++- util/Util.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/analyze/nsfw.js b/commands/analyze/nsfw.js index 3da02fa5..701ead69 100644 --- a/commands/analyze/nsfw.js +++ b/commands/analyze/nsfw.js @@ -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!`); } diff --git a/util/Util.js b/util/Util.js index 3e76d2fc..d5d14e46 100644 --- a/util/Util.js +++ b/util/Util.js @@ -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) {