Compare commits

..

1 Commits

Author SHA1 Message Date
rehanbgmi 52a2ef3a95
Merge 0fc481db47 into 12fda0a3ed 2025-06-18 15:38:47 +02:00
4 changed files with 388 additions and 609 deletions

View File

@ -176,12 +176,9 @@ def update_status(message: str, scope: str = 'DLC.CORE') -> None:
ui.update_status(message) ui.update_status(message)
def start() -> None: def start() -> None:
# Note: pre_start is called in run() before start() now. for frame_processor in get_frame_processors_modules(modules.globals.frame_processors):
# If it were to be called here, it would also need the status_fn_callback. if not frame_processor.pre_start():
# For example: return
# for frame_processor in get_frame_processors_modules(modules.globals.frame_processors):
# if not frame_processor.pre_start(status_fn_callback=update_status): # If pre_start was here
# return
update_status('Processing...') update_status('Processing...')
# process image to image # process image to image
if has_image_extension(modules.globals.target_path): if has_image_extension(modules.globals.target_path):
@ -193,7 +190,7 @@ def start() -> None:
print("Error copying file:", str(e)) print("Error copying file:", str(e))
for frame_processor in get_frame_processors_modules(modules.globals.frame_processors): for frame_processor in get_frame_processors_modules(modules.globals.frame_processors):
update_status('Progressing...', frame_processor.NAME) update_status('Progressing...', frame_processor.NAME)
frame_processor.process_image(modules.globals.source_path, modules.globals.output_path, modules.globals.output_path, status_fn_callback=update_status) frame_processor.process_image(modules.globals.source_path, modules.globals.output_path, modules.globals.output_path)
release_resources() release_resources()
if is_image(modules.globals.target_path): if is_image(modules.globals.target_path):
update_status('Processing to image succeed!') update_status('Processing to image succeed!')
@ -213,7 +210,7 @@ def start() -> None:
temp_frame_paths = get_temp_frame_paths(modules.globals.target_path) temp_frame_paths = get_temp_frame_paths(modules.globals.target_path)
for frame_processor in get_frame_processors_modules(modules.globals.frame_processors): for frame_processor in get_frame_processors_modules(modules.globals.frame_processors):
update_status('Progressing...', frame_processor.NAME) update_status('Progressing...', frame_processor.NAME)
frame_processor.process_video(modules.globals.source_path, temp_frame_paths, status_fn_callback=update_status) frame_processor.process_video(modules.globals.source_path, temp_frame_paths)
release_resources() release_resources()
# handles fps # handles fps
if modules.globals.keep_fps: if modules.globals.keep_fps:
@ -252,9 +249,7 @@ def run() -> None:
if not pre_check(): if not pre_check():
return return
for frame_processor in get_frame_processors_modules(modules.globals.frame_processors): for frame_processor in get_frame_processors_modules(modules.globals.frame_processors):
if not frame_processor.pre_check(): # pre_check in face_swapper does not use update_status if not frame_processor.pre_check():
return
if hasattr(frame_processor, 'pre_start') and not frame_processor.pre_start(status_fn_callback=update_status): # Pass callback here
return return
limit_resources() limit_resources()
if modules.globals.headless: if modules.globals.headless:

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,6 @@ from modules.face_analyser import (
) )
from modules.capturer import get_video_frame, get_video_frame_total from modules.capturer import get_video_frame, get_video_frame_total
from modules.processors.frame.core import get_frame_processors_modules from modules.processors.frame.core import get_frame_processors_modules
from modules.processors.frame.face_swapper import reset_tracker_state # Added import
from modules.utilities import ( from modules.utilities import (
is_image, is_image,
is_video, is_video,
@ -241,7 +240,6 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
command=lambda: ( command=lambda: (
setattr(modules.globals, "many_faces", many_faces_value.get()), setattr(modules.globals, "many_faces", many_faces_value.get()),
save_switch_states(), save_switch_states(),
reset_tracker_state() # Added reset call
), ),
) )
many_faces_switch.place(relx=0.6, rely=0.65) many_faces_switch.place(relx=0.6, rely=0.65)
@ -268,8 +266,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
command=lambda: ( command=lambda: (
setattr(modules.globals, "map_faces", map_faces.get()), setattr(modules.globals, "map_faces", map_faces.get()),
save_switch_states(), save_switch_states(),
close_mapper_window() if not map_faces.get() else None, close_mapper_window() if not map_faces.get() else None
reset_tracker_state() # Added reset call
), ),
) )
map_faces_switch.place(relx=0.1, rely=0.75) map_faces_switch.place(relx=0.1, rely=0.75)
@ -607,11 +604,9 @@ def select_source_path() -> None:
RECENT_DIRECTORY_SOURCE = os.path.dirname(modules.globals.source_path) RECENT_DIRECTORY_SOURCE = os.path.dirname(modules.globals.source_path)
image = render_image_preview(modules.globals.source_path, (200, 200)) image = render_image_preview(modules.globals.source_path, (200, 200))
source_label.configure(image=image) source_label.configure(image=image)
reset_tracker_state() # Added reset call
else: else:
modules.globals.source_path = None modules.globals.source_path = None
source_label.configure(image=None) source_label.configure(image=None)
reset_tracker_state() # Added reset call even if source is cleared
def swap_faces_paths() -> None: def swap_faces_paths() -> None:
@ -984,8 +979,6 @@ def create_webcam_preview(camera_index: int):
frame_count = 0 frame_count = 0
fps = 0 fps = 0
reset_tracker_state() # Ensure tracker is reset before starting webcam loop
while True: while True:
ret, frame = cap.read() ret, frame = cap.read()
if not ret: if not ret:

View File

@ -2,7 +2,7 @@
numpy>=1.23.5,<2 numpy>=1.23.5,<2
typing-extensions>=4.8.0 typing-extensions>=4.8.0
opencv-contrib-python==4.10.0.84 opencv-python==4.10.0.84
cv2_enumerate_cameras==1.1.15 cv2_enumerate_cameras==1.1.15
onnx==1.16.0 onnx==1.16.0
insightface==0.7.3 insightface==0.7.3