Open Natemo2625 opened 3 years ago
You'd have to have your bot pull the HTML/CSS and parse for JPG/PNG/GIF files. Once you parse the files you would loop through them and use that information to report.
You're not the first person to ask about this, perhaps I should make this a feature of the library? Just thinking on this. Perhaps it's a useful enough skill.
Yeah, I have a command that screenshots whatever site you want, and if it's NSFW it returns This site is NSFW
, but it doesn't check for images, just URLs
Currently, to use this you'd have to parse the HTML/CSS. I'll mark this ticket as a feature request and revisit it next Hacktoberfest.
I've just added this to my discord bot as well. This is how you can do it yourself.
const tf = require("@tensorflow/tfjs-node")
const nsfwjs = require("nsfwjs")
const fetch = require("node-fetch")
// Attachment has to contain image url, height and width
async function classifyImage(attachment) {
const model = await nsfwjs.load()
const imageBuffer = await fetch(attachment.url).then((res) => res.buffer());
const imageTensor = tf.node.decodeImage(imageBuffer)
return await model.classify(imageTensor)
}
This is a bit different from my implementation, but i think it should work.
So let's say I wanted to use this with a discord bot that checks a url for nsfw content. Can I do that with this, and how could I do it?