Closed matluuk closed 1 hour ago
The sentence Since the alignment method has no impact on the face recognition performance
is totally false. As you can confirm from here, alignment increases facial recognition pipeline's accuracy up to 6%.
If you still insist to skip alignment, you already have an option in the input argument. If you set align to False in any function, then this is going to skip alignment as mentioned here. Similarly, you can skip detection as well while setting detector_backend argument to skip as mentioned here.
I could have described the suggestion better. I am using alignment in both situations that I measured.
The with the sentence Since the alignment method has no impact on the face recognition performance
was badly shaped. I tried to refer to comment https://github.com/serengil/deepface/pull/1269#issuecomment-2206364746 that expressed that the usage of ´Image.BICUBIC´ resampling doesn't affect the face recognition performance. Thus it would not matter from face recognition perspective if we are using
img = np.array(Image.fromarray(img).rotate(angle))
or
img = np.array(Image.fromarray(img).rotate(angle, resample=Image.BICUBIC))
. Changing the image rotation to the latter has significant performance impact I measured with timeit.
To clarifying further: Both timeit measurements were done with alingment enabled. Faster run (7.931031430998701 seconds) was done with the old image rotation that doesn't use ´Image.BICUBIC´ resampling. The slower run (41.79532476099848 seconds) was done with newer image rotation that uses ´Image.BICUBIC´ resampling.
Okay, I could understand it now.
Your request is fair enough. Thank you for the explanation.
In the current source code, this seems retired already - https://github.com/serengil/deepface/blob/master/deepface/modules/detection.py#L346
Description
In pull request #1269, the face alignment method was changed to use
Image.BICUBIC
resampling. While this change may improve image quality, it significantly impacts performance.Performance Testing
I tested the performance impact by running the ´DeepFace.represent´ function with timeit for 100 rounds. The “yunet” detector and “SFace” face recognition model were used.
Results
Image.BICUBIC
resampling:Execution time: 7.931031430998701 seconds
withImage.BICUBIC
resampling:Execution time: 41.79532476099848 seconds
Suggestion
Since the alignment method has no impact on the face recognition performance, it would be beneficial to make the resampling method configurable. This way, users can choose whether to use Image.BICUBIC resampling based on their performance needs.
Environment Details
Additional Info
No response