Compare commits

...

10 Commits

Author SHA1 Message Date
kira-offgrid 1dbe6682ed
Merge 130f096cd5 into 12fda0a3ed 2025-06-19 10:58:51 -04:00
KRSHH 12fda0a3ed
fix formatting 2025-06-17 18:42:36 +05:30
KRSHH d963430854
Add techlinked link 2025-06-17 18:42:10 +05:30
KRSHH 5855d15c09
Removed outdated links 2025-06-17 18:35:24 +05:30
KRSHH fcc73d0add
Update Download Button 2025-06-16 14:37:41 +05:30
KRSHH 8d4a386a27
Upgrade prebuilt to 2.1 2025-06-15 22:19:49 +05:30
Chittimalla Krish b98c5234d8
Revert 8bdc14a 2025-06-15 20:08:43 +05:30
Chittimalla Krish 8bdc14a789
Update prebuilt version 2025-06-15 17:50:38 +05:30
Kenneth Estanislao f121083bc8
Update README.md
RTX 50xx support
2025-06-15 02:22:00 +08:00
kira-offgrid 130f096cd5 fix: python.lang.security.audit.non-literal-import.non-literal-import-modules-processors-frame-core.py 2025-05-16 04:27:47 +00:00
4 changed files with 209 additions and 19 deletions

View File

