Open fushatech opened 6 years ago
Asalamu'alaykum, hope things are well.
I'm interested in solving this problem, and will gladly lend a hand. Here's a relatively old article on content moderation APIs available: (make sure Tahir is turned on) https://towardsdatascience.com/comparison-of-the-best-nsfw-image-moderation-apis-2018-84be8da65303.
Yeah it could be slow/expensive running this for every image, but that whitelist #9 feature might make it more feasible. I've always imagined something like Tahir being used as a community tool to mark images and train its own model.
Walaikum as salam Haris!
Jazak Allah Khair for your help! If you think you can tackle this, please go for it! I was talking to another brother who was saying that TensorFlow JS may be a possible way to train a model to detect human skin. There is a commercial API that apparently detects nudity / partial nudity (https://www.webpurify.com/). Perhaps we can build something Shariah-compliant and open source.
Wa-iyakum :) Webpurify looks like a pretty cool solution! So to sum up the ideas so far:
Challenges
Let me know if there's something I missed. Based on this, I think the most feasible solution is to have the user input an API key for a service like Google's Vision API and have the extension scan images one-by-one, unblurring them after they are analyzed. That way, processing has a low performance overhead, costs of the API are proxied to the user, and having some analysis is always better than none. The results can be cached so they're unblurred automatically next time they're loaded in.
Regarding building our own model -- I don't think it's worth the effort to start from scratch. Perhaps starting with Yahoo's open-source analyzer or the tensorflow-equivalent should be used. Then trusted users can continuously train the model? I'm not sure, I think this approach has too many things that need to be thought of, for example, the nature of the data itself is a problem. But the cool thing about this approach is the ability of extension users to help in the process of training the model.
I'd love to hear your thoughts.
Excellent thoughts. I think the issue with existing models, like Google Vision or WebPurify is that their definition of permissible/awrah is different from ours. For example, these APIs would most likely mark an image of a woman wearing a knee high skirt as "safe" whereas for us, that is still impermissible to see.
That's why I think we would need to build our model since nothing meets Shariah standards. But like you said, it makes a lot more sense to build off existing models than to start from scratch. I am thinking as a next step, instead of having every image blurred, we can blur every image with human skin (male or female) by building off existing models that detect skin. And then, after that, look to see if we can train the model to learn Shariah definitions of awrah as well as other things that are impermissible (alcohol, drugs, gambling, etc).
I think we can fine tune this model. It's possible to use it with tensorflowjs.
Also, I think it'll be helpful to have the same references to the fiqh definitions of awrah for every school of thought.
Asalamu'alaykum brother, hope things are well. Wow, two months went by so fast.
Just a small update: I got around to using the standard mobilenet classifier in the browser via tensorflow js. It works pretty well and is fast enough for an application like this alhamdulillah. The next step was to convert the keras model above but the tensorflowjs_converter
tool wasn't capable of converting one of the layers. I think it was a lambda layer or something? Anyway, I'll get around to that in the coming months insha'Allah.
any updates :)
Darn, it's been a while~
The main motivation for my work on this was for a sideproject. Unfortunately, lots of things have piled up and I've put automatic image analysis on the back burner. There's lots of things to consider with this issue and it's no easy feat :-)
Asalamu'alaykum guys @Wulf @fushatech @amine123ait, I know it's been ages, but I recently had the idea to build an extension that blurs out Haram content, I didn't know about Tahir at the time but I started building the project anyway, my idea was to use face detection to generalize the detection and definition of impermissible content, so basically blur out any picture that has a (insert gender here) face.
I have already published the project HumanBlur and the extension is currently pending review on the chrome web store, but I really need a lot of help with it as I am new to chrome extensions and not super knowledgeable with AI and ML. My idea kinda works, it works on images and videos too, but obviously, the accuracy could use a lot of improvement, bodies are not detected, so unless the face is detected and the gender is identified, the image goes undetected. To resolve this I am probably going to add nudity/partial nudity models on top of the face detection and I think that should give decent results, but as I said, I am new to this so its taking me some time to figure it out. Oh and I don't like the current name but I decided to go for something more "inclusive" to not get hate lol.
I am letting you know about this so perhaps you can help contribute to it maybe since you guys were looking to do or at least use something similar, Jazakum Allahu Khairan.
Wa'alaykum asalaam @alganzory :)
That's a cool way to tackle the problem! Don't let the accuracy get you down -- just iterate slowly. What I've learnt over the past few years is that end users just want something that sorta works :)
Please let us know when the extension is on the store. Also, if you have the time, could I request a Firefox version?
May Allah bless you bro! 🤗
Wa'alaykum asalaam @alganzory :)
That's a cool way to tackle the problem! Don't let the accuracy get you down -- just iterate slowly. What I've learnt over the past few years is that end users just want something that sorta works :)
Please let us know when the extension is on the store. Also, if you have the time, could I request a Firefox version?
May Allah bless you bro! 🤗
Thanks for the tips bro, I am working on integrating a nudity filter right now and also trying to develop the firefox version, but it's already published Alhamdullilah :) HumanBlur in Chrome Store
May Allah bless you too brother.
Assalamu alaikum
@alganzory this looks great! May Allah (swt) reward you. If you need help with things related to AI/ML I am can do that in shaa Allah since I am experienced in that area. But I don't have much experience in the webdev area.
The chrome extension is awesome, especially in its ability to work on videos. I'm wondering if there's a way to tailor this project to be more focused on filtering out nudity than faces alone, but I realize after reading this that a solution of that nature may be too resource-heavy. Has anyone discovered a way to filter out nudity only in a tool similar to the HaramBlur chrome extension?
@alganzory Walaikum as salam wa rahmatullah brother - this is amazing work, ta barak Allah, may Allah accept it from you and make it heavy on your scales on Yawm al Qiyama. Great job!
Currently Tahir works by blurring all images, and thus preventing accidentally viewing any impermissible images. It would be ideal if Tahir blurred haram images only. However, this is difficult to do because: (1) existing skin detection APIs seem limited (decent failure rate, works for limited skin colors) & (2) running each image through a skin detector API will probably slow down browsing.
More research is needed to see if there are robust APIs that reliably & efficiently detect skin or if we should build our own (perhaps using OpenCV).