diff --git a/gui-demo.png b/gui-demo.png index 38f1c6338..59b24c592 100644 Binary files a/gui-demo.png and b/gui-demo.png differ diff --git a/roop/core.py b/roop/core.py index 23a0883d6..1843545cc 100755 --- a/roop/core.py +++ b/roop/core.py @@ -57,8 +57,8 @@ def parse_args() -> None: roop.globals.source_path = args.source_path roop.globals.target_path = args.target_path - roop.globals.output_path = normalize_output_path(roop.globals.source_path, roop.globals.target_path, args.output_path) # type: ignore - roop.globals.headless = roop.globals.source_path and roop.globals.target_path and roop.globals.output_path + roop.globals.output_path = normalize_output_path(roop.globals.source_path, roop.globals.target_path, args.output_path) + roop.globals.headless = roop.globals.source_path is not None and roop.globals.target_path is not None and roop.globals.output_path is not None roop.globals.frame_processors = args.frame_processor roop.globals.keep_fps = args.keep_fps roop.globals.keep_frames = args.keep_frames @@ -109,7 +109,7 @@ def limit_resources() -> None: memory = roop.globals.max_memory * 1024 ** 6 if platform.system().lower() == 'windows': import ctypes - kernel32 = ctypes.windll.kernel32 + kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined] kernel32.SetProcessWorkingSetSize(-1, ctypes.c_size_t(memory), ctypes.c_size_t(memory)) else: import resource diff --git a/roop/globals.py b/roop/globals.py index f7c68e650..3eca8d0d0 100644 --- a/roop/globals.py +++ b/roop/globals.py @@ -1,22 +1,22 @@ -from typing import List +from typing import List, Optional -source_path = None -target_path = None -output_path = None -headless = None +source_path: Optional[str] = None +target_path: Optional[str] = None +output_path: Optional[str] = None +headless: Optional[bool] = None frame_processors: List[str] = [] -keep_fps = None -keep_frames = None -skip_audio = None -many_faces = None -reference_face_position = None -reference_frame_number = None -similar_face_distance = None -temp_frame_format = None -temp_frame_quality = None -output_video_encoder = None -output_video_quality = None -max_memory = None +keep_fps: Optional[bool] = None +keep_frames: Optional[bool] = None +skip_audio: Optional[bool] = None +many_faces: Optional[bool] = None +reference_face_position: Optional[int] = None +reference_frame_number: Optional[int] = None +similar_face_distance: Optional[float] = None +temp_frame_format: Optional[str] = None +temp_frame_quality: Optional[int] = None +output_video_encoder: Optional[str] = None +output_video_quality: Optional[int] = None +max_memory: Optional[int] = None execution_providers: List[str] = [] -execution_threads = None -log_level = 'error' +execution_threads: Optional[int] = None +log_level: str = 'error' diff --git a/roop/metadata.py b/roop/metadata.py index 1de4d8409..03f321bc2 100644 --- a/roop/metadata.py +++ b/roop/metadata.py @@ -1,2 +1,2 @@ name = 'roop' -version = '1.3.0' +version = '1.3.1' diff --git a/roop/processors/frame/face_swapper.py b/roop/processors/frame/face_swapper.py index 3aa5257db..b8072076f 100644 --- a/roop/processors/frame/face_swapper.py +++ b/roop/processors/frame/face_swapper.py @@ -75,7 +75,7 @@ def process_frame(source_face: Face, reference_face: Face, temp_frame: Frame) -> def process_frames(source_path: str, temp_frame_paths: List[str], update: Callable[[], None]) -> None: source_face = get_one_face(cv2.imread(source_path)) - reference_face = get_face_reference() + reference_face = None if roop.globals.many_faces else get_face_reference() for temp_frame_path in temp_frame_paths: temp_frame = cv2.imread(temp_frame_path) result = process_frame(source_face, reference_face, temp_frame) @@ -87,13 +87,13 @@ def process_frames(source_path: str, temp_frame_paths: List[str], update: Callab def process_image(source_path: str, target_path: str, output_path: str) -> None: source_face = get_one_face(cv2.imread(source_path)) target_frame = cv2.imread(target_path) - reference_face = get_one_face(target_frame, roop.globals.reference_face_position) + reference_face = None if roop.globals.many_faces else get_one_face(target_frame, roop.globals.reference_face_position) result = process_frame(source_face, reference_face, target_frame) cv2.imwrite(output_path, result) def process_video(source_path: str, temp_frame_paths: List[str]) -> None: - if not get_face_reference(): + if not roop.globals.many_faces and not get_face_reference(): reference_frame = cv2.imread(temp_frame_paths[roop.globals.reference_frame_number]) reference_face = get_one_face(reference_frame, roop.globals.reference_face_position) set_face_reference(reference_face) diff --git a/roop/ui.py b/roop/ui.py index 67ec32a52..cebe6a20c 100644 --- a/roop/ui.py +++ b/roop/ui.py @@ -152,7 +152,7 @@ def select_source_path(source_path: Optional[str] = None) -> None: if source_path is None: source_path = ctk.filedialog.askopenfilename(title='select an source image', initialdir=RECENT_DIRECTORY_SOURCE) if is_image(source_path): - roop.globals.source_path = source_path # type: ignore + roop.globals.source_path = source_path RECENT_DIRECTORY_SOURCE = os.path.dirname(roop.globals.source_path) image = render_image_preview(roop.globals.source_path, (200, 200)) source_label.configure(image=image) @@ -170,12 +170,12 @@ def select_target_path(target_path: Optional[str] = None) -> None: if target_path is None: target_path = ctk.filedialog.askopenfilename(title='select an target image or video', initialdir=RECENT_DIRECTORY_TARGET) if is_image(target_path): - roop.globals.target_path = target_path # type: ignore + roop.globals.target_path = target_path RECENT_DIRECTORY_TARGET = os.path.dirname(roop.globals.target_path) image = render_image_preview(roop.globals.target_path, (200, 200)) target_label.configure(image=image) elif is_video(target_path): - roop.globals.target_path = target_path # type: ignore + roop.globals.target_path = target_path RECENT_DIRECTORY_TARGET = os.path.dirname(roop.globals.target_path) video_frame = render_video_preview(target_path, (200, 200)) target_label.configure(image=video_frame) @@ -273,8 +273,8 @@ def update_preview(frame_number: int = 0) -> None: def update_face_reference(steps: int) -> None: clear_face_reference() - reference_frame_number = preview_slider.get() - roop.globals.reference_face_position += steps # type: ignore + reference_frame_number = int(preview_slider.get()) + roop.globals.reference_face_position += steps roop.globals.reference_frame_number = reference_frame_number update_preview(reference_frame_number)