mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-27 04:21:03 +02:00
adopt the workflow task vocabulary from next major (#1185)
Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from facefusion import logger, process_manager, translator
|
||||
from facefusion import logger, process_manager, state_manager, translator
|
||||
from facefusion.temp_helper import clear_temp_directory, create_temp_directory
|
||||
from facefusion.types import ErrorCode
|
||||
|
||||
|
||||
def is_process_stopping() -> bool:
|
||||
@@ -6,3 +8,15 @@ def is_process_stopping() -> bool:
|
||||
process_manager.end()
|
||||
logger.info(translator.get('processing_stopped'), __name__)
|
||||
return process_manager.is_pending()
|
||||
|
||||
|
||||
def setup() -> ErrorCode:
|
||||
if create_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('creating_temp'), __name__)
|
||||
return 0
|
||||
|
||||
|
||||
def clear() -> ErrorCode:
|
||||
if clear_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('clearing_temp'), __name__)
|
||||
return 0
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
from functools import partial
|
||||
|
||||
from facefusion import ffmpeg
|
||||
from facefusion import logger, process_manager, state_manager, translator
|
||||
from facefusion import content_analyser, ffmpeg, logger, process_manager, state_manager, translator
|
||||
from facefusion.audio import create_empty_audio_frame
|
||||
from facefusion.content_analyser import analyse_image
|
||||
from facefusion.filesystem import is_image
|
||||
from facefusion.processors.core import get_processors_modules
|
||||
from facefusion.temp_helper import clear_temp_directory, create_temp_directory, get_temp_file_path
|
||||
from facefusion.temp_helper import get_temp_file_path
|
||||
from facefusion.time_helper import calculate_end_time
|
||||
from facefusion.types import ErrorCode
|
||||
from facefusion.vision import conditional_merge_vision_mask, detect_image_resolution, extract_vision_mask, pack_resolution, read_static_image, read_static_images, restrict_image_resolution, scale_resolution, write_image
|
||||
from facefusion.workflows.core import is_process_stopping
|
||||
from facefusion.workflows.core import clear, is_process_stopping, setup
|
||||
|
||||
|
||||
def process(start_time : float) -> ErrorCode:
|
||||
tasks =\
|
||||
[
|
||||
analyse_image,
|
||||
clear,
|
||||
setup,
|
||||
prepare_image,
|
||||
process_image,
|
||||
partial(finalize_image, start_time)
|
||||
partial(finalize_image, start_time),
|
||||
clear
|
||||
]
|
||||
process_manager.start()
|
||||
|
||||
@@ -34,16 +35,9 @@ def process(start_time : float) -> ErrorCode:
|
||||
return 0
|
||||
|
||||
|
||||
def setup() -> ErrorCode:
|
||||
if analyse_image(state_manager.get_item('target_path')):
|
||||
def analyse_image() -> ErrorCode:
|
||||
if content_analyser.analyse_image(state_manager.get_item('target_path')):
|
||||
return 3
|
||||
|
||||
if clear_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('clearing_temp'), __name__)
|
||||
|
||||
if create_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('creating_temp'), __name__)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -104,9 +98,6 @@ def finalize_image(start_time : float) -> ErrorCode:
|
||||
else:
|
||||
logger.warn(translator.get('finalizing_image_skipped'), __name__)
|
||||
|
||||
logger.debug(translator.get('clearing_temp'), __name__)
|
||||
clear_temp_directory(state_manager.get_item('target_path'))
|
||||
|
||||
if is_image(state_manager.get_item('output_path')):
|
||||
logger.info(translator.get('processing_image_succeeded').format(seconds = calculate_end_time(start_time)), __name__)
|
||||
else:
|
||||
|
||||
@@ -4,29 +4,30 @@ from functools import partial
|
||||
import numpy
|
||||
from tqdm import tqdm
|
||||
|
||||
from facefusion import ffmpeg
|
||||
from facefusion import logger, process_manager, state_manager, translator, video_manager
|
||||
from facefusion import content_analyser, ffmpeg, logger, process_manager, state_manager, translator, video_manager
|
||||
from facefusion.audio import create_empty_audio_frame, get_audio_frame, get_voice_frame
|
||||
from facefusion.common_helper import get_first
|
||||
from facefusion.content_analyser import analyse_video
|
||||
from facefusion.filesystem import filter_audio_paths, is_video
|
||||
from facefusion.processors.core import get_processors_modules
|
||||
from facefusion.temp_helper import clear_temp_directory, create_temp_directory, move_temp_file, resolve_temp_frame_set
|
||||
from facefusion.temp_helper import move_temp_file, resolve_temp_frame_set
|
||||
from facefusion.time_helper import calculate_end_time
|
||||
from facefusion.types import ErrorCode
|
||||
from facefusion.vision import conditional_merge_vision_mask, detect_video_resolution, extract_vision_mask, pack_resolution, read_static_image, read_static_images, read_static_video_frame, restrict_trim_frame, restrict_video_fps, restrict_video_resolution, scale_resolution, select_video_frames, write_image
|
||||
from facefusion.workflows.core import is_process_stopping
|
||||
from facefusion.workflows.core import clear, is_process_stopping, setup
|
||||
|
||||
|
||||
def process(start_time : float) -> ErrorCode:
|
||||
tasks =\
|
||||
[
|
||||
analyse_video,
|
||||
clear,
|
||||
setup,
|
||||
extract_frames,
|
||||
process_video,
|
||||
process_frames,
|
||||
merge_frames,
|
||||
restore_audio,
|
||||
partial(finalize_video, start_time)
|
||||
partial(finalize_video, start_time),
|
||||
clear
|
||||
]
|
||||
process_manager.start()
|
||||
|
||||
@@ -41,18 +42,11 @@ def process(start_time : float) -> ErrorCode:
|
||||
return 0
|
||||
|
||||
|
||||
def setup() -> ErrorCode:
|
||||
def analyse_video() -> ErrorCode:
|
||||
trim_frame_start, trim_frame_end = restrict_trim_frame(state_manager.get_item('target_path'), state_manager.get_item('trim_frame_start'), state_manager.get_item('trim_frame_end'))
|
||||
|
||||
if analyse_video(state_manager.get_item('target_path'), trim_frame_start, trim_frame_end):
|
||||
if content_analyser.analyse_video(state_manager.get_item('target_path'), trim_frame_start, trim_frame_end):
|
||||
return 3
|
||||
|
||||
if clear_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('clearing_temp'), __name__)
|
||||
|
||||
if create_temp_directory(state_manager.get_item('target_path')):
|
||||
logger.debug(translator.get('creating_temp'), __name__)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -73,7 +67,7 @@ def extract_frames() -> ErrorCode:
|
||||
return 0
|
||||
|
||||
|
||||
def process_video() -> ErrorCode:
|
||||
def process_frames() -> ErrorCode:
|
||||
temp_frame_set = resolve_temp_frame_set(state_manager.get_item('target_path'))
|
||||
|
||||
if temp_frame_set:
|
||||
@@ -189,9 +183,6 @@ def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool:
|
||||
|
||||
|
||||
def finalize_video(start_time : float) -> ErrorCode:
|
||||
logger.debug(translator.get('clearing_temp'), __name__)
|
||||
clear_temp_directory(state_manager.get_item('target_path'))
|
||||
|
||||
if is_video(state_manager.get_item('output_path')):
|
||||
logger.info(translator.get('processing_video_succeeded').format(seconds = calculate_end_time(start_time)), __name__)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user