Compare commits
3 Commits
b3e73956d2
...
20637d3c27
Author | SHA1 | Date |
---|---|---|
|
20637d3c27 | |
|
01393ec77b | |
|
85a52e92b2 |
22
README.md
22
README.md
|
@ -20,14 +20,19 @@
|
|||
|
||||
###### 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.
|
||||
|
||||
## Quick Start - Pre-built
|
||||
<div align="center">
|
||||
<a href="https://hacksider.gumroad.com/l/vccdmm">
|
||||
<img src="https://github.com/user-attachments/assets/7d993b32-e3e8-4cd3-bbfb-a549152ebdd5" width="285" height="77" />
|
||||
</a>
|
||||
<a href="https://krshh.gumroad.com/l/Deep-Live-Cam-Mac">
|
||||
<img src="https://github.com/user-attachments/assets/d5d913b5-a7de-4609-96b9-979a5749a703" width="285" height="77" />
|
||||
</a>
|
||||
## Quick Start - Download Prebuilt
|
||||
|
||||
<div style="margin: 28px 0;">
|
||||
<div style="margin-bottom: 20px;">
|
||||
<a href="https://hacksider.gumroad.com/l/vccdmm" target="_blank">
|
||||
<img src="https://github.com/user-attachments/assets/c702bb7d-d9c0-466a-9ad2-02849294e540" alt="Download Button 1" style="width: 280px; display: block;">
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://krshh.gumroad.com/l/Deep-Live-Cam-Mac" target="_blank">
|
||||
<img src="https://github.com/user-attachments/assets/9a302750-2d54-457d-bdc8-6ed7c6af0e1a" alt="Download Button 2" style="width: 280px; display: block;">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
## Features - Everything is real-time
|
||||
|
@ -256,7 +261,6 @@ Looking for a CLI mode? Using the -s/--source argument will make the run program
|
|||
- [pereiraroland26](https://github.com/pereiraroland26): Multiple faces support
|
||||
- [vic4key](https://github.com/vic4key): For supporting/contributing to this project
|
||||
- [kier007](https://github.com/kier007): for improving the user experience
|
||||
- [qitianai](https://github.com/qitianai): for multi-lingual support
|
||||
- and [all developers](https://github.com/hacksider/Deep-Live-Cam/graphs/contributors) behind libraries used in this project.
|
||||
- Footnote: Please be informed that the base author of the code is [s0md3v](https://github.com/s0md3v/roop)
|
||||
- All the wonderful users who helped make this project go viral by starring the repo ❤️
|
||||
|
|
|
@ -31,16 +31,11 @@
|
|||
"Please select a source image first": "请先选择一个源图像",
|
||||
"No faces found in target": "目标图像中没有人脸",
|
||||
"Add": "添加",
|
||||
"Clear": "清除",
|
||||
"Submit": "确认",
|
||||
"Select source image": "请选取源图像",
|
||||
"Select target image": "请选取目标图像",
|
||||
"Please provide mapping!": "请提供映射",
|
||||
"Atleast 1 source with target is required!": "至少需要一个来源图像与目标图像相关!",
|
||||
"At least 1 source with target is required!": "至少需要一个来源图像与目标图像相关!",
|
||||
"Face could not be detected in last upload!": "最近上传的图像中没有检测到人脸!",
|
||||
"Select Camera:": "选择摄像头",
|
||||
"All mappings cleared!": "所有映射均已清除!",
|
||||
"Mappings successfully submitted!": "成功提交映射!",
|
||||
"Source x Target Mapper is already open.": "源 x 目标映射器已打开。"
|
||||
"Select Camera:": "选择摄像头"
|
||||
}
|
|
@ -6,7 +6,7 @@ class LanguageManager:
|
|||
self.current_language = default_language
|
||||
self.translations = {}
|
||||
self.load_language(default_language)
|
||||
|
||||
|
||||
def load_language(self, language_code) -> bool:
|
||||
"""load language file"""
|
||||
if language_code == "en":
|
||||
|
@ -20,7 +20,7 @@ class LanguageManager:
|
|||
except FileNotFoundError:
|
||||
print(f"Language file not found: {language_code}")
|
||||
return False
|
||||
|
||||
|
||||
def _(self, key, default=None) -> str:
|
||||
"""get translate text"""
|
||||
return self.translations.get(key, default if default else key)
|
105
modules/ui.py
105
modules/ui.py
|
@ -266,7 +266,6 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
|||
command=lambda: (
|
||||
setattr(modules.globals, "map_faces", map_faces.get()),
|
||||
save_switch_states(),
|
||||
close_mapper_window() if not map_faces.get() else None
|
||||
),
|
||||
)
|
||||
map_faces_switch.place(relx=0.1, rely=0.75)
|
||||
|
@ -381,41 +380,32 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
|||
|
||||
return root
|
||||
|
||||
def close_mapper_window():
|
||||
global POPUP, POPUP_LIVE
|
||||
if POPUP and POPUP.winfo_exists():
|
||||
POPUP.destroy()
|
||||
POPUP = None
|
||||
if POPUP_LIVE and POPUP_LIVE.winfo_exists():
|
||||
POPUP_LIVE.destroy()
|
||||
POPUP_LIVE = None
|
||||
|
||||
|
||||
def analyze_target(start: Callable[[], None], root: ctk.CTk):
|
||||
if POPUP != None and POPUP.winfo_exists():
|
||||
update_status("Please complete pop-up or close it.")
|
||||
update_status(_("Please complete pop-up or close it."))
|
||||
return
|
||||
|
||||
if modules.globals.map_faces:
|
||||
modules.globals.souce_target_map = []
|
||||
|
||||
if is_image(modules.globals.target_path):
|
||||
update_status("Getting unique faces")
|
||||
update_status(_("Getting unique faces"))
|
||||
get_unique_faces_from_target_image()
|
||||
elif is_video(modules.globals.target_path):
|
||||
update_status("Getting unique faces")
|
||||
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)
|
||||
else:
|
||||
update_status("No faces found in target")
|
||||
update_status(_("No faces found in target"))
|
||||
else:
|
||||
select_output_path(start)
|
||||
|
||||
|
||||
def create_source_target_popup(
|
||||
start: Callable[[], None], root: ctk.CTk, map: list
|
||||
start: Callable[[], None], root: ctk.CTk, map: list
|
||||
) -> None:
|
||||
global POPUP, popup_status_label
|
||||
|
||||
|
@ -484,7 +474,7 @@ def create_source_target_popup(
|
|||
|
||||
|
||||
def update_popup_source(
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
) -> list:
|
||||
global source_label_dict
|
||||
|
||||
|
@ -509,7 +499,7 @@ def update_popup_source(
|
|||
x_min, y_min, x_max, y_max = face["bbox"]
|
||||
|
||||
map[button_num]["source"] = {
|
||||
"cv2": cv2_img[int(y_min): int(y_max), int(x_min): int(x_max)],
|
||||
"cv2": cv2_img[int(y_min) : int(y_max), int(x_min) : int(x_max)],
|
||||
"face": face,
|
||||
}
|
||||
|
||||
|
@ -531,7 +521,7 @@ def update_popup_source(
|
|||
source_image.configure(image=tk_image)
|
||||
source_label_dict[button_num] = source_image
|
||||
else:
|
||||
update_pop_status("Face could not be detected in last upload!")
|
||||
update_pop_status(_("Face could not be detected in last upload!"))
|
||||
return map
|
||||
|
||||
|
||||
|
@ -689,7 +679,7 @@ def check_and_ignore_nsfw(target, destroy: Callable = None) -> bool:
|
|||
destroy(
|
||||
to_quit=False
|
||||
) # Do not need to destroy the window frame if the target is NSFW
|
||||
update_status("Processing ignored!")
|
||||
update_status(_("Processing ignored!"))
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -718,7 +708,7 @@ def render_image_preview(image_path: str, size: Tuple[int, int]) -> ctk.CTkImage
|
|||
|
||||
|
||||
def render_video_preview(
|
||||
video_path: str, size: Tuple[int, int], frame_number: int = 0
|
||||
video_path: str, size: Tuple[int, int], frame_number: int = 0
|
||||
) -> ctk.CTkImage:
|
||||
capture = cv2.VideoCapture(video_path)
|
||||
if frame_number:
|
||||
|
@ -753,12 +743,12 @@ def init_preview() -> None:
|
|||
|
||||
def update_preview(frame_number: int = 0) -> None:
|
||||
if modules.globals.source_path and modules.globals.target_path:
|
||||
update_status("Processing...")
|
||||
update_status(_("Processing..."))
|
||||
temp_frame = get_video_frame(modules.globals.target_path, frame_number)
|
||||
if modules.globals.nsfw_filter and check_and_ignore_nsfw(temp_frame):
|
||||
return
|
||||
for frame_processor in get_frame_processors_modules(
|
||||
modules.globals.frame_processors
|
||||
modules.globals.frame_processors
|
||||
):
|
||||
temp_frame = frame_processor.process_frame(
|
||||
get_one_face(cv2.imread(modules.globals.source_path)), temp_frame
|
||||
|
@ -769,21 +759,14 @@ def update_preview(frame_number: int = 0) -> None:
|
|||
)
|
||||
image = ctk.CTkImage(image, size=image.size)
|
||||
preview_label.configure(image=image)
|
||||
update_status("Processing succeed!")
|
||||
update_status(_("Processing succeed!"))
|
||||
PREVIEW.deiconify()
|
||||
|
||||
|
||||
def webcam_preview(root: ctk.CTk, camera_index: int):
|
||||
global POPUP_LIVE
|
||||
|
||||
if POPUP_LIVE and POPUP_LIVE.winfo_exists():
|
||||
update_status("Source x Target Mapper is already open.")
|
||||
POPUP_LIVE.focus()
|
||||
return
|
||||
|
||||
if not modules.globals.map_faces:
|
||||
if modules.globals.source_path is None:
|
||||
update_status("Please select a source image first")
|
||||
update_status(_("Please select a source image first"))
|
||||
return
|
||||
create_webcam_preview(camera_index)
|
||||
else:
|
||||
|
@ -793,7 +776,6 @@ def webcam_preview(root: ctk.CTk, camera_index: int):
|
|||
)
|
||||
|
||||
|
||||
|
||||
def get_available_cameras():
|
||||
"""Returns a list of available camera names and indices."""
|
||||
if platform.system() == "Windows":
|
||||
|
@ -841,7 +823,7 @@ def get_available_cameras():
|
|||
camera_indices.append(0)
|
||||
camera_names.append("FaceTime Camera")
|
||||
cap.release()
|
||||
|
||||
|
||||
# On macOS, additional cameras typically use indices 1 and 2
|
||||
for i in [1, 2]:
|
||||
cap = cv2.VideoCapture(i)
|
||||
|
@ -869,7 +851,7 @@ def create_webcam_preview(camera_index: int):
|
|||
|
||||
cap = VideoCapturer(camera_index)
|
||||
if not cap.start(PREVIEW_DEFAULT_WIDTH, PREVIEW_DEFAULT_HEIGHT, 60):
|
||||
update_status("Failed to start camera")
|
||||
update_status(_("Failed to start camera"))
|
||||
return
|
||||
|
||||
preview_label.configure(width=PREVIEW_DEFAULT_WIDTH, height=PREVIEW_DEFAULT_HEIGHT)
|
||||
|
@ -957,7 +939,7 @@ def create_webcam_preview(camera_index: int):
|
|||
|
||||
|
||||
def create_source_target_popup_for_webcam(
|
||||
root: ctk.CTk, map: list, camera_index: int
|
||||
root: ctk.CTk, map: list, camera_index: int
|
||||
) -> None:
|
||||
global POPUP_LIVE, popup_status_label_live
|
||||
|
||||
|
@ -968,54 +950,27 @@ def create_source_target_popup_for_webcam(
|
|||
|
||||
def on_submit_click():
|
||||
if has_valid_map():
|
||||
POPUP_LIVE.destroy()
|
||||
simplify_maps()
|
||||
update_pop_live_status("Mappings successfully submitted!")
|
||||
create_webcam_preview(camera_index) # Open the preview window
|
||||
create_webcam_preview(camera_index)
|
||||
else:
|
||||
update_pop_live_status("At least 1 source with target is required!")
|
||||
update_pop_live_status(_("At least 1 source with target is required!"))
|
||||
|
||||
def on_add_click():
|
||||
add_blank_map()
|
||||
refresh_data(map)
|
||||
update_pop_live_status("Please provide mapping!")
|
||||
|
||||
def on_clear_click():
|
||||
clear_source_target_images(map)
|
||||
refresh_data(map)
|
||||
update_pop_live_status("All mappings cleared!")
|
||||
update_pop_live_status(_("Please provide mapping!"))
|
||||
|
||||
popup_status_label_live = ctk.CTkLabel(POPUP_LIVE, text=None, justify="center")
|
||||
popup_status_label_live.grid(row=1, column=0, pady=15)
|
||||
|
||||
add_button = ctk.CTkButton(POPUP_LIVE, text=_("Add"), command=lambda: on_add_click())
|
||||
add_button.place(relx=0.1, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
|
||||
clear_button = ctk.CTkButton(POPUP_LIVE, text=_("Clear"), command=lambda: on_clear_click())
|
||||
clear_button.place(relx=0.4, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
add_button.place(relx=0.2, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
|
||||
close_button = ctk.CTkButton(
|
||||
POPUP_LIVE, text=_("Submit"), command=lambda: on_submit_click()
|
||||
)
|
||||
close_button.place(relx=0.7, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
|
||||
|
||||
|
||||
def clear_source_target_images(map: list):
|
||||
global source_label_dict_live, target_label_dict_live
|
||||
|
||||
for item in map:
|
||||
if "source" in item:
|
||||
del item["source"]
|
||||
if "target" in item:
|
||||
del item["target"]
|
||||
|
||||
for button_num in list(source_label_dict_live.keys()):
|
||||
source_label_dict_live[button_num].destroy()
|
||||
del source_label_dict_live[button_num]
|
||||
|
||||
for button_num in list(target_label_dict_live.keys()):
|
||||
target_label_dict_live[button_num].destroy()
|
||||
del target_label_dict_live[button_num]
|
||||
close_button.place(relx=0.6, rely=0.92, relwidth=0.2, relheight=0.05)
|
||||
|
||||
|
||||
def refresh_data(map: list):
|
||||
|
@ -1099,7 +1054,7 @@ def refresh_data(map: list):
|
|||
|
||||
|
||||
def update_webcam_source(
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
) -> list:
|
||||
global source_label_dict_live
|
||||
|
||||
|
@ -1124,7 +1079,7 @@ def update_webcam_source(
|
|||
x_min, y_min, x_max, y_max = face["bbox"]
|
||||
|
||||
map[button_num]["source"] = {
|
||||
"cv2": cv2_img[int(y_min): int(y_max), int(x_min): int(x_max)],
|
||||
"cv2": cv2_img[int(y_min) : int(y_max), int(x_min) : int(x_max)],
|
||||
"face": face,
|
||||
}
|
||||
|
||||
|
@ -1146,12 +1101,12 @@ def update_webcam_source(
|
|||
source_image.configure(image=tk_image)
|
||||
source_label_dict_live[button_num] = source_image
|
||||
else:
|
||||
update_pop_live_status("Face could not be detected in last upload!")
|
||||
update_pop_live_status(_("Face could not be detected in last upload!"))
|
||||
return map
|
||||
|
||||
|
||||
def update_webcam_target(
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
scrollable_frame: ctk.CTkScrollableFrame, map: list, button_num: int
|
||||
) -> list:
|
||||
global target_label_dict_live
|
||||
|
||||
|
@ -1176,7 +1131,7 @@ def update_webcam_target(
|
|||
x_min, y_min, x_max, y_max = face["bbox"]
|
||||
|
||||
map[button_num]["target"] = {
|
||||
"cv2": cv2_img[int(y_min): int(y_max), int(x_min): int(x_max)],
|
||||
"cv2": cv2_img[int(y_min) : int(y_max), int(x_min) : int(x_max)],
|
||||
"face": face,
|
||||
}
|
||||
|
||||
|
@ -1198,5 +1153,5 @@ def update_webcam_target(
|
|||
target_image.configure(image=tk_image)
|
||||
target_label_dict_live[button_num] = target_image
|
||||
else:
|
||||
update_pop_live_status("Face could not be detected in last upload!")
|
||||
return map
|
||||
update_pop_live_status(_("Face could not be detected in last upload!"))
|
||||
return map
|
||||
|
|
Loading…
Reference in New Issue