From 189d75062169e5759b2b8e26d334898d2ac96171 Mon Sep 17 00:00:00 2001 From: Henry Ruhs Date: Wed, 29 Oct 2025 11:51:42 +0100 Subject: [PATCH] 3.4.2 (#975) * Reduce caching to avoid RAM explosion * Reduce caching to avoid RAM explosion * Reduce caching to avoid RAM explosion * fix bounding_box scale * Bump to 3.4.2 * More conservative on audio caching * Fix coverage issue * Fix coverage issue --------- Co-authored-by: harisreedhar --- .coveragerc | 2 ++ facefusion/audio.py | 4 ++-- facefusion/download.py | 4 ++-- facefusion/face_analyser.py | 8 +------- facefusion/metadata.py | 2 +- facefusion/vision.py | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..1da13b9 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +patch = subprocess diff --git a/facefusion/audio.py b/facefusion/audio.py index cb12ca9..739fc84 100644 --- a/facefusion/audio.py +++ b/facefusion/audio.py @@ -11,7 +11,7 @@ from facefusion.types import Audio, AudioFrame, Fps, Mel, MelFilterBank, Spectro from facefusion.voice_extractor import batch_extract_voice -@lru_cache() +@lru_cache(maxsize = 64) def read_static_audio(audio_path : str, fps : Fps) -> Optional[List[AudioFrame]]: return read_audio(audio_path, fps) @@ -31,7 +31,7 @@ def read_audio(audio_path : str, fps : Fps) -> Optional[List[AudioFrame]]: return None -@lru_cache() +@lru_cache(maxsize = 64) def read_static_voice(audio_path : str, fps : Fps) -> Optional[List[AudioFrame]]: return read_voice(audio_path, fps) diff --git a/facefusion/download.py b/facefusion/download.py index 37179e8..42458d0 100644 --- a/facefusion/download.py +++ b/facefusion/download.py @@ -41,7 +41,7 @@ def conditional_download(download_directory_path : str, urls : List[str]) -> Non progress.update(current_size - progress.n) -@lru_cache(maxsize = 1024) +@lru_cache(maxsize = 64) def get_static_download_size(url : str) -> int: commands = curl_builder.chain( curl_builder.head(url), @@ -59,7 +59,7 @@ def get_static_download_size(url : str) -> int: return 0 -@lru_cache(maxsize = 1024) +@lru_cache(maxsize = 64) def ping_static_url(url : str) -> bool: commands = curl_builder.chain( curl_builder.head(url), diff --git a/facefusion/face_analyser.py b/facefusion/face_analyser.py index 855ebd7..76b9b62 100644 --- a/facefusion/face_analyser.py +++ b/facefusion/face_analyser.py @@ -128,13 +128,7 @@ def scale_face(target_face : Face, target_vision_frame : VisionFrame, temp_visio scale_x = temp_vision_frame.shape[1] / target_vision_frame.shape[1] scale_y = temp_vision_frame.shape[0] / target_vision_frame.shape[0] - bounding_box =\ - [ - target_face.bounding_box * scale_x, - target_face.bounding_box * scale_y, - target_face.bounding_box * scale_x, - target_face.bounding_box * scale_y - ] + bounding_box = target_face.bounding_box * [ scale_x, scale_y, scale_x, scale_y ] landmark_set =\ { '5': target_face.landmark_set.get('5') * numpy.array([ scale_x, scale_y ]), diff --git a/facefusion/metadata.py b/facefusion/metadata.py index 625746a..2b2526b 100644 --- a/facefusion/metadata.py +++ b/facefusion/metadata.py @@ -4,7 +4,7 @@ METADATA =\ { 'name': 'FaceFusion', 'description': 'Industry leading face manipulation platform', - 'version': '3.4.1', + 'version': '3.4.2', 'license': 'OpenRAIL-AS', 'author': 'Henry Ruhs', 'url': 'https://facefusion.io' diff --git a/facefusion/vision.py b/facefusion/vision.py index 3166248..fa06c72 100644 --- a/facefusion/vision.py +++ b/facefusion/vision.py @@ -22,7 +22,7 @@ def read_static_images(image_paths : List[str]) -> List[VisionFrame]: return vision_frames -@lru_cache(maxsize = 1024) +@lru_cache(maxsize = 64) def read_static_image(image_path : str) -> Optional[VisionFrame]: return read_image(image_path) @@ -65,7 +65,7 @@ def restrict_image_resolution(image_path : str, resolution : Resolution) -> Reso return resolution -@lru_cache(maxsize = 1024) +@lru_cache(maxsize = 64) def read_static_video_frame(video_path : str, frame_number : int = 0) -> Optional[VisionFrame]: return read_video_frame(video_path, frame_number)