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

Focus Peaking filter #55

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open

Focus Peaking filter #55

wants to merge 13 commits into from

Conversation

shigabeev
Copy link

Hey! Nice job you have done here! I like the DFP so much so far. I'm on my way to adding my own feature set to filter for portrait images.

This new filter would detect the presence of face on image, would make sure that there is only one face on image and detect focus on this face.

For face detection I use retinaface from DeepFace. Unfortunately DeepFace doesn't support GPU, but in my experience, the biggest bottleneck is IO for huge images, so I was fine with not using GPU.

Next step is to detect whether the image has face as its main focus. I use focus peaking algorithm for it and it worked best for me. For threshold I noticed that images with ratio above 1500 are in focus. With better optics and aperture sizes this value can reach up to 30000. Blurry images have ratio of 200 - 800.

I also changed tqdm to tqdm.auto so that it has a nicer progress bar in jupyter.

I know my filters are pretty specific, but let me know your input and I can make the code more generic.

@boomb0om
Copy link
Contributor

Hi! Thanks a lot for help. Can you please create pull request into dev branch?

@boomb0om
Copy link
Contributor

Also you need to add extra requirements for your filter into pyproject.toml file

@shigabeev shigabeev changed the base branch from main to dev July 11, 2024 16:20
@shigabeev
Copy link
Author

I forgot about the requirements. Will do!

@shigabeev
Copy link
Author

Done!

@shigabeev
Copy link
Author

New changes include boolean columns f"{filter_name}_pass" with with recommended threshold ratios so that when I import and use the repository externally, I can just use the "True|False" value in this column to determine whether I should keep or reject an image without getting into details of provided metrics.

@shigabeev
Copy link
Author

Hey @boomb0om,

If these changes aren’t merged by New Year, I’ll have to close the source code of my repository. The only reason it’s open now is to merge the code here so that my company doesn’t have to maintain its own fork.

I get that my changes might not be your internal priority right now, but since the goal is to make this repo a big, community-supported project, I think the additions could be useful in the long run. Let me know if there’s anything I should tweak to make merging easier.

Cheers!

@shigabeev
Copy link
Author

shigabeev commented Dec 18, 2024

Yeah, also it has all the changes from the neighboring PR #65 So if you merge this branch, close #65

Added Grayscale detection filter. It detects if image is grayscale even if it has 3 dimensions and was compressed.
Added Oily skin detection filter. Useful for portrait images.

Usage:

grayscale_filter = GrayscaleFilter(workers=1,
                                batch_size=1)
oily_skin_filter = OilySkinFilter(workers=1,
                                batch_size=16,
                                 model_name="dima806/skin_types_image_detection")

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

Successfully merging this pull request may close these issues.

2 participants