diff --git a/roop/core.py b/roop/core.py index f0550ad..aa73cb3 100755 --- a/roop/core.py +++ b/roop/core.py @@ -70,7 +70,7 @@ def parse_args() -> None: roop.globals.execution_providers = decode_execution_providers(args.execution_provider) roop.globals.execution_threads = args.execution_threads - # warn and cast deprecated args + # translate deprecated args if args.source_path_deprecated: print('\033[33mArgument -f and --face are deprecated. Use -s and --source instead.\033[0m') roop.globals.source_path = args.source_path_deprecated diff --git a/roop/processors/frame/face_enhancer.py b/roop/processors/frame/face_enhancer.py index 508c855..586e569 100644 --- a/roop/processors/frame/face_enhancer.py +++ b/roop/processors/frame/face_enhancer.py @@ -17,7 +17,7 @@ NAME = 'ROOP.FACE-ENHANCER' def pre_check() -> bool: download_directory_path = resolve_relative_path('../models') - conditional_download(download_directory_path, ['https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth']) + conditional_download(download_directory_path, ['https://huggingface.co/henryruhs/roop/resolve/main/GFPGANv1.3.pth']) return True @@ -37,8 +37,7 @@ def get_face_enhancer() -> None: # todo: set models path https://github.com/TencentARC/GFPGAN/issues/399 FACE_ENHANCER = gfpgan.GFPGANer( model_path=model_path, - channel_multiplier=2, - upscale=2 + channel_multiplier=2 ) return FACE_ENHANCER diff --git a/roop/processors/frame/face_swapper.py b/roop/processors/frame/face_swapper.py index 5797eac..291e054 100644 --- a/roop/processors/frame/face_swapper.py +++ b/roop/processors/frame/face_swapper.py @@ -16,7 +16,7 @@ NAME = 'ROOP.FACE-SWAPPER' def pre_check() -> bool: download_directory_path = resolve_relative_path('../models') - conditional_download(download_directory_path, ['https://huggingface.co/deepinsight/inswapper/resolve/main/inswapper_128.onnx']) + conditional_download(download_directory_path, ['https://huggingface.co/henryruhs/roop/resolve/main/inswapper_128.onnx']) return True diff --git a/roop/ui.py b/roop/ui.py index ecb2656..95133d1 100644 --- a/roop/ui.py +++ b/roop/ui.py @@ -199,13 +199,13 @@ def init_preview() -> None: def update_preview(frame_number: int = 0) -> None: if roop.globals.source_path and roop.globals.target_path: - video_frame = get_video_frame(roop.globals.target_path, frame_number) + temp_frame = get_video_frame(roop.globals.target_path, frame_number) for frame_processor in get_frame_processors_modules(roop.globals.frame_processors): - video_frame = frame_processor.process_frame( + temp_frame = frame_processor.process_frame( get_one_face(cv2.imread(roop.globals.source_path)), - video_frame + temp_frame ) - image = Image.fromarray(cv2.cvtColor(video_frame, cv2.COLOR_BGR2RGB)) + image = Image.fromarray(cv2.cvtColor(temp_frame, cv2.COLOR_BGR2RGB)) image = ImageOps.contain(image, (PREVIEW_MAX_WIDTH, PREVIEW_MAX_HEIGHT), Image.LANCZOS) image = ctk.CTkImage(image, size=image.size) preview_label.configure(image=image) diff --git a/roop/utilities.py b/roop/utilities.py index 0d7ac09..f97e175 100644 --- a/roop/utilities.py +++ b/roop/utilities.py @@ -20,13 +20,15 @@ if platform.system().lower() == 'darwin': ssl._create_default_https_context = ssl._create_unverified_context -def run_ffmpeg(args: List[str]) -> None: +def run_ffmpeg(args: List[str]) -> bool: commands = ['ffmpeg', '-hide_banner', '-hwaccel', 'auto', '-loglevel', roop.globals.log_level] commands.extend(args) try: subprocess.check_output(commands, stderr=subprocess.STDOUT) + return True except Exception: pass + return False def detect_fps(target_path: str) -> float: @@ -53,8 +55,8 @@ def create_video(target_path: str, fps: float = 30.0) -> None: def restore_audio(target_path: str, output_path: str) -> None: temp_output_path = get_temp_output_path(target_path) - run_ffmpeg(['-i', temp_output_path, '-i', target_path, '-c:v', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path]) - if not os.path.isfile(output_path): + done = run_ffmpeg(['-i', temp_output_path, '-i', target_path, '-c:v', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-y', output_path]) + if not done: move_temp(target_path, output_path)