Compare commits

..

9 Commits

Author SHA1 Message Date
Kenneth Estanislao 91884eebf7
Merge pull request #615 from saleweaver/experimental
Adding headless parameter to arguments to run from the cli, reenabling macOS compatibility
2024-09-23 04:01:23 +08:00
Michael 4686716c59 add to README.md 2024-09-22 18:39:00 +01:00
Michael f4028d3949 Fix underscore/hyphen 2024-09-22 18:33:02 +01:00
Michael 07c735e9d2 Allows to set the upscale factor for gfpgan face_enhancer 2024-09-22 18:31:06 +01:00
Michael aa021b6aa0 better import condition 2024-09-22 18:11:02 +01:00
Michael 0e3805e200 added headless argument to readme 2024-09-22 17:57:46 +01:00
Michael 5cabbffda8 - removed unused import statements
- added macOS specific required library to requirements.txt
- conditional import of pygrabber, which is unavailable for macOS
2024-09-22 17:55:26 +01:00
Michael 0d4676591e - removed unused import statements
- added macOS specific required library to requirements.txt
- conditional import of pygrabber, which is unavailable for macOS
2024-09-22 17:54:44 +01:00
Michael c2cc885672 Adding headless parameter to arguments to run from the cli 2024-09-21 22:41:47 +01:00
6 changed files with 21 additions and 7 deletions

View File

@ -164,6 +164,8 @@ options:
--max-memory MAX_MEMORY maximum amount of RAM in GB --max-memory MAX_MEMORY maximum amount of RAM in GB
--execution-provider {cpu} [{cpu} ...] available execution provider (choices: cpu, ...) --execution-provider {cpu} [{cpu} ...] available execution provider (choices: cpu, ...)
--execution-threads EXECUTION_THREADS number of execution threads --execution-threads EXECUTION_THREADS number of execution threads
--headless run in headless mode
--enhancer-upscale-factor Sets the upscale factor for the enhancer. Only applies if `face_enhancer` is set as a frame-processor
-v, --version show program's version number and exit -v, --version show program's version number and exit
``` ```

View File

@ -70,6 +70,10 @@ def parse_args() -> None:
choices=suggest_execution_providers(), nargs='+') choices=suggest_execution_providers(), nargs='+')
program.add_argument('--execution-threads', help='Number of execution threads', dest='execution_threads', type=int, program.add_argument('--execution-threads', help='Number of execution threads', dest='execution_threads', type=int,
default=suggest_execution_threads()) default=suggest_execution_threads())
program.add_argument('--headless', help='Run in headless mode', dest='headless', default=False, action='store_true')
program.add_argument('--enhancer-upscale-factor',
help='Sets the upscale factor for the enhancer. Only applies if `face_enhancer` is set as a frame-processor',
dest='enhancer_upscale_factor', type=int, default=1)
program.add_argument('-v', '--version', action='version', program.add_argument('-v', '--version', action='version',
version=f'{modules.metadata.name} {modules.metadata.version}') version=f'{modules.metadata.name} {modules.metadata.version}')
@ -98,7 +102,8 @@ def parse_args() -> None:
modules.globals.max_memory = args.max_memory modules.globals.max_memory = args.max_memory
modules.globals.execution_providers = decode_execution_providers(args.execution_provider) modules.globals.execution_providers = decode_execution_providers(args.execution_provider)
modules.globals.execution_threads = args.execution_threads modules.globals.execution_threads = args.execution_threads
modules.globals.headless = args.headless
modules.globals.enhancer_upscale_factor = args.enhancer_upscale_factor
# Handle face enhancer tumbler # Handle face enhancer tumbler
modules.globals.fp_ui['face_enhancer'] = 'face_enhancer' in args.frame_processor modules.globals.fp_ui['face_enhancer'] = 'face_enhancer' in args.frame_processor

View File

@ -30,3 +30,4 @@ fp_ui: Dict[str, bool] = {}
nsfw = None nsfw = None
camera_input_combobox = None camera_input_combobox = None
webcam_preview_running = False webcam_preview_running = False
enhancer_upscale_factor = 1

View File

@ -33,7 +33,10 @@ def get_face_enhancer() -> Any:
with THREAD_LOCK: with THREAD_LOCK:
if FACE_ENHANCER is None: if FACE_ENHANCER is None:
model_path = resolve_relative_path('../models/GFPGANv1.4.pth') model_path = resolve_relative_path('../models/GFPGANv1.4.pth')
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined] FACE_ENHANCER = gfpgan.GFPGANer(
model_path=model_path,
upscale=modules.globals.enhancer_upscale_factor
) # type: ignore[attr-defined]
return FACE_ENHANCER return FACE_ENHANCER
def enhance_face(temp_frame: Frame) -> Frame: def enhance_face(temp_frame: Frame) -> Frame:

View File

@ -6,15 +6,17 @@ from typing import Callable, Tuple, List, Any
from types import ModuleType from types import ModuleType
import cv2 import cv2
from PIL import Image, ImageOps from PIL import Image, ImageOps
from pygrabber.dshow_graph import FilterGraph
import pyvirtualcam import pyvirtualcam
# Import OS-specific modules only when necessary # Import OS-specific modules only when necessary
if platform.system() == 'Darwin': # macOS if platform.system() == 'Darwin': # macOS
import objc
from Foundation import NSObject
import AVFoundation import AVFoundation
# Import Windows specific modules only when on windows platform
if platform.system() == 'Windows' or platform.system() == 'Linux': # Windows or Linux
from pygrabber.dshow_graph import FilterGraph
import modules.globals import modules.globals
import modules.metadata import modules.metadata
from modules.face_analyser import get_one_face from modules.face_analyser import get_one_face

View File

@ -24,3 +24,4 @@ gfpgan==1.3.8
pyobjc==9.1; sys_platform == 'darwin' pyobjc==9.1; sys_platform == 'darwin'
pygrabber==0.2 pygrabber==0.2
pyvirtualcam==0.12.0 pyvirtualcam==0.12.0
pyobjc-framework-AVFoundation==10.3.1; sys_platform == 'darwin'