alganzory / HaramBlur

A Browser extension that enables you to navigate the web with respect for your Islamic values, protect your privacy and reduce browsing distractions by auto detecting and blurring "Haram" content.
https://haramblur.com
GNU Affero General Public License v3.0
382 stars 29 forks source link

Blur only the "Haram" part of the picture #20

Open alganzory opened 8 months ago

alganzory commented 8 months ago

This is quite highly requested because people still wanna see relevant info in "bad" pictures. This would probably require drawing over the photos /videos which could be resource intensive

man2machine commented 8 months ago

This would be difficult from an AI perspective as well, so this feature is most likely a bit far out timeline-wise. But it is technically possible.

mahmouds12 commented 8 months ago

Salam Alaikom @alganzory and @man2machine I know that this feature might be a challenging one. Here's a JS fiddle that I think might help https://jsfiddle.net/mahmouds12/2kdenjxL/64/

If we can know the position and size of the object to be blurred using AI, we can set $posLeft, $posTop, $blur-width, $blur-height accordingly. Do you think this can be achieved inside a chrome extension? and if possible, would this be resource intensive?

ALWISHARIFF commented 8 months ago

Waaleikum salaam warahmatullahy wabarakatuh

man2machine commented 8 months ago

Wa alaikum assalam

@mahmouds12 @alganzory It is technically possible, as I said before, however, currently in the roadmap, our first goal should be to build a better filter for images that blurs out the entire image (without detecting the area).

One of the most difficult parts of blurring out certain parts of an image is "labeling". The way machine learning currently works is that you have to take a bunch of images (thousands to millions) and have humans label the correct outputs for the given image. Then you make the algorithm learn from this information and have the algorithm perform detection for new images on its own.

Thus, labeling the images requires people to actually look at the haram images themselves and label it. Needless to say, looking at haram images, is haram. And definitely looking at thousands of these images is a bad thing for muslims and non-muslims. The functionality in the extension currently is possible because non-muslims have already looked at the haram images and have labeled a bunch of data and created algorithms for completely different purposes, that we are are currently utilizing.

The next step is to use the same label information that is available already (from non-muslims) and create our own algorithm that is suited for our particular task and is more performant. More research is needed to see what types of label data already exists. If we cannot find the proper label data, it wouldn't be possible to do the partial image blurring, since one would need to label thousands to millions of haram images to do this, and that is obviously not good.

The current AI model being used (BlazeFace) only performs face detection. So if we were to use that for partial image blurring, only the face would be blurred, and that means all the other parts of the body would still be left exposed, which is obviously very bad. Furthermore, if you read the research paper, the BlazeFace model does not detect the entire face properly, it is only meant to detect the general area of a face. Thus most likely, using the model would result in certain things showing like hair, neck, etc. and of course the rest of the body.

This is actually the main difficulty from an AI perspective. The resource intensity is something ML researchers are working on, and it is foreseeable in the future that can be solved in shaa Allah. Drawing over images and videos is something challenging compared to what the extension has currently, but it is technically possible. However, The AI labeling issue is the far more difficult challenge for this. Depending on the results of the research I plan to do in shaa Allah, it may be that it is not possible this at all.

alganzory commented 8 months ago

I'd like to add to @man2machine points that I am mostly in agreement with:

This is not to say it's impossible, I am just trying to say there are higher priority prerequisites to make this work.

man2machine commented 8 months ago

@alganzory For sure some level of body blocking is possible and there are models out there to do this as you were stating. So it is possible to get some preliminary version working. However, what my long comment earlier basically means is that this type of model may not be as performant due to the improper labeling. In particular, what I am concerned is if for example only part of the face or body is showing, and also body detection in the case where there is no face. These are the cases that I am still unsure of what is possible. Of course from a technical sense, if the labels are there and if we have more processing power, it is of course completely possible. But we are not sure if that is the case.

owghanem commented 6 months ago

Thus, labeling the images requires people to actually look at the haram images themselves and label it. Needless to say, looking at haram images, is haram. And definitely looking at thousands of these images is a bad thing for muslims and non-muslims. The functionality in the extension currently is possible because non-muslims have already looked at the haram images and have labeled a bunch of data and created algorithms for completely different purposes, that we are are currently utilizing.

Is it possible somehow to teach the model through user feedback? I mean instead of making people look at specific content and rating it, we look at the content unfortunately on a daily basis, why not just give the user a way to report back if the detection was accurate or not

ALWISHARIFF commented 6 months ago

Assalamu alaykum warahmatullahy wabarakatuh brothers we can use nudenets dataset to train our own model yolo8 is a great model Nudenet dataset

https://archive.org/details/NudeNet_classifier_dataset_v1

I think this dataset is enough ins Allah to blur the haram part and if it doesn't get very accurate we can create a user feedback where we will create a small extension that would simply get the frames of part of the video not blurred and the user can do that by just hitting a button which would get the current video frame that was not blurred (timestamp)and we can add that to our dataset ins Allah and slowly improve our dataset and model ins Allah

karim-bouchez commented 6 months ago

As salamou 3alaykoum

FYI, I made a similar Python package : https://github.com/itkho/hafdh-nadhar Just for the body detection (using yolov3) it's relatively quick (~10ms/img on Mac M1). But I don't know how the AI model is portable from Python to JS. If it is easily portable, I think that with the @mahmouds12 method, it could be added without too much slow down, wa Allahou A3lam.

What is the speed (ms/img) for the face recognition on this environment ? (I'm asking in order to have a reference)

alganzory commented 6 months ago

Salam Alaikom @alganzory and @man2machine I know that this feature might be a challenging one. Here's a JS fiddle that I think might help https://jsfiddle.net/mahmouds12/2kdenjxL/64/

If we can know the position and size of the object to be blurred using AI, we can set $posLeft, $posTop, $blur-width, $blur-height accordingly. Do you think this can be achieved inside a chrome extension? and if possible, would this be resource intensive?

The problem with this approach is that I'd have to replace every image element with this setup of divs and containers, I haven't tried it yet but I assume this will at the very least break some images or how the DOM looks

alganzory commented 6 months ago

Assalamu alaykum warahmatullahy wabarakatuh brothers we can use nudenets dataset to train our own model yolo8 is a great model Nudenet dataset

https://archive.org/details/NudeNet_classifier_dataset_v1

I think this dataset is enough ins Allah to blur the haram part and if it doesn't get very accurate we can create a user feedback where we will create a small extension that would simply get the frames of part of the video not blurred and the user can do that by just hitting a button which would get the current video frame that was not blurred (timestamp)and we can add that to our dataset ins Allah and slowly improve our dataset and model ins Allah

I know there's a model called Nudenet I believe based on this dataset, however when I tried it before the model was pretty big for the browser environment, I am not sure if we can make use of this dataset or the existing model to make a smaller one? (I don't have this experience, maybe @man2machine can offer some insights)

alganzory commented 3 months ago

The comment deleted above sounded like a troll to me so I impulsively deleted it. Nevertheless, they shared an interesting perspective about how blurring only a part of the image/frame could tempt you to want to disable the blur. It's honestly a fair concern but I also get why it's hard to watch videos with HaramBlur cause the entire frame would be blurred, so I am probably going for the approach where if NSFW detected -> blur the entire frame, if just face -> blur the face and some padding