feat: Enhance AutoMatch and Identify components with quality criteria for face matching

This commit updates the AutoMatch component to include a new criterion for auto-matching faces based on picture quality, requiring a minimum quality score of 50%. The Identify component has been modified to persist user settings in localStorage, improving user experience by retaining preferences across sessions. Additionally, the Modify component introduces functionality for selecting and unmatching faces in bulk, enhancing the management of face items. Documentation has been updated to reflect these changes.
This commit is contained in:
tanyar09
2025-11-11 12:48:26 -05:00
parent 20a8e4df5d
commit 17aeb5b823
5 changed files with 210 additions and 69 deletions
+9
View File
@@ -517,8 +517,10 @@ def auto_match_faces(
If auto_accept=True:
- Only processes persons with frontal or tilted reference faces (not profile)
- Only processes persons with reference face quality > 50% (quality_score > 0.5)
- Only matches with frontal or tilted unidentified faces (not profile)
- Only auto-accepts matches with similarity >= threshold
- Only auto-accepts faces with quality > 50% (quality_score > 0.5)
"""
from src.web.db.models import Person, Photo
from sqlalchemy import func
@@ -542,6 +544,7 @@ def auto_match_faces(
# Filter matches by criteria:
# 1. Match face must be frontal (already filtered by find_similar_faces)
# 2. Similarity must be >= threshold
# 3. Quality must be > 50% (quality_score > 0.5)
qualifying_faces = []
for face, distance, confidence_pct in similar_faces:
@@ -550,6 +553,12 @@ def auto_match_faces(
skipped_matches += 1
continue
# Check quality threshold (only accept faces with quality > 50%)
face_quality = float(face.quality_score) if face.quality_score is not None else 0.0
if face_quality <= 0.5:
skipped_matches += 1
continue
qualifying_faces.append(face.id)
# Auto-accept qualifying faces
+13 -2
View File
@@ -1728,7 +1728,8 @@ def find_auto_match_matches(
Args:
tolerance: Similarity tolerance (default: 0.6)
filter_frontal_only: Only include persons with frontal or tilted reference face (not profile)
filter_frontal_only: Only include persons with frontal or tilted reference face (not profile).
When True (auto-accept mode), also requires reference faces to have quality > 0.5
Returns:
List of (person_id, reference_face_id, reference_face, matches) tuples
@@ -1747,15 +1748,25 @@ def find_auto_match_matches(
# JOIN photos p ON f.photo_id = p.id
# WHERE f.person_id IS NOT NULL AND f.quality_score >= 0.3
# ORDER BY f.person_id, f.quality_score DESC
#
# For auto-accept mode (filter_frontal_only=True), also require quality > 0.5
quality_threshold = 0.3
identified_faces: List[Face] = (
db.query(Face)
.join(Photo, Face.photo_id == Photo.id)
.filter(Face.person_id.isnot(None))
.filter(Face.quality_score >= 0.3)
.filter(Face.quality_score >= quality_threshold)
.order_by(Face.person_id, Face.quality_score.desc())
.all()
)
# For auto-accept mode, filter out reference faces with quality <= 0.5
if filter_frontal_only:
identified_faces = [
f for f in identified_faces
if f.quality_score is not None and float(f.quality_score) > 0.5
]
if not identified_faces:
return []