Refactor face extraction and alignment logic; enhance bounding box transformation and facial landmark adjustments #1414
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.
Tickets
#1413
What has been done
In this PR, I have modified the code so that bounding box around image also gets rotated on image rotation during alignment.
Here are some result:
Original Image I used (left rotated):
Here is the earlier aligned image extracted (plotted aligned_sub_img from extract_face() function that is return of align_img_wrt_eyes function)
After the change in PR, this is how it looks now:
Tested the performance on random images to identify the same person using embeddings from the image below.
Image 1:
Image 2:
Image 3:
Here are the results:
Cosine Similarity Comparison Table
Observations:
@serengil Not entirely sure if this has resulted in significant improvements. While the alignment issue appears to be resolved, there may still be other areas requiring adjustments. I had anticipated cosine similarity improvements across all models, but the results seem mixed.
I would appreciate it if you could thoroughly test this with your expertise and recommend any additional changes that might be necessary.
Thank you!
How to test