Focus Peaking filter #55
Open
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.