fix: improve face clustering parameters to prevent incorrect grouping… #742
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.
Fixes #722
📋 Description
This PR addresses the bug where face clustering incorrectly groups unrelated images together when processing folders with many images. The issue was caused by overly permissive DBSCAN clustering parameters that allowed faces with relatively low similarity (>0.7) to be grouped together.
🔧 Changes Made
1. DBSCAN Clustering Parameters (
backend/app/utils/face_clusters.py)epsparameter: Reduced from0.3→0.15min_samplesparameter: Increased from2→32. Incremental Assignment Threshold (
backend/app/utils/face_clusters.py)similarity_threshold: Increased from0.7→0.853. Test Script Update (
backend/test.py)4. Documentation Update (
docs/backend/backend_python/image-processing.md)🎯 Impact
Before
After
✅ Testing
Testing Instructions for Reviewers
python backend/reset_database.pyNote: This fix improves clustering accuracy but may result in fewer clusters being formed initially. This is the desired behavior as it prevents incorrect groupings. As more images of the same person are added, proper clusters will form with the higher confidence threshold.
Summary by CodeRabbit
Bug Fixes
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.