@ -30,11 +30,11 @@ 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.0 Quick Start - Pre-built (Windows)
## Exclusive v2.1 Quick Start - Pre-built (Windows/Mac Silicon)
<a href="https://deeplivecam.net/index.php/quickstart"> <img src="media/Download.png" width="285" height="77" />
##### This is the fastest build you can get if you have a discrete NVIDIA or AMD GPU.
##### This is the fastest build you can get if you have a discrete NVIDIA or AMD GPU or Mac Silicon, And you'll receive special priority support.
###### These Pre-builts are perfect for non-technical users or those who don't have time to, or can't manually install all the requirements. Just a heads-up: this is an open-source project, so you can also install it manually. This will be 60 days ahead on the open source version.
@ -196,7 +196,7 @@ pip install -r requirements.txt
```bash
pip install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
pip uninstall onnxruntime onnxruntime-gpu
pip install onnxruntime-gpu==1.16.3
pip install onnxruntime-gpu==1.21.0
```
3. Usage:
@ -304,19 +304,6 @@ python run.py --execution-provider openvino
- Use a screen capture tool like OBS to stream.
- To change the face, select a new source image.
## Tips and Tricks
Check out these helpful guides to get the most out of Deep-Live-Cam:
- [Unlocking the Secrets to the Perfect Deepfake Image](https://deeplivecam.net/index.php/blog/tips-and-tricks/unlocking-the-secrets-to-the-perfect-deepfake-image) - Learn how to create the best deepfake with full head coverage
- [Video Call with DeepLiveCam](https://deeplivecam.net/index.php/blog/tips-and-tricks/video-call-with-deeplivecam) - Make your meetings livelier by using DeepLiveCam with OBS and meeting software
- [Have a Special Guest!](https://deeplivecam.net/index.php/blog/tips-and-tricks/have-a-special-guest) - Tutorial on how to use face mapping to add special guests to your stream
- [Watch Deepfake Movies in Realtime](https://deeplivecam.net/index.php/blog/tips-and-tricks/watch-deepfake-movies-in-realtime) - See yourself star in any video without processing the video
- [Better Quality without Sacrificing Speed](https://deeplivecam.net/index.php/blog/tips-and-tricks/better-quality-without-sacrificing-speed) - Tips for achieving better results without impacting performance
- [Instant Vtuber!](https://deeplivecam.net/index.php/blog/tips-and-tricks/instant-vtuber) - Create a new persona/vtuber easily using Metahuman Creator
Visit our [official blog](https://deeplivecam.net/index.php/blog/tips-and-tricks) for more tips and tutorials.
## Command Line Arguments (Unmaintained)
```
@ -360,6 +347,8 @@ Looking for a CLI mode? Using the -s/--source argument will make the run program
- [*"This real-time webcam deepfake tool raises alarms about the future of identity theft"*](https://www.diyphotography.net/this-real-time-webcam-deepfake-tool-raises-alarms-about-the-future-of-identity-theft/) - DIYPhotography
- [*"That's Crazy, Oh God. That's Fucking Freaky Dude... That's So Wild Dude"*](https://www.youtube.com/watch?time_continue=1074&v=py4Tc-Y8BcY) - SomeOrdinaryGamers
- [*"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)
## Credits

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -1,12 +1,129 @@
import sys
import importlib
from typing import Set, Optional
# Define a whitelist of allowed modules that can be dynamically imported
ALLOWED_MODULES: Set[str] = {
'modules.processors.frame.blur',
'modules.processors.frame.censor',
'modules.processors.frame.crop',
'modules.processors.frame.resize',
'modules.processors.frame.rotate',
# Add all legitimate processor modules that should be importable
}
def safe_import_module(module_name: str) -> Optional[object]:
"""
Safely import a module by checking against a whitelist.
Args:
module_name: The name of the module to import
Returns:
The imported module or None if the module is not in the whitelist
"""
if module_name in ALLOWED_MODULES:
return safe_import_module(module_name)
else:
# Log the attempt to import a non-whitelisted module
print(f"Warning: Attempted to import non-whitelisted module: {module_name}")
return None
import importlib
from typing import Set, Optional
# Define a whitelist of allowed modules that can be dynamically imported
ALLOWED_MODULES: Set[str] = {
'modules.processors.frame.blur',
'modules.processors.frame.censor',
'modules.processors.frame.crop',
'modules.processors.frame.resize',
'modules.processors.frame.rotate',
# Add all legitimate processor modules that should be importable
}
def safe_import_module(module_name: str) -> Optional[object]:
"""
Safely import a module by checking against a whitelist.
Args:
module_name: The name of the module to import
Returns:
The imported module or None if the module is not in the whitelist
"""
if module_name in ALLOWED_MODULES:
return safe_import_module(module_name)
else:
# Log the attempt to import a non-whitelisted module
print(f"Warning: Attempted to import non-whitelisted module: {module_name}")
return None
from concurrent.futures import ThreadPoolExecutor
from types import ModuleType
from typing import Any, List, Callable
from tqdm import tqdm
import modules
import modules.globals
import importlib
from typing import Set, Optional
# Define a whitelist of allowed modules that can be dynamically imported
ALLOWED_MODULES: Set[str] = {
'modules.processors.frame.blur',
'modules.processors.frame.censor',
'modules.processors.frame.crop',
'modules.processors.frame.resize',
'modules.processors.frame.rotate',
# Add all legitimate processor modules that should be importable
}
def safe_import_module(module_name: str) -> Optional[object]:
"""
Safely import a module by checking against a whitelist.
Args:
module_name: The name of the module to import
Returns:
The imported module or None if the module is not in the whitelist
"""
if module_name in ALLOWED_MODULES:
return safe_import_module(module_name)
else:
# Log the attempt to import a non-whitelisted module
print(f"Warning: Attempted to import non-whitelisted module: {module_name}")
return None
import importlib
from typing import Set, Optional
# Define a whitelist of allowed modules that can be dynamically imported
ALLOWED_MODULES: Set[str] = {
'modules.processors.frame.blur',
'modules.processors.frame.censor',
'modules.processors.frame.crop',
'modules.processors.frame.resize',
'modules.processors.frame.rotate',
# Add all legitimate processor modules that should be importable
}
def safe_import_module(module_name: str) -> Optional[object]:
"""
Safely import a module by checking against a whitelist.
Args:
module_name: The name of the module to import
Returns:
The imported module or None if the module is not in the whitelist
"""
if module_name in ALLOWED_MODULES:
return safe_import_module(module_name)
else:
# Log the attempt to import a non-whitelisted module
print(f"Warning: Attempted to import non-whitelisted module: {module_name}")
return None
FRAME_PROCESSORS_MODULES: List[ModuleType] = []
FRAME_PROCESSORS_INTERFACE = [
@ -20,7 +137,7 @@ FRAME_PROCESSORS_INTERFACE = [
def load_frame_processor_module(frame_processor: str) -> Any:
try:
frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}')
frame_processor_module = safe_import_module(f'modules.processors.frame.{frame_processor}')
for method_name in FRAME_PROCESSORS_INTERFACE:
if not hasattr(frame_processor_module, method_name):
sys.exit()

View File

@ -0,0 +1,84 @@
import sys
import importlib
from concurrent.futures import ThreadPoolExecutor
from types import ModuleType
from typing import Any, List, Callable
from tqdm import tqdm
import modules
import modules.globals
FRAME_PROCESSORS_MODULES: List[ModuleType] = []
FRAME_PROCESSORS_INTERFACE = [
'pre_check',
'pre_start',
'process_frame',
'process_image',
'process_video'
]
def load_frame_processor_module(frame_processor: str) -> Any:
try:
frame_processor_module = importlib.import_module(f'modules.processors.frame.{frame_processor}')
for method_name in FRAME_PROCESSORS_INTERFACE:
if not hasattr(frame_processor_module, method_name):
sys.exit()
except ImportError:
print(f"Frame processor {frame_processor} not found")
sys.exit()
return frame_processor_module
def get_frame_processors_modules(frame_processors: List[str]) -> List[ModuleType]:
global FRAME_PROCESSORS_MODULES
if not FRAME_PROCESSORS_MODULES:
for frame_processor in frame_processors:
frame_processor_module = load_frame_processor_module(frame_processor)
FRAME_PROCESSORS_MODULES.append(frame_processor_module)
set_frame_processors_modules_from_ui(frame_processors)
return FRAME_PROCESSORS_MODULES
def set_frame_processors_modules_from_ui(frame_processors: List[str]) -> None:
global FRAME_PROCESSORS_MODULES
current_processor_names = [proc.__name__.split('.')[-1] for proc in FRAME_PROCESSORS_MODULES]
for frame_processor, state in modules.globals.fp_ui.items():
if state == True and frame_processor not in current_processor_names:
try:
frame_processor_module = load_frame_processor_module(frame_processor)
FRAME_PROCESSORS_MODULES.append(frame_processor_module)
if frame_processor not in modules.globals.frame_processors:
modules.globals.frame_processors.append(frame_processor)
except SystemExit:
print(f"Warning: Failed to load frame processor {frame_processor} requested by UI state.")
except Exception as e:
print(f"Warning: Error loading frame processor {frame_processor} requested by UI state: {e}")
elif state == False and frame_processor in current_processor_names:
try:
module_to_remove = next((mod for mod in FRAME_PROCESSORS_MODULES if mod.__name__.endswith(f'.{frame_processor}')), None)
if module_to_remove:
FRAME_PROCESSORS_MODULES.remove(module_to_remove)
if frame_processor in modules.globals.frame_processors:
modules.globals.frame_processors.remove(frame_processor)
except Exception as e:
print(f"Warning: Error removing frame processor {frame_processor}: {e}")
def multi_process_frame(source_path: str, temp_frame_paths: List[str], process_frames: Callable[[str, List[str], Any], None], progress: Any = None) -> None:
with ThreadPoolExecutor(max_workers=modules.globals.execution_threads) as executor:
futures = []
for path in temp_frame_paths:
future = executor.submit(process_frames, source_path, [path], progress)
futures.append(future)
for future in futures:
future.result()
def process_video(source_path: str, frame_paths: list[str], process_frames: Callable[[str, List[str], Any], None]) -> None:
progress_bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]'
total = len(frame_paths)
with tqdm(total=total, desc='Processing', unit='frame', dynamic_ncols=True, bar_format=progress_bar_format) as progress:
progress.set_postfix({'execution_providers': modules.globals.execution_providers, 'execution_threads': modules.globals.execution_threads, 'max_memory': modules.globals.max_memory})
multi_process_frame(source_path, frame_paths, process_frames, progress)