From 1ac0e3e9a431162218286935e3068817042b2ebb Mon Sep 17 00:00:00 2001 From: Henry Ruhs Date: Sat, 30 May 2026 11:55:58 +0200 Subject: [PATCH] remove face store (#1132) (#1133) --- facefusion/benchmarker.py | 2 -- facefusion/face_analyser.py | 36 +++++++++++++++--------------------- facefusion/face_store.py | 24 ------------------------ facefusion/types.py | 6 ------ tests/test_face_analyser.py | 2 -- 5 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 facefusion/face_store.py diff --git a/facefusion/benchmarker.py b/facefusion/benchmarker.py index 2f404886..07d88181 100644 --- a/facefusion/benchmarker.py +++ b/facefusion/benchmarker.py @@ -9,7 +9,6 @@ import facefusion.choices from facefusion import content_analyser, core, state_manager from facefusion.cli_helper import render_table from facefusion.download import conditional_download, resolve_download_url -from facefusion.face_store import clear_static_faces from facefusion.filesystem import get_file_extension from facefusion.types import BenchmarkCycleSet from facefusion.vision import count_video_frame_total, detect_video_fps @@ -64,7 +63,6 @@ def cycle(cycle_count : int) -> BenchmarkCycleSet: if state_manager.get_item('benchmark_mode') == 'cold': content_analyser.analyse_image.cache_clear() content_analyser.analyse_video.cache_clear() - clear_static_faces() start_time = perf_counter() core.conditional_process() diff --git a/facefusion/face_analyser.py b/facefusion/face_analyser.py index 76b9b621..135261ed 100644 --- a/facefusion/face_analyser.py +++ b/facefusion/face_analyser.py @@ -9,7 +9,6 @@ from facefusion.face_detector import detect_faces, detect_faces_by_angle from facefusion.face_helper import apply_nms, convert_to_face_landmark_5, estimate_face_angle, get_nms_threshold from facefusion.face_landmarker import detect_face_landmark, estimate_face_landmark_68_5 from facefusion.face_recognizer import calculate_face_embedding -from facefusion.face_store import get_static_faces, set_static_faces from facefusion.types import BoundingBox, Face, FaceLandmark5, FaceLandmarkSet, FaceScoreSet, Score, VisionFrame @@ -98,29 +97,24 @@ def get_many_faces(vision_frames : List[VisionFrame]) -> List[Face]: for vision_frame in vision_frames: if numpy.any(vision_frame): - static_faces = get_static_faces(vision_frame) - if static_faces: - many_faces.extend(static_faces) - else: - all_bounding_boxes = [] - all_face_scores = [] - all_face_landmarks_5 = [] + all_bounding_boxes = [] + all_face_scores = [] + all_face_landmarks_5 = [] - for face_detector_angle in state_manager.get_item('face_detector_angles'): - if face_detector_angle == 0: - bounding_boxes, face_scores, face_landmarks_5 = detect_faces(vision_frame) - else: - bounding_boxes, face_scores, face_landmarks_5 = detect_faces_by_angle(vision_frame, face_detector_angle) - all_bounding_boxes.extend(bounding_boxes) - all_face_scores.extend(face_scores) - all_face_landmarks_5.extend(face_landmarks_5) + for face_detector_angle in state_manager.get_item('face_detector_angles'): + if face_detector_angle == 0: + bounding_boxes, face_scores, face_landmarks_5 = detect_faces(vision_frame) + else: + bounding_boxes, face_scores, face_landmarks_5 = detect_faces_by_angle(vision_frame, face_detector_angle) + all_bounding_boxes.extend(bounding_boxes) + all_face_scores.extend(face_scores) + all_face_landmarks_5.extend(face_landmarks_5) - if all_bounding_boxes and all_face_scores and all_face_landmarks_5 and state_manager.get_item('face_detector_score') > 0: - faces = create_faces(vision_frame, all_bounding_boxes, all_face_scores, all_face_landmarks_5) + if all_bounding_boxes and all_face_scores and all_face_landmarks_5 and state_manager.get_item('face_detector_score') > 0: + faces = create_faces(vision_frame, all_bounding_boxes, all_face_scores, all_face_landmarks_5) - if faces: - many_faces.extend(faces) - set_static_faces(vision_frame, faces) + if faces: + many_faces.extend(faces) return many_faces diff --git a/facefusion/face_store.py b/facefusion/face_store.py deleted file mode 100644 index 2b4a6bab..00000000 --- a/facefusion/face_store.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import List, Optional - -from facefusion.hash_helper import create_hash -from facefusion.types import Face, FaceStore, VisionFrame - -FACE_STORE : FaceStore =\ -{ - 'static_faces': {} -} - - -def get_static_faces(vision_frame : VisionFrame) -> Optional[List[Face]]: - vision_hash = create_hash(vision_frame.tobytes()) - return FACE_STORE.get('static_faces').get(vision_hash) - - -def set_static_faces(vision_frame : VisionFrame, faces : List[Face]) -> None: - vision_hash = create_hash(vision_frame.tobytes()) - if vision_hash: - FACE_STORE['static_faces'][vision_hash] = faces - - -def clear_static_faces() -> None: - FACE_STORE['static_faces'].clear() diff --git a/facefusion/types.py b/facefusion/types.py index 6b684c78..9a1a2aaf 100755 --- a/facefusion/types.py +++ b/facefusion/types.py @@ -46,12 +46,6 @@ Face = namedtuple('Face', 'age', 'race' ]) -FaceSet : TypeAlias = Dict[str, List[Face]] -FaceStore = TypedDict('FaceStore', -{ - 'static_faces' : FaceSet -}) - Language = Literal['en'] Locales : TypeAlias = Dict[Language, Dict[str, Any]] LocalePoolSet : TypeAlias = Dict[str, Locales] diff --git a/tests/test_face_analyser.py b/tests/test_face_analyser.py index f0f4a7b8..af435224 100644 --- a/tests/test_face_analyser.py +++ b/tests/test_face_analyser.py @@ -5,7 +5,6 @@ import pytest from facefusion import face_classifier, face_detector, face_landmarker, face_recognizer, state_manager from facefusion.download import conditional_download from facefusion.face_analyser import get_many_faces -from facefusion.face_store import clear_static_faces from facefusion.vision import read_static_image from .assert_helper import get_test_example_file, get_test_examples_directory @@ -41,7 +40,6 @@ def before_each() -> None: face_detector.clear_inference_pool() face_landmarker.clear_inference_pool() face_recognizer.clear_inference_pool() - clear_static_faces() def test_get_one_face_with_retinaface() -> None: