diff --git a/facefusion/benchmarker.py b/facefusion/benchmarker.py index 4ba16bd4..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_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_faces() start_time = perf_counter() core.conditional_process() diff --git a/facefusion/face_analyser.py b/facefusion/face_analyser.py index 5f58e1cd..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_faces, set_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): - faces = get_faces(vision_frame) - if faces: - many_faces.extend(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_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 0356378e..00000000 --- a/facefusion/face_store.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import List, Optional - -from facefusion.hash_helper import create_hash -from facefusion.types import Face, FaceStore, VisionFrame - -FACE_STORE : FaceStore = {} - - -def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]: - vision_hash = create_hash(vision_frame.tobytes()) - return FACE_STORE.get(vision_hash) - - -def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None: - vision_hash = create_hash(vision_frame.tobytes()) - if vision_hash: - FACE_STORE[vision_hash] = faces - - -def clear_faces() -> None: - FACE_STORE.clear() diff --git a/facefusion/types.py b/facefusion/types.py index 1df7f475..ad372bd8 100755 --- a/facefusion/types.py +++ b/facefusion/types.py @@ -44,8 +44,6 @@ Face = namedtuple('Face', 'age', 'race' ]) -FaceStore : TypeAlias = Dict[str, List[Face]] - Language = Literal['en'] Locales : TypeAlias = Dict[Language, Dict[str, Any]] LocalePoolSet : TypeAlias = Dict[str, Locales] diff --git a/facefusion/uis/components/face_selector.py b/facefusion/uis/components/face_selector.py index cdaaf812..10494b4d 100644 --- a/facefusion/uis/components/face_selector.py +++ b/facefusion/uis/components/face_selector.py @@ -9,7 +9,6 @@ from facefusion import state_manager, translator from facefusion.common_helper import calculate_float_step, calculate_int_step from facefusion.face_analyser import get_many_faces from facefusion.face_selector import sort_and_filter_faces -from facefusion.face_store import clear_faces from facefusion.filesystem import is_image, is_video from facefusion.types import FaceSelectorMode, FaceSelectorOrder, Gender, Race, VisionFrame from facefusion.uis.core import get_ui_component, get_ui_components, register_ui_component @@ -193,7 +192,6 @@ def clear_reference_frame_number() -> None: def clear_and_update_reference_position_gallery() -> gradio.Gallery: - clear_faces() return update_reference_position_gallery() diff --git a/facefusion/uis/components/preview.py b/facefusion/uis/components/preview.py index 5adef646..f5945ba1 100755 --- a/facefusion/uis/components/preview.py +++ b/facefusion/uis/components/preview.py @@ -11,7 +11,6 @@ from facefusion.common_helper import get_first from facefusion.content_analyser import analyse_frame from facefusion.face_analyser import get_one_face from facefusion.face_selector import select_faces -from facefusion.face_store import clear_faces from facefusion.filesystem import filter_audio_paths, is_image, is_video from facefusion.processors.core import get_processors_modules from facefusion.types import AudioFrame, Face, Mask, VisionFrame @@ -218,7 +217,6 @@ def update_preview_image(preview_mode : PreviewMode, preview_resolution : str, f def clear_and_update_preview_image(preview_mode : PreviewMode, preview_resolution : str, frame_number : int = 0) -> gradio.Image: - clear_faces() return update_preview_image(preview_mode, preview_resolution, frame_number) diff --git a/facefusion/uis/components/target.py b/facefusion/uis/components/target.py index e69e3c56..9a996635 100644 --- a/facefusion/uis/components/target.py +++ b/facefusion/uis/components/target.py @@ -3,7 +3,6 @@ from typing import Optional, Tuple import gradio from facefusion import state_manager, translator -from facefusion.face_store import clear_faces from facefusion.filesystem import is_image, is_video from facefusion.uis.core import register_ui_component from facefusion.uis.types import ComponentOptions, File @@ -51,8 +50,6 @@ def listen() -> None: def update(file : File) -> Tuple[gradio.Image, gradio.Video]: - clear_faces() - if file and is_image(file.name): state_manager.set_item('target_path', file.name) return gradio.Image(value = file.name, visible = True), gradio.Video(value = None, visible = False) diff --git a/facefusion/uis/components/trim_frame.py b/facefusion/uis/components/trim_frame.py index 9ad37a6e..c5e8341a 100644 --- a/facefusion/uis/components/trim_frame.py +++ b/facefusion/uis/components/trim_frame.py @@ -3,7 +3,6 @@ from typing import Optional, Tuple from gradio_rangeslider import RangeSlider from facefusion import state_manager, translator -from facefusion.face_store import clear_faces from facefusion.filesystem import is_video from facefusion.uis.core import get_ui_components from facefusion.uis.types import ComponentOptions @@ -53,7 +52,6 @@ def remote_update() -> RangeSlider: def update_trim_frame(trim_frame : Tuple[float, float]) -> None: - clear_faces() trim_frame_start, trim_frame_end = trim_frame video_frame_total = count_video_frame_total(state_manager.get_item('target_path')) trim_frame_start = int(trim_frame_start) if trim_frame_start > 0 else None diff --git a/tests/test_face_analyser.py b/tests/test_face_analyser.py index c12aa72d..22d06ad5 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_faces from facefusion.vision import read_static_image from .helper import get_test_example_file, get_test_examples_directory @@ -38,7 +37,6 @@ def before_each() -> None: face_detector.clear_inference_pool() face_landmarker.clear_inference_pool() face_recognizer.clear_inference_pool() - clear_faces() def test_get_one_face_with_retinaface() -> None: