Compare commits

...

10 Commits

Author SHA1 Message Date
Mr.Tom c85d78f0e6
Merge 6d6d2fc748 into 94b0b63b3b 2024-10-09 19:48:07 +02:00
KRSHH 94b0b63b3b
Update README.md 2024-10-09 21:46:59 +05:30
KRSHH 53d473164b
remember/save switch states 2024-10-09 19:51:04 +05:30
KRSHH 673439d47c
Update globals.py for Default states 2024-10-09 19:50:20 +05:30
hoangngoc5275 6d6d2fc748
Update python-package.yml
Signed-off-by: hoangngoc5275 <hoangngocngoc50@gmail.com>
2024-09-29 04:33:28 +07:00
hoangngoc5275 cb9d04933b
Merge branch 'hacksider:main' into main 2024-09-29 04:10:38 +07:00
looman loras 2edde04570 Merge branch 'main' of https://github.com/hoangngoc5275/Deepface
* 'main' of https://github.com/hoangngoc5275/Deepface:
  Create python-package.yml
2024-09-18 17:18:02 +07:00
hoangngoc5275 5da4632c15
Merge branch 'hacksider:main' into main 2024-09-17 11:16:08 +07:00
hoangngoc5275 0f65be8bb3
Merge branch 'hacksider:main' into main 2024-09-16 20:53:42 +07:00
hoangngoc5275 d0faf924d1
Create python-package.yml
Signed-off-by: hoangngoc5275 <hoangngocngoc50@gmail.com>
2024-09-14 15:03:47 +07:00
4 changed files with 137 additions and 34 deletions

View File

@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: falses
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

View File

@ -392,9 +392,14 @@ 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)
## Thanks to all the contributors ## Contributions
<a href="https://github.com/hacksider/Deep-Live-Cam/graphs/contributors" target="_blank">
<img src="https://contrib.rocks/image?repo=hacksider/Deep-Live-Cam" />
</a>
![Alt](https://repobeats.axiom.co/api/embed/fec8e29c45dfdb9c5916f3a7830e1249308d20e1.svg "Repobeats analytics image") ![Alt](https://repobeats.axiom.co/api/embed/fec8e29c45dfdb9c5916f3a7830e1249308d20e1.svg "Repobeats analytics image")
## Star History
<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>

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 = None keep_fps = True
keep_audio = None keep_audio = True
keep_frames = None keep_frames = False
many_faces = None many_faces = False
map_faces = None map_faces = False
color_correction = None # New global variable for color correction toggle color_correction = False # New global variable for color correction toggle
nsfw_filter = None nsfw_filter = False
video_encoder = None video_encoder = None
video_quality = None video_quality = None
live_mirror = None live_mirror = False
live_resizable = None live_resizable = False
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] = {} fp_ui: Dict[str, bool] = {"face_enhancer": False}
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,6 +6,8 @@ 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 (
@ -80,9 +82,49 @@ 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"))
@ -125,8 +167,9 @@ 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: setattr( command=lambda: (
modules.globals, "keep_fps", not modules.globals.keep_fps setattr(modules.globals, "keep_fps", keep_fps_value.get()),
save_switch_states(),
), ),
) )
keep_fps_checkbox.place(relx=0.1, rely=0.6) keep_fps_checkbox.place(relx=0.1, rely=0.6)
@ -137,20 +180,23 @@ 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: setattr( command=lambda: (
modules.globals, "keep_frames", keep_frames_value.get() setattr(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: update_tumbler("face_enhancer", enhancer_value.get()), command=lambda: (
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)
@ -160,7 +206,10 @@ 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: setattr(modules.globals, "keep_audio", keep_audio_value.get()), command=lambda: (
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)
@ -170,19 +219,22 @@ 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: setattr(modules.globals, "many_faces", many_faces_value.get()), command=lambda: (
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: setattr( command=lambda: (
modules.globals, "color_correction", color_correction_value.get() setattr(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)
@ -197,18 +249,23 @@ 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: setattr(modules.globals, "map_faces", map_faces.get()), command=lambda: (
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)
# Add Show FPS switch show_fps_value = ctk.BooleanVar(value=modules.globals.show_fps)
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: setattr(modules.globals, "show_fps", show_fps_value.get()), command=lambda: (
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)
@ -456,6 +513,7 @@ 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: