Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alganzory opened this issue Nov 1, 2023 · 12 comments
Open

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

alganzory opened this issue Nov 1, 2023 · 12 comments
Labels
enhancement New feature or request

Comments

@alganzory
Copy link
Owner

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

@alganzory alganzory added enhancement New feature or request hard and removed hard labels Nov 1, 2023
@man2machine
Copy link

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
Copy link

mahmouds12 commented Nov 10, 2023

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
Copy link

Waaleikum salaam warahmatullahy wabarakatuh

@man2machine
Copy link

man2machine commented Nov 11, 2023

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
Copy link
Owner Author

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

  • There exists some nudity detection models that are able to label parts like nudenet, but often they are very heavy to be used in such environment
  • I could add body detection to the equation and then block the face and the body if the face is haram, but again, adding extra models to this will make it even slower.
  • my very initial point about drawing over the images instead of just adding a css class and how it would make it even slower.

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

@man2machine
Copy link

man2machine commented Nov 11, 2023

@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
Copy link

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
Copy link

ALWISHARIFF commented Dec 19, 2023

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
Copy link

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
Copy link
Owner Author

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
Copy link
Owner Author

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)

Repository owner deleted a comment from liverfail Mar 11, 2024
@alganzory
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants