mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-19 15:27:14 +02:00
restore analysing
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from concurrent.futures import Future, ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
@@ -21,45 +21,43 @@ from facefusion.workflows.core import is_process_stopping
|
|||||||
|
|
||||||
|
|
||||||
def process(start_time : float) -> ErrorCode:
|
def process(start_time : float) -> 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'))
|
tasks =\
|
||||||
|
[
|
||||||
|
setup,
|
||||||
|
extract_frames,
|
||||||
|
process_disk_frames,
|
||||||
|
merge_frames,
|
||||||
|
enforce_analysis,
|
||||||
|
restore_audio,
|
||||||
|
partial(finalize_video, start_time)
|
||||||
|
]
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers = 1) as analyse_executor:
|
if state_manager.get_item('workflow_mode') == 'stream':
|
||||||
analyse_future = analyse_executor.submit(analyse_video, state_manager.get_item('target_path'), trim_frame_start, trim_frame_end)
|
|
||||||
tasks =\
|
tasks =\
|
||||||
[
|
[
|
||||||
setup,
|
setup,
|
||||||
extract_frames,
|
process_stream_frames,
|
||||||
process_disk_frames,
|
enforce_analysis,
|
||||||
merge_frames,
|
|
||||||
partial(enforce_analysis, analyse_future),
|
|
||||||
restore_audio,
|
restore_audio,
|
||||||
partial(finalize_video, start_time)
|
partial(finalize_video, start_time)
|
||||||
]
|
]
|
||||||
|
process_manager.start()
|
||||||
|
|
||||||
if state_manager.get_item('workflow_mode') == 'stream':
|
for task in tasks:
|
||||||
tasks =\
|
error_code = task() #type:ignore[operator]
|
||||||
[
|
|
||||||
setup,
|
|
||||||
process_stream_frames,
|
|
||||||
partial(enforce_analysis, analyse_future),
|
|
||||||
restore_audio,
|
|
||||||
partial(finalize_video, start_time)
|
|
||||||
]
|
|
||||||
process_manager.start()
|
|
||||||
|
|
||||||
for task in tasks:
|
if error_code > 0:
|
||||||
error_code = task() #type:ignore[operator]
|
process_manager.end()
|
||||||
|
return error_code
|
||||||
|
|
||||||
if error_code > 0:
|
process_manager.end()
|
||||||
process_manager.end()
|
|
||||||
return error_code
|
|
||||||
|
|
||||||
process_manager.end()
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def enforce_analysis(analyse_future : Future[bool]) -> ErrorCode:
|
def enforce_analysis() -> ErrorCode:
|
||||||
if analyse_future.result():
|
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):
|
||||||
clear_temp_directory(state_manager.get_item('target_path'))
|
clear_temp_directory(state_manager.get_item('target_path'))
|
||||||
return 3
|
return 3
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user