Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63b90c428e | |||
| df8e8b427e | |||
| dfd145b996 | |||
| b3c4ed9250 | |||
| 2411f1e9b1 | |||
| 96224efe07 | |||
| 8e05142cda | |||
| a007db2ffa | |||
| 475740b22b | |||
| 600ce34c8d | |||
| 865ab3ca02 | |||
| 178578b034 | |||
| b53132f3a4 | |||
| 00da11b491 | |||
| b82fdc3f31 | |||
| 3ffa9f38b0 | |||
| 3f98d4c826 | |||
| 9b6ca286b9 | |||
| 0999c0447e |
@@ -1,4 +1,4 @@
|
||||
<h1 align="center">Deep-Live-Cam</h1>
|
||||
<h1 align="center">Deep-Live-Cam 2.0.1c</h1>
|
||||
|
||||
<p align="center">
|
||||
Real-time face swap and video deepfake with a single click and only a single image.
|
||||
@@ -30,7 +30,7 @@ By using this software, you agree to these terms and commit to using it in a man
|
||||
|
||||
Users are expected to use this software responsibly and legally. If using a real person's face, obtain their consent and clearly label any output as a deepfake when sharing online. We are not responsible for end-user actions.
|
||||
|
||||
## Exclusive v2.2 Quick Start - Pre-built (Windows/Mac Silicon)
|
||||
## Exclusive v2.3d Quick Start - Pre-built (Windows/Mac Silicon)
|
||||
|
||||
<a href="https://deeplivecam.net/index.php/quickstart"> <img src="media/Download.png" width="285" height="77" />
|
||||
|
||||
@@ -354,11 +354,13 @@ Looking for a CLI mode? Using the -s/--source argument will make the run program
|
||||
- [*"Alright look look look, now look chat, we can do any face we want to look like chat"*](https://www.youtube.com/live/mFsCe7AIxq8?feature=shared&t=2686) - IShowSpeed
|
||||
- [*"They do a pretty good job matching poses, expression and even the lighting"*](https://www.youtube.com/watch?v=wnCghLjqv3s&t=551s) - TechLinked (LTT)
|
||||
- [*"Als Sean Connery an der Redaktionskonferenz teilnahm"*](https://www.golem.de/news/deepfakes-als-sean-connery-an-der-redaktionskonferenz-teilnahm-2408-188172.html) - Golem.de (German)
|
||||
- [*"What the F***! Why do I look like Vinny Jr? I look exactly like Vinny Jr!? No, this shit is crazy! Bro This is F*** Crazy! "*](https://youtu.be/JbUPRmXRUtE?t=3964) - IShowSpeed
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
- [ffmpeg](https://ffmpeg.org/): for making video-related operations easy
|
||||
- [Henry](https://github.com/henryruhs): One of the major contributor in this repo
|
||||
- [deepinsight](https://github.com/deepinsight): for their [insightface](https://github.com/deepinsight/insightface) project which provided a well-made library and models. Please be reminded that the [use of the model is for non-commercial research purposes only](https://github.com/deepinsight/insightface?tab=readme-ov-file#license).
|
||||
- [havok2-htwo](https://github.com/havok2-htwo): for sharing the code for webcam
|
||||
- [GosuDRM](https://github.com/GosuDRM): for the open version of roop
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"Source x Target Mapper": "Pemetaan Sumber x Target",
|
||||
"select a source image": "Pilih gambar sumber",
|
||||
"Preview": "Pratinjau",
|
||||
"select a target image or video": "Pilih gambar atau video target",
|
||||
"save image output file": "Simpan file keluaran gambar",
|
||||
"save video output file": "Simpan file keluaran video",
|
||||
"select a target image": "Pilih gambar target",
|
||||
"source": "Sumber",
|
||||
"Select a target": "Pilih target",
|
||||
"Select a face": "Pilih wajah",
|
||||
"Keep audio": "Pertahankan audio",
|
||||
"Face Enhancer": "Peningkat wajah",
|
||||
"Many faces": "Banyak wajah",
|
||||
"Show FPS": "Tampilkan FPS",
|
||||
"Keep fps": "Pertahankan FPS",
|
||||
"Keep frames": "Pertahankan frame",
|
||||
"Fix Blueish Cam": "Perbaiki kamera kebiruan",
|
||||
"Mouth Mask": "Masker mulut",
|
||||
"Show Mouth Mask Box": "Tampilkan kotak masker mulut",
|
||||
"Start": "Mulai",
|
||||
"Live": "Langsung",
|
||||
"Destroy": "Hentikan",
|
||||
"Map faces": "Petakan wajah",
|
||||
"Processing...": "Sedang memproses...",
|
||||
"Processing succeed!": "Pemrosesan berhasil!",
|
||||
"Processing ignored!": "Pemrosesan diabaikan!",
|
||||
"Failed to start camera": "Gagal memulai kamera",
|
||||
"Please complete pop-up or close it.": "Harap selesaikan atau tutup pop-up.",
|
||||
"Getting unique faces": "Mengambil wajah unik",
|
||||
"Please select a source image first": "Silakan pilih gambar sumber terlebih dahulu",
|
||||
"No faces found in target": "Tidak ada wajah ditemukan pada target",
|
||||
"Add": "Tambah",
|
||||
"Clear": "Bersihkan",
|
||||
"Submit": "Kirim",
|
||||
"Select source image": "Pilih gambar sumber",
|
||||
"Select target image": "Pilih gambar target",
|
||||
"Please provide mapping!": "Harap tentukan pemetaan!",
|
||||
"At least 1 source with target is required!": "Minimal 1 sumber dengan target diperlukan!",
|
||||
"Face could not be detected in last upload!": "Wajah tidak dapat terdeteksi pada unggahan terakhir!",
|
||||
"Select Camera:": "Pilih Kamera:",
|
||||
"All mappings cleared!": "Semua pemetaan telah dibersihkan!",
|
||||
"Mappings successfully submitted!": "Pemetaan berhasil dikirim!",
|
||||
"Source x Target Mapper is already open.": "Pemetaan Sumber x Target sudah terbuka."
|
||||
}
|
||||
+4
-3
@@ -12,7 +12,7 @@ file_types = [
|
||||
]
|
||||
|
||||
# Face Mapping Data
|
||||
souce_target_map: List[Dict[str, Any]] = [] # Stores detailed map for image/video processing
|
||||
source_target_map: List[Dict[str, Any]] = [] # Stores detailed map for image/video processing
|
||||
simple_map: Dict[str, Any] = {} # Stores simplified map (embeddings/faces) for live/simple mode
|
||||
|
||||
# Paths
|
||||
@@ -26,7 +26,8 @@ keep_fps: bool = True
|
||||
keep_audio: bool = True
|
||||
keep_frames: bool = False
|
||||
many_faces: bool = False # Process all detected faces with default source
|
||||
map_faces: bool = False # Use souce_target_map or simple_map for specific swaps
|
||||
map_faces: bool = False # Use source_target_map or simple_map for specific swaps
|
||||
poisson_blend: bool = False # Enable Poisson Blending for smoother face swaps
|
||||
color_correction: bool = False # Enable color correction (implementation specific)
|
||||
nsfw_filter: bool = False
|
||||
|
||||
@@ -68,4 +69,4 @@ enable_interpolation: bool = True # Toggle temporal smoothing
|
||||
interpolation_weight: float = 0 # Blend weight for current frame (0.0-1.0). Lower=smoother.
|
||||
# --- END: Added for Frame Interpolation ---
|
||||
|
||||
# --- END OF FILE globals.py ---
|
||||
# --- END OF FILE globals.py ---
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
name = 'Deep-Live-Cam'
|
||||
version = '2.0c'
|
||||
version = '2.0.1c'
|
||||
edition = 'GitHub Edition'
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Optional
|
||||
import cv2
|
||||
import insightface
|
||||
import threading
|
||||
import numpy as np
|
||||
import platform
|
||||
import modules.globals
|
||||
import modules.processors.frame.core
|
||||
from modules.core import update_status
|
||||
@@ -14,9 +15,9 @@ from modules.utilities import (
|
||||
is_video,
|
||||
)
|
||||
from modules.cluster_analysis import find_closest_centroid
|
||||
# Removed modules.globals.face_swapper_enabled - assuming controlled elsewhere or implicitly true if used
|
||||
# Removed modules.globals.opacity - accessed via getattr
|
||||
import os
|
||||
from collections import deque
|
||||
import time
|
||||
|
||||
FACE_SWAPPER = None
|
||||
THREAD_LOCK = threading.Lock()
|
||||
@@ -26,6 +27,16 @@ NAME = "DLC.FACE-SWAPPER"
|
||||
PREVIOUS_FRAME_RESULT = None # Stores the final processed frame from the previous step
|
||||
# --- END: Added for Interpolation ---
|
||||
|
||||
# --- START: Mac M1-M5 Optimizations ---
|
||||
IS_APPLE_SILICON = platform.system() == 'Darwin' and platform.machine() == 'arm64'
|
||||
FRAME_CACHE = deque(maxlen=3) # Cache for frame reuse
|
||||
FACE_DETECTION_CACHE = {} # Cache face detections
|
||||
LAST_DETECTION_TIME = 0
|
||||
DETECTION_INTERVAL = 0.033 # ~30 FPS detection rate for live mode
|
||||
FRAME_SKIP_COUNTER = 0
|
||||
ADAPTIVE_QUALITY = True
|
||||
# --- END: Mac M1-M5 Optimizations ---
|
||||
|
||||
abs_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
models_dir = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(abs_dir))), "models"
|
||||
@@ -63,22 +74,40 @@ def get_face_swapper() -> Any:
|
||||
|
||||
with THREAD_LOCK:
|
||||
if FACE_SWAPPER is None:
|
||||
model_path = os.path.join(models_dir, "inswapper_128_fp16.onnx")
|
||||
model_name = "inswapper_128.onnx"
|
||||
if "CUDAExecutionProvider" in modules.globals.execution_providers:
|
||||
model_name = "inswapper_128_fp16.onnx"
|
||||
model_path = os.path.join(models_dir, model_name)
|
||||
update_status(f"Loading face swapper model from: {model_path}", NAME)
|
||||
try:
|
||||
# Ensure the providers list is correctly passed
|
||||
providers = modules.globals.execution_providers
|
||||
# print(f"Attempting to load model with providers: {providers}") # Debug print
|
||||
# Optimized provider configuration for Apple Silicon
|
||||
providers_config = []
|
||||
for p in modules.globals.execution_providers:
|
||||
if p == "CoreMLExecutionProvider" and IS_APPLE_SILICON:
|
||||
# Enhanced CoreML configuration for M1-M5
|
||||
providers_config.append((
|
||||
"CoreMLExecutionProvider",
|
||||
{
|
||||
"ModelFormat": "MLProgram",
|
||||
"MLComputeUnits": "ALL", # Use Neural Engine + GPU + CPU
|
||||
"SpecializationStrategy": "FastPrediction",
|
||||
"AllowLowPrecisionAccumulationOnGPU": 1,
|
||||
"EnableOnSubgraphs": 1,
|
||||
"RequireStaticShapes": 0,
|
||||
"MaximumCacheSize": 1024 * 1024 * 512, # 512MB cache
|
||||
}
|
||||
))
|
||||
else:
|
||||
providers_config.append(p)
|
||||
|
||||
FACE_SWAPPER = insightface.model_zoo.get_model(
|
||||
model_path, providers=providers
|
||||
model_path,
|
||||
providers=providers_config,
|
||||
)
|
||||
update_status("Face swapper model loaded successfully.", NAME)
|
||||
except Exception as e:
|
||||
update_status(f"Error loading face swapper model: {e}", NAME)
|
||||
# print traceback maybe?
|
||||
# import traceback
|
||||
# traceback.print_exc()
|
||||
FACE_SWAPPER = None # Ensure it remains None on failure
|
||||
FACE_SWAPPER = None
|
||||
return None
|
||||
return FACE_SWAPPER
|
||||
|
||||
@@ -87,19 +116,22 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
||||
face_swapper = get_face_swapper()
|
||||
if face_swapper is None:
|
||||
update_status("Face swapper model not loaded or failed to load. Skipping swap.", NAME)
|
||||
return temp_frame # Return original frame if model failed or not loaded
|
||||
return temp_frame
|
||||
|
||||
# Store a copy of the original frame before swapping for opacity blending
|
||||
original_frame = temp_frame.copy()
|
||||
|
||||
# --- Pre-swap Input Check (Optional but good practice) ---
|
||||
# Pre-swap Input Check with optimization
|
||||
if temp_frame.dtype != np.uint8:
|
||||
# print(f"Warning: Input frame is {temp_frame.dtype}, converting to uint8 before swap.")
|
||||
temp_frame = np.clip(temp_frame, 0, 255).astype(np.uint8)
|
||||
# --- End Input Check ---
|
||||
|
||||
# Apply the face swap
|
||||
# Apply the face swap with optimized memory handling
|
||||
try:
|
||||
# For Apple Silicon, use optimized inference
|
||||
if IS_APPLE_SILICON:
|
||||
# Ensure contiguous memory layout for better performance
|
||||
temp_frame = np.ascontiguousarray(temp_frame)
|
||||
|
||||
swapped_frame_raw = face_swapper.get(
|
||||
temp_frame, target_face, source_face, paste_back=True
|
||||
)
|
||||
@@ -156,13 +188,42 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
||||
)
|
||||
|
||||
if getattr(modules.globals, "show_mouth_mask_box", False):
|
||||
mouth_mask_data = (mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon)
|
||||
# Draw visualization on the swapped_frame *before* opacity blending
|
||||
swapped_frame = draw_mouth_mask_visualization(
|
||||
swapped_frame, target_face, mouth_mask_data
|
||||
)
|
||||
|
||||
# Apply opacity blend between the original frame and the swapped frame
|
||||
mouth_mask_data = (mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon)
|
||||
# Draw visualization on the swapped_frame *before* opacity blending
|
||||
swapped_frame = draw_mouth_mask_visualization(
|
||||
swapped_frame, target_face, mouth_mask_data
|
||||
)
|
||||
|
||||
# --- Poisson Blending ---
|
||||
if getattr(modules.globals, "poisson_blend", False):
|
||||
face_mask = create_face_mask(target_face, temp_frame)
|
||||
if face_mask is not None:
|
||||
# Find bounding box of the mask
|
||||
y_indices, x_indices = np.where(face_mask > 0)
|
||||
if len(x_indices) > 0 and len(y_indices) > 0:
|
||||
x_min, x_max = np.min(x_indices), np.max(x_indices)
|
||||
y_min, y_max = np.min(y_indices), np.max(y_indices)
|
||||
|
||||
# Calculate center
|
||||
center = (int((x_min + x_max) / 2), int((y_min + y_max) / 2))
|
||||
|
||||
# Crop src and mask
|
||||
src_crop = swapped_frame[y_min : y_max + 1, x_min : x_max + 1]
|
||||
mask_crop = face_mask[y_min : y_max + 1, x_min : x_max + 1]
|
||||
|
||||
try:
|
||||
# Use original_frame as destination to blend the swapped face onto it
|
||||
swapped_frame = cv2.seamlessClone(
|
||||
src_crop,
|
||||
original_frame,
|
||||
mask_crop,
|
||||
center,
|
||||
cv2.NORMAL_CLONE,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Poisson blending failed: {e}")
|
||||
|
||||
# Apply opacity blend between the original frame and the swapped frame
|
||||
opacity = getattr(modules.globals, "opacity", 1.0)
|
||||
# Ensure opacity is within valid range [0.0, 1.0]
|
||||
opacity = max(0.0, min(1.0, opacity))
|
||||
@@ -177,14 +238,50 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
||||
return final_swapped_frame
|
||||
|
||||
|
||||
# --- START: Mac M1-M5 Optimized Face Detection ---
|
||||
def get_faces_optimized(frame: Frame, use_cache: bool = True) -> Optional[List[Face]]:
|
||||
"""Optimized face detection for live mode on Apple Silicon"""
|
||||
global LAST_DETECTION_TIME, FACE_DETECTION_CACHE
|
||||
|
||||
if not use_cache or not IS_APPLE_SILICON:
|
||||
# Standard detection
|
||||
if modules.globals.many_faces:
|
||||
return get_many_faces(frame)
|
||||
else:
|
||||
face = get_one_face(frame)
|
||||
return [face] if face else None
|
||||
|
||||
# Adaptive detection rate for live mode
|
||||
current_time = time.time()
|
||||
time_since_last = current_time - LAST_DETECTION_TIME
|
||||
|
||||
# Skip detection if too soon (adaptive frame skipping)
|
||||
if time_since_last < DETECTION_INTERVAL and FACE_DETECTION_CACHE:
|
||||
return FACE_DETECTION_CACHE.get('faces')
|
||||
|
||||
# Perform detection
|
||||
LAST_DETECTION_TIME = current_time
|
||||
if modules.globals.many_faces:
|
||||
faces = get_many_faces(frame)
|
||||
else:
|
||||
face = get_one_face(frame)
|
||||
faces = [face] if face else None
|
||||
|
||||
# Cache results
|
||||
FACE_DETECTION_CACHE['faces'] = faces
|
||||
FACE_DETECTION_CACHE['timestamp'] = current_time
|
||||
|
||||
return faces
|
||||
# --- END: Mac M1-M5 Optimized Face Detection ---
|
||||
|
||||
# --- START: Helper function for interpolation and sharpening ---
|
||||
def apply_post_processing(current_frame: Frame, swapped_face_bboxes: List[np.ndarray]) -> Frame:
|
||||
"""Applies sharpening and interpolation."""
|
||||
"""Applies sharpening and interpolation with Apple Silicon optimizations."""
|
||||
global PREVIOUS_FRAME_RESULT
|
||||
|
||||
processed_frame = current_frame.copy()
|
||||
|
||||
# 1. Apply Sharpening (if enabled)
|
||||
# 1. Apply Sharpening (if enabled) with optimized kernel for Apple Silicon
|
||||
sharpness_value = getattr(modules.globals, "sharpness", 0.0)
|
||||
if sharpness_value > 0.0 and swapped_face_bboxes:
|
||||
height, width = processed_frame.shape[:2]
|
||||
@@ -207,23 +304,21 @@ def apply_post_processing(current_frame: Frame, swapped_face_bboxes: List[np.nda
|
||||
continue
|
||||
|
||||
face_region = processed_frame[y1:y2, x1:x2]
|
||||
if face_region.size == 0: continue # Skip empty regions
|
||||
if face_region.size == 0: continue
|
||||
|
||||
# Apply sharpening using addWeighted for smoother control
|
||||
# Use try-except for GaussianBlur and addWeighted as they can fail on invalid inputs
|
||||
# Apply sharpening with optimized parameters for Apple Silicon
|
||||
try:
|
||||
blurred = cv2.GaussianBlur(face_region, (0, 0), 3) # sigma=3, kernel size auto
|
||||
sharpened_region = cv2.addWeighted(
|
||||
# Use smaller sigma for faster processing on Apple Silicon
|
||||
sigma = 2 if IS_APPLE_SILICON else 3
|
||||
blurred = cv2.GaussianBlur(face_region, (0, 0), sigma)
|
||||
sharpened_region = cv2.addWeighted(
|
||||
face_region, 1.0 + sharpness_value,
|
||||
blurred, -sharpness_value,
|
||||
0
|
||||
)
|
||||
# Ensure the sharpened region doesn't have invalid values
|
||||
sharpened_region = np.clip(sharpened_region, 0, 255).astype(np.uint8)
|
||||
processed_frame[y1:y2, x1:x2] = sharpened_region
|
||||
except cv2.error as sharpen_e:
|
||||
# print(f"Warning: OpenCV error during sharpening: {sharpen_e} for bbox {bbox}") # Debug
|
||||
# Skip sharpening for this region if it fails
|
||||
)
|
||||
sharpened_region = np.clip(sharpened_region, 0, 255).astype(np.uint8)
|
||||
processed_frame[y1:y2, x1:x2] = sharpened_region
|
||||
except cv2.error:
|
||||
pass
|
||||
|
||||
|
||||
@@ -323,7 +418,7 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||
source_target_pairs = []
|
||||
|
||||
# Ensure maps exist before accessing them
|
||||
souce_target_map = getattr(modules.globals, "souce_target_map", None)
|
||||
source_target_map = getattr(modules.globals, "source_target_map", None)
|
||||
simple_map = getattr(modules.globals, "simple_map", None)
|
||||
|
||||
# Check if target is a file path (image or video) or live stream
|
||||
@@ -331,11 +426,11 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||
|
||||
if is_file_target:
|
||||
# Processing specific image or video file with pre-analyzed maps
|
||||
if souce_target_map:
|
||||
if source_target_map:
|
||||
if modules.globals.many_faces:
|
||||
source_face = default_source_face() # Use default source for all targets
|
||||
if source_face:
|
||||
for map_data in souce_target_map:
|
||||
for map_data in source_target_map:
|
||||
if is_image(modules.globals.target_path):
|
||||
target_info = map_data.get("target", {})
|
||||
if target_info: # Check if target info exists
|
||||
@@ -353,7 +448,7 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||
for target_face in faces_in_frame:
|
||||
source_target_pairs.append((source_face, target_face))
|
||||
else: # Single face or specific mapping
|
||||
for map_data in souce_target_map:
|
||||
for map_data in source_target_map:
|
||||
source_info = map_data.get("source", {})
|
||||
if not source_info: continue # Skip if no source info
|
||||
source_face = source_info.get("face")
|
||||
|
||||
+33
-18
@@ -36,7 +36,7 @@ if platform.system() == "Windows":
|
||||
ROOT = None
|
||||
POPUP = None
|
||||
POPUP_LIVE = None
|
||||
ROOT_HEIGHT = 750
|
||||
ROOT_HEIGHT = 800
|
||||
ROOT_WIDTH = 600
|
||||
|
||||
PREVIEW = None
|
||||
@@ -98,6 +98,7 @@ def save_switch_states():
|
||||
"keep_frames": modules.globals.keep_frames,
|
||||
"many_faces": modules.globals.many_faces,
|
||||
"map_faces": modules.globals.map_faces,
|
||||
"poisson_blend": modules.globals.poisson_blend,
|
||||
"color_correction": modules.globals.color_correction,
|
||||
"nsfw_filter": modules.globals.nsfw_filter,
|
||||
"live_mirror": modules.globals.live_mirror,
|
||||
@@ -120,6 +121,7 @@ def load_switch_states():
|
||||
modules.globals.keep_frames = switch_states.get("keep_frames", False)
|
||||
modules.globals.many_faces = switch_states.get("many_faces", False)
|
||||
modules.globals.map_faces = switch_states.get("map_faces", False)
|
||||
modules.globals.poisson_blend = switch_states.get("poisson_blend", False)
|
||||
modules.globals.color_correction = switch_states.get("color_correction", False)
|
||||
modules.globals.nsfw_filter = switch_states.get("nsfw_filter", False)
|
||||
modules.globals.live_mirror = switch_states.get("live_mirror", False)
|
||||
@@ -272,6 +274,19 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
)
|
||||
map_faces_switch.place(relx=0.1, rely=0.65)
|
||||
|
||||
poisson_blend_value = ctk.BooleanVar(value=modules.globals.poisson_blend)
|
||||
poisson_blend_switch = ctk.CTkSwitch(
|
||||
root,
|
||||
text=_("Poisson Blend"),
|
||||
variable=poisson_blend_value,
|
||||
cursor="hand2",
|
||||
command=lambda: (
|
||||
setattr(modules.globals, "poisson_blend", poisson_blend_value.get()),
|
||||
save_switch_states(),
|
||||
),
|
||||
)
|
||||
poisson_blend_switch.place(relx=0.1, rely=0.7)
|
||||
|
||||
show_fps_value = ctk.BooleanVar(value=modules.globals.show_fps)
|
||||
show_fps_switch = ctk.CTkSwitch(
|
||||
root,
|
||||
@@ -310,21 +325,21 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
start_button = ctk.CTkButton(
|
||||
root, text=_("Start"), cursor="hand2", command=lambda: analyze_target(start, root)
|
||||
)
|
||||
start_button.place(relx=0.15, rely=0.80, relwidth=0.2, relheight=0.05)
|
||||
start_button.place(relx=0.15, rely=0.86, relwidth=0.2, relheight=0.05)
|
||||
|
||||
stop_button = ctk.CTkButton(
|
||||
root, text=_("Destroy"), cursor="hand2", command=lambda: destroy()
|
||||
)
|
||||
stop_button.place(relx=0.4, rely=0.80, relwidth=0.2, relheight=0.05)
|
||||
stop_button.place(relx=0.4, rely=0.86, relwidth=0.2, relheight=0.05)
|
||||
|
||||
preview_button = ctk.CTkButton(
|
||||
root, text=_("Preview"), cursor="hand2", command=lambda: toggle_preview()
|
||||
)
|
||||
preview_button.place(relx=0.65, rely=0.80, relwidth=0.2, relheight=0.05)
|
||||
preview_button.place(relx=0.65, rely=0.86, relwidth=0.2, relheight=0.05)
|
||||
|
||||
# --- Camera Selection ---
|
||||
camera_label = ctk.CTkLabel(root, text=_("Select Camera:"))
|
||||
camera_label.place(relx=0.1, rely=0.86, relwidth=0.2, relheight=0.05)
|
||||
camera_label.place(relx=0.1, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
|
||||
available_cameras = get_available_cameras()
|
||||
camera_indices, camera_names = available_cameras
|
||||
@@ -343,7 +358,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
root, variable=camera_variable, values=camera_names
|
||||
)
|
||||
|
||||
camera_optionmenu.place(relx=0.35, rely=0.86, relwidth=0.25, relheight=0.05)
|
||||
camera_optionmenu.place(relx=0.35, rely=0.92, relwidth=0.25, relheight=0.05)
|
||||
|
||||
live_button = ctk.CTkButton(
|
||||
root,
|
||||
@@ -363,7 +378,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
else "disabled"
|
||||
),
|
||||
)
|
||||
live_button.place(relx=0.65, rely=0.86, relwidth=0.2, relheight=0.05)
|
||||
live_button.place(relx=0.65, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
# --- End Camera Selection ---
|
||||
|
||||
# 1) Define a DoubleVar for transparency (0 = fully transparent, 1 = fully opaque)
|
||||
@@ -387,7 +402,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
|
||||
# 2) Transparency label and slider (placed ABOVE sharpness)
|
||||
transparency_label = ctk.CTkLabel(root, text="Transparency:")
|
||||
transparency_label.place(relx=0.15, rely=0.69, relwidth=0.2, relheight=0.05)
|
||||
transparency_label.place(relx=0.15, rely=0.75, relwidth=0.2, relheight=0.05)
|
||||
|
||||
transparency_slider = ctk.CTkSlider(
|
||||
root,
|
||||
@@ -403,7 +418,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
border_width=1,
|
||||
corner_radius=3,
|
||||
)
|
||||
transparency_slider.place(relx=0.35, rely=0.71, relwidth=0.5, relheight=0.02)
|
||||
transparency_slider.place(relx=0.35, rely=0.77, relwidth=0.5, relheight=0.02)
|
||||
|
||||
# 3) Sharpness label & slider
|
||||
sharpness_var = ctk.DoubleVar(value=0.0) # start at 0.0
|
||||
@@ -412,7 +427,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
update_status(f"Sharpness set to {value:.1f}")
|
||||
|
||||
sharpness_label = ctk.CTkLabel(root, text="Sharpness:")
|
||||
sharpness_label.place(relx=0.15, rely=0.74, relwidth=0.2, relheight=0.05)
|
||||
sharpness_label.place(relx=0.15, rely=0.80, relwidth=0.2, relheight=0.05)
|
||||
|
||||
sharpness_slider = ctk.CTkSlider(
|
||||
root,
|
||||
@@ -428,17 +443,17 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
border_width=1,
|
||||
corner_radius=3,
|
||||
)
|
||||
sharpness_slider.place(relx=0.35, rely=0.76, relwidth=0.5, relheight=0.02)
|
||||
sharpness_slider.place(relx=0.35, rely=0.82, relwidth=0.5, relheight=0.02)
|
||||
|
||||
# Status and link at the bottom
|
||||
global status_label
|
||||
status_label = ctk.CTkLabel(root, text=None, justify="center")
|
||||
status_label.place(relx=0.1, rely=0.9, relwidth=0.8)
|
||||
status_label.place(relx=0.1, rely=0.96, relwidth=0.8)
|
||||
|
||||
donate_label = ctk.CTkLabel(
|
||||
root, text="Deep Live Cam", justify="center", cursor="hand2"
|
||||
)
|
||||
donate_label.place(relx=0.1, rely=0.95, relwidth=0.8)
|
||||
donate_label.place(relx=0.1, rely=0.98, relwidth=0.8)
|
||||
donate_label.configure(
|
||||
text_color=ctk.ThemeManager.theme.get("URL").get("text_color")
|
||||
)
|
||||
@@ -465,7 +480,7 @@ def analyze_target(start: Callable[[], None], root: ctk.CTk):
|
||||
return
|
||||
|
||||
if modules.globals.map_faces:
|
||||
modules.globals.souce_target_map = []
|
||||
modules.globals.source_target_map = []
|
||||
|
||||
if is_image(modules.globals.target_path):
|
||||
update_status("Getting unique faces")
|
||||
@@ -474,8 +489,8 @@ def analyze_target(start: Callable[[], None], root: ctk.CTk):
|
||||
update_status("Getting unique faces")
|
||||
get_unique_faces_from_target_video()
|
||||
|
||||
if len(modules.globals.souce_target_map) > 0:
|
||||
create_source_target_popup(start, root, modules.globals.souce_target_map)
|
||||
if len(modules.globals.source_target_map) > 0:
|
||||
create_source_target_popup(start, root, modules.globals.source_target_map)
|
||||
else:
|
||||
update_status("No faces found in target")
|
||||
else:
|
||||
@@ -855,9 +870,9 @@ def webcam_preview(root: ctk.CTk, camera_index: int):
|
||||
return
|
||||
create_webcam_preview(camera_index)
|
||||
else:
|
||||
modules.globals.souce_target_map = []
|
||||
modules.globals.source_target_map = []
|
||||
create_source_target_popup_for_webcam(
|
||||
root, modules.globals.souce_target_map, camera_index
|
||||
root, modules.globals.source_target_map, camera_index
|
||||
)
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -11,7 +11,7 @@ tk==0.1.0
|
||||
customtkinter==5.2.2
|
||||
pillow==11.1.0
|
||||
torch; sys_platform != 'darwin'
|
||||
torch==2.7.1+cu128; sys_platform == 'darwin'
|
||||
torch==2.8.0+cu128; sys_platform == 'darwin'
|
||||
torchvision; sys_platform != 'darwin'
|
||||
torchvision==0.20.1; sys_platform == 'darwin'
|
||||
onnxruntime-silicon==1.16.3; sys_platform == 'darwin' and platform_machine == 'arm64'
|
||||
@@ -20,4 +20,5 @@ tensorflow; sys_platform != 'darwin'
|
||||
opennsfw2==0.10.2
|
||||
protobuf==4.25.1
|
||||
git+https://github.com/xinntao/BasicSR.git@master
|
||||
git+https://github.com/TencentARC/GFPGAN.git@master
|
||||
git+https://github.com/TencentARC/GFPGAN.git@master
|
||||
pygrabber
|
||||
|
||||
Reference in New Issue
Block a user