patch-3.7.1 (#1178)

* patch 3.7.1

* fix bug for 2 processors on image to image pipeline (#1177)

* reduce default value of target_frame_amount

* restore old performance

* restore old performance

* restore old performance

* restore old performance
This commit is contained in:
Henry Ruhs
2026-07-05 16:43:36 +02:00
committed by henryruhs
parent ac9f514d60
commit 3834e3856a
4 changed files with 20 additions and 14 deletions
+1 -1
View File
@@ -606,7 +606,7 @@ def create_frame_distribution_program() -> ArgumentParser:
'--target-frame-amount',
help = translator.get('help.target_frame_amount'),
type = int,
default = config.get_int_value('frame_distribution', 'target_frame_amount', '5'),
default = config.get_int_value('frame_distribution', 'target_frame_amount', '2'),
choices = facefusion.choices.target_frame_amount_range,
metavar = create_int_metavar(facefusion.choices.target_frame_amount_range)
)
+6
View File
@@ -19,6 +19,12 @@ def get_video_capture(video_path : str) -> cv2.VideoCapture:
return VIDEO_POOL_SET.get('capture').get(video_path)
def conditional_set_video_frame_position(video_capture : cv2.VideoCapture, frame_position : int) -> bool:
if not video_capture.get(cv2.CAP_PROP_POS_FRAMES) == frame_position:
return video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position)
return True
def get_video_writer(video_path : str) -> cv2.VideoWriter:
if video_path not in VIDEO_POOL_SET.get('writer'):
video_writer = cv2.VideoWriter()
+10 -10
View File
@@ -11,7 +11,7 @@ from facefusion.filesystem import get_file_extension, is_image, is_video
from facefusion.media_helper import restrict_trim_frame
from facefusion.thread_helper import thread_lock, thread_semaphore
from facefusion.types import ColorMode, Duration, Fps, Mask, Orientation, Resolution, Scale, VisionFrame
from facefusion.video_manager import get_video_capture
from facefusion.video_manager import conditional_set_video_frame_position, get_video_capture
def read_static_images(image_paths : List[str], color_mode : ColorMode = 'rgb') -> List[VisionFrame]:
@@ -81,11 +81,11 @@ def read_video_frame(video_path : str, frame_number : int = 0) -> Optional[Visio
video_capture = get_video_capture(video_path)
if video_capture and video_capture.isOpened():
frame_total = video_capture.get(cv2.CAP_PROP_FRAME_COUNT)
frame_position = min(frame_total, frame_number)
video_frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
video_frame_position = min(video_frame_total, frame_number)
with thread_semaphore():
video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position)
conditional_set_video_frame_position(video_capture, video_frame_position)
has_vision_frame, vision_frame = video_capture.read()
if has_vision_frame:
@@ -106,13 +106,13 @@ def read_video_chunk(video_path : str, chunk_number : int, chunk_size : int) ->
video_capture = get_video_capture(video_path)
if video_capture and video_capture.isOpened():
frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
frame_position = chunk_number * chunk_size
video_frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
video_frame_position = chunk_number * chunk_size
with thread_semaphore():
video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position)
conditional_set_video_frame_position(video_capture, video_frame_position)
for frame_number in range(frame_position, min(frame_position + chunk_size, frame_total)):
for frame_number in range(video_frame_position, min(video_frame_position + chunk_size, video_frame_total)):
has_vision_frame, vision_frame = video_capture.read()
if has_vision_frame:
@@ -121,9 +121,9 @@ def read_video_chunk(video_path : str, chunk_number : int, chunk_size : int) ->
return video_frame_chunk
def select_video_frames(video_path : str, frame_number : int = 0, frame_offset : int = 5) -> List[VisionFrame]:
def select_video_frames(video_path : str, frame_number : int = 0, frame_offset : int = 2) -> List[VisionFrame]:
vision_frames = []
chunk_size = (frame_offset * 2 + 1) * 4
chunk_size = frame_offset * 2 + 1
if is_video(video_path):
with thread_lock():
+3 -3
View File
@@ -77,10 +77,10 @@ def conditional_get_reference_vision_frame() -> VisionFrame:
return read_static_image(state_manager.get_item('target_path'))
def conditional_get_target_vision_frames(temp_frame_path : str, frame_number : int) -> List[VisionFrame]:
def conditional_get_target_vision_frames(frame_number : int) -> List[VisionFrame]:
if state_manager.get_item('workflow') in [ 'image-to-video', 'image-to-video:frames' ]:
return select_video_frames(state_manager.get_item('target_path'), frame_number, state_manager.get_item('target_frame_amount'))
return [ read_static_image(temp_frame_path) ]
return [ read_static_image(state_manager.get_item('target_path')) ]
def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool:
@@ -88,7 +88,7 @@ def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool:
source_vision_frames = read_static_images(state_manager.get_item('source_paths'))
source_audio_frame = conditional_get_source_audio_frame(frame_number)
source_voice_frame = conditional_get_source_voice_frame(frame_number)
target_vision_frames = conditional_get_target_vision_frames(temp_frame_path, frame_number)
target_vision_frames = conditional_get_target_vision_frames(frame_number)
temp_vision_frame = read_static_image(temp_frame_path, 'rgba').copy()
temp_vision_mask = extract_vision_mask(temp_vision_frame)