mirror of
https://github.com/facefusion/facefusion.git
synced 2026-06-02 02:41:38 +02:00
@@ -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()
|
||||
|
||||
+15
-21
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
@@ -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]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user