diff --git a/README.md b/README.md index e183e89..802a327 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -
Real-time face swap and video deepfake with a single click and only a single image. diff --git a/modules/metadata.py b/modules/metadata.py index 206f7d2..e839f8d 100644 --- a/modules/metadata.py +++ b/modules/metadata.py @@ -1,3 +1,3 @@ name = 'Deep-Live-Cam' -version = '2.0.3c' +version = '2.1' edition = 'GitHub Edition' \ No newline at end of file diff --git a/modules/ui.py b/modules/ui.py index 1a4c7ca..7143076 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -10,6 +10,8 @@ import json import queue import threading import numpy as np +import requests +import tempfile import modules.globals import modules.metadata from modules.face_analyser import ( @@ -192,9 +194,15 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C select_face_button = ctk.CTkButton( root, text=_("Select a face"), cursor="hand2", command=lambda: select_source_path() ) - select_face_button.place(relx=0.1, rely=0.30, relwidth=0.3, relheight=0.1) + select_face_button.place(relx=0.1, rely=0.30, relwidth=0.24, relheight=0.1) ToolTip(select_face_button, _("Choose the source face image to swap onto the target")) + random_face_button = ctk.CTkButton( + root, text="🔄", cursor="hand2", width=30, command=lambda: fetch_random_face() + ) + random_face_button.place(relx=0.35, rely=0.30, relwidth=0.05, relheight=0.1) + ToolTip(random_face_button, _("Get a random face from thispersondoesnotexist.com")) + swap_faces_button = ctk.CTkButton( root, text="↔", cursor="hand2", command=lambda: swap_faces_paths() ) @@ -766,6 +774,26 @@ def update_tumbler(var: str, value: bool) -> None: ) +def fetch_random_face() -> None: + PREVIEW.withdraw() + try: + response = requests.get( + "https://thispersondoesnotexist.com/", + headers={"User-Agent": "Mozilla/5.0"}, + timeout=10, + ) + response.raise_for_status() + temp_dir = tempfile.gettempdir() + temp_path = os.path.join(temp_dir, "deep_live_cam_random_face.jpg") + with open(temp_path, "wb") as f: + f.write(response.content) + modules.globals.source_path = temp_path + image = render_image_preview(temp_path, (200, 200)) + source_label.configure(image=image) + except Exception as e: + print(f"Failed to fetch random face: {e}") + + def select_source_path() -> None: global RECENT_DIRECTORY_SOURCE, img_ft, vid_ft