Compare commits

..

1 Commits

Author SHA1 Message Date
david-biro 33a3b7bc97
Merge b18a6095c1 into bbad5e08bb 2024-10-08 22:15:54 +04:00
3 changed files with 34 additions and 97 deletions

View File

@ -394,14 +394,9 @@ This is an open-source project developed in our free time. Updates may be delaye
- and [all developers](https://github.com/hacksider/Deep-Live-Cam/graphs/contributors) behind libraries used in this project. - and [all developers](https://github.com/hacksider/Deep-Live-Cam/graphs/contributors) behind libraries used in this project.
- Foot Note: [This is originally roop-cam, see the full history of the code here.](https://github.com/hacksider/roop-cam) Please be informed that the base author of the code is [s0md3v](https://github.com/s0md3v/roop) - Foot Note: [This is originally roop-cam, see the full history of the code here.](https://github.com/hacksider/roop-cam) Please be informed that the base author of the code is [s0md3v](https://github.com/s0md3v/roop)
## Contributions ## Thanks to all the contributors
![Alt](https://repobeats.axiom.co/api/embed/fec8e29c45dfdb9c5916f3a7830e1249308d20e1.svg "Repobeats analytics image") <a href="https://github.com/hacksider/Deep-Live-Cam/graphs/contributors" target="_blank">
## Star History <img src="https://contrib.rocks/image?repo=hacksider/Deep-Live-Cam" />
<a href="https://star-history.com/#hacksider/deep-live-cam&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=hacksider/deep-live-cam&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=hacksider/deep-live-cam&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=hacksider/deep-live-cam&type=Date" />
</picture>
</a> </a>
![Alt](https://repobeats.axiom.co/api/embed/fec8e29c45dfdb9c5916f3a7830e1249308d20e1.svg "Repobeats analytics image")

View File

@ -2,11 +2,11 @@ import os
from typing import List, Dict, Any from typing import List, Dict, Any
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
WORKFLOW_DIR = os.path.join(ROOT_DIR, "workflow") WORKFLOW_DIR = os.path.join(ROOT_DIR, 'workflow')
file_types = [ file_types = [
("Image", ("*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp")), ('Image', ('*.png','*.jpg','*.jpeg','*.gif','*.bmp')),
("Video", ("*.mp4", "*.mkv")), ('Video', ('*.mp4','*.mkv'))
] ]
souce_target_map = [] souce_target_map = []
@ -16,23 +16,23 @@ source_path = None
target_path = None target_path = None
output_path = None output_path = None
frame_processors: List[str] = [] frame_processors: List[str] = []
keep_fps = True keep_fps = None
keep_audio = True keep_audio = None
keep_frames = False keep_frames = None
many_faces = False many_faces = None
map_faces = False map_faces = None
color_correction = False # New global variable for color correction toggle color_correction = None # New global variable for color correction toggle
nsfw_filter = False nsfw_filter = None
video_encoder = None video_encoder = None
video_quality = None video_quality = None
live_mirror = False live_mirror = None
live_resizable = False live_resizable = None
max_memory = None max_memory = None
execution_providers: List[str] = [] execution_providers: List[str] = []
execution_threads = None execution_threads = None
headless = None headless = None
log_level = "error" log_level = 'error'
fp_ui: Dict[str, bool] = {"face_enhancer": False} fp_ui: Dict[str, bool] = {}
camera_input_combobox = None camera_input_combobox = None
webcam_preview_running = False webcam_preview_running = False
show_fps = False show_fps = False

View File

@ -6,8 +6,6 @@ import cv2
from cv2_enumerate_cameras import enumerate_cameras # Add this import from cv2_enumerate_cameras import enumerate_cameras # Add this import
from PIL import Image, ImageOps from PIL import Image, ImageOps
import time import time
import json
import modules.globals import modules.globals
import modules.metadata import modules.metadata
from modules.face_analyser import ( from modules.face_analyser import (
@ -82,49 +80,9 @@ def init(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.CTk:
return ROOT return ROOT
def save_switch_states():
switch_states = {
"keep_fps": modules.globals.keep_fps,
"keep_audio": modules.globals.keep_audio,
"keep_frames": modules.globals.keep_frames,
"many_faces": modules.globals.many_faces,
"map_faces": modules.globals.map_faces,
"color_correction": modules.globals.color_correction,
"nsfw_filter": modules.globals.nsfw_filter,
"live_mirror": modules.globals.live_mirror,
"live_resizable": modules.globals.live_resizable,
"fp_ui": modules.globals.fp_ui,
"show_fps": modules.globals.show_fps,
}
with open("switch_states.json", "w") as f:
json.dump(switch_states, f)
def load_switch_states():
try:
with open("switch_states.json", "r") as f:
switch_states = json.load(f)
modules.globals.keep_fps = switch_states.get("keep_fps", True)
modules.globals.keep_audio = switch_states.get("keep_audio", True)
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.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)
modules.globals.live_resizable = switch_states.get("live_resizable", False)
modules.globals.fp_ui = switch_states.get("fp_ui", {"face_enhancer": False})
modules.globals.show_fps = switch_states.get("show_fps", False)
except FileNotFoundError:
# If the file doesn't exist, use default values
pass
def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.CTk: def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.CTk:
global source_label, target_label, status_label, show_fps_switch global source_label, target_label, status_label, show_fps_switch
load_switch_states()
ctk.deactivate_automatic_dpi_awareness() ctk.deactivate_automatic_dpi_awareness()
ctk.set_appearance_mode("system") ctk.set_appearance_mode("system")
ctk.set_default_color_theme(resolve_relative_path("ui.json")) ctk.set_default_color_theme(resolve_relative_path("ui.json"))
@ -167,9 +125,8 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text="Keep fps", text="Keep fps",
variable=keep_fps_value, variable=keep_fps_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(
setattr(modules.globals, "keep_fps", keep_fps_value.get()), modules.globals, "keep_fps", not modules.globals.keep_fps
save_switch_states(),
), ),
) )
keep_fps_checkbox.place(relx=0.1, rely=0.6) keep_fps_checkbox.place(relx=0.1, rely=0.6)
@ -180,23 +137,20 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text="Keep frames", text="Keep frames",
variable=keep_frames_value, variable=keep_frames_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(
setattr(modules.globals, "keep_frames", keep_frames_value.get()), modules.globals, "keep_frames", keep_frames_value.get()
save_switch_states(),
), ),
) )
keep_frames_switch.place(relx=0.1, rely=0.65) keep_frames_switch.place(relx=0.1, rely=0.65)
# for FRAME PROCESSOR ENHANCER tumbler:
enhancer_value = ctk.BooleanVar(value=modules.globals.fp_ui["face_enhancer"]) enhancer_value = ctk.BooleanVar(value=modules.globals.fp_ui["face_enhancer"])
enhancer_switch = ctk.CTkSwitch( enhancer_switch = ctk.CTkSwitch(
root, root,
text="Face Enhancer", text="Face Enhancer",
variable=enhancer_value, variable=enhancer_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: update_tumbler("face_enhancer", enhancer_value.get()),
update_tumbler("face_enhancer", enhancer_value.get()),
save_switch_states(),
),
) )
enhancer_switch.place(relx=0.1, rely=0.7) enhancer_switch.place(relx=0.1, rely=0.7)
@ -206,10 +160,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text="Keep audio", text="Keep audio",
variable=keep_audio_value, variable=keep_audio_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(modules.globals, "keep_audio", keep_audio_value.get()),
setattr(modules.globals, "keep_audio", keep_audio_value.get()),
save_switch_states(),
),
) )
keep_audio_switch.place(relx=0.6, rely=0.6) keep_audio_switch.place(relx=0.6, rely=0.6)
@ -219,22 +170,19 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text="Many faces", text="Many faces",
variable=many_faces_value, variable=many_faces_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(modules.globals, "many_faces", many_faces_value.get()),
setattr(modules.globals, "many_faces", many_faces_value.get()),
save_switch_states(),
),
) )
many_faces_switch.place(relx=0.6, rely=0.65) many_faces_switch.place(relx=0.6, rely=0.65)
# Add color correction toggle button
color_correction_value = ctk.BooleanVar(value=modules.globals.color_correction) color_correction_value = ctk.BooleanVar(value=modules.globals.color_correction)
color_correction_switch = ctk.CTkSwitch( color_correction_switch = ctk.CTkSwitch(
root, root,
text="Fix Blueish Cam\n(force cv2 to use RGB instead of BGR)", text="Fix Blueish Cam\n(force cv2 to use RGB instead of BGR)",
variable=color_correction_value, variable=color_correction_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(
setattr(modules.globals, "color_correction", color_correction_value.get()), modules.globals, "color_correction", color_correction_value.get()
save_switch_states(),
), ),
) )
color_correction_switch.place(relx=0.6, rely=0.70) color_correction_switch.place(relx=0.6, rely=0.70)
@ -249,23 +197,18 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text="Map faces", text="Map faces",
variable=map_faces, variable=map_faces,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(modules.globals, "map_faces", map_faces.get()),
setattr(modules.globals, "map_faces", map_faces.get()),
save_switch_states(),
),
) )
map_faces_switch.place(relx=0.1, rely=0.75) map_faces_switch.place(relx=0.1, rely=0.75)
show_fps_value = ctk.BooleanVar(value=modules.globals.show_fps) # Add Show FPS switch
show_fps_value = ctk.BooleanVar(value=False)
show_fps_switch = ctk.CTkSwitch( show_fps_switch = ctk.CTkSwitch(
root, root,
text="Show FPS", text="Show FPS",
variable=show_fps_value, variable=show_fps_value,
cursor="hand2", cursor="hand2",
command=lambda: ( command=lambda: setattr(modules.globals, "show_fps", show_fps_value.get()),
setattr(modules.globals, "show_fps", show_fps_value.get()),
save_switch_states(),
),
) )
show_fps_switch.place(relx=0.6, rely=0.75) show_fps_switch.place(relx=0.6, rely=0.75)
@ -513,7 +456,6 @@ def update_pop_live_status(text: str) -> None:
def update_tumbler(var: str, value: bool) -> None: def update_tumbler(var: str, value: bool) -> None:
modules.globals.fp_ui[var] = value modules.globals.fp_ui[var] = value
save_switch_states()
def select_source_path() -> None: def select_source_path() -> None: