From c2cc885672d2a7d8ffb1e9083e8b3ca536968727 Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sat, 21 Sep 2024 22:41:47 +0100
Subject: [PATCH 1/8] Adding headless parameter to arguments to run from the
 cli

---
 modules/core.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/core.py b/modules/core.py
index b4e4a31..a66340e 100644
--- a/modules/core.py
+++ b/modules/core.py
@@ -70,6 +70,7 @@ def parse_args() -> None:
                          choices=suggest_execution_providers(), nargs='+')
     program.add_argument('--execution-threads', help='Number of execution threads', dest='execution_threads', type=int,
                          default=suggest_execution_threads())
+    program.add_argument('--headless', help='Run in headless mode', dest='headless', default=False, action='store_true')
     program.add_argument('-v', '--version', action='version',
                          version=f'{modules.metadata.name} {modules.metadata.version}')
 
@@ -98,6 +99,7 @@ def parse_args() -> None:
     modules.globals.max_memory = args.max_memory
     modules.globals.execution_providers = decode_execution_providers(args.execution_provider)
     modules.globals.execution_threads = args.execution_threads
+    modules.globals.headless = args.headless
 
     # Handle face enhancer tumbler
     modules.globals.fp_ui['face_enhancer'] = 'face_enhancer' in args.frame_processor

From 0d4676591e3c490113b8ef9b1e3677c4adb63dac Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 17:54:44 +0100
Subject: [PATCH 2/8] - removed unused import statements - added macOS specific
 required library to requirements.txt - conditional import of pygrabber, which
 is unavailable for macOS

---
 modules/ui.py    | 7 ++++---
 requirements.txt | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/ui.py b/modules/ui.py
index 494d85a..e83c3d0 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -6,15 +6,16 @@ from typing import Callable, Tuple, List, Any
 from types import ModuleType
 import cv2
 from PIL import Image, ImageOps
-from pygrabber.dshow_graph import FilterGraph
 import pyvirtualcam
 
 # Import OS-specific modules only when necessary
 if platform.system() == 'Darwin':  # macOS
-    import objc
-    from Foundation import NSObject
     import AVFoundation
 
+if os.name == 'nt':  # Windows
+    from pygrabber.dshow_graph import FilterGraph
+
+
 import modules.globals
 import modules.metadata
 from modules.face_analyser import get_one_face
diff --git a/requirements.txt b/requirements.txt
index 915179d..96bb6b4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,4 +23,5 @@ tqdm==4.66.4
 gfpgan==1.3.8
 pyobjc==9.1; sys_platform == 'darwin'
 pygrabber==0.2
-pyvirtualcam==0.12.0
\ No newline at end of file
+pyvirtualcam==0.12.0
+pyobjc-framework-AVFoundation==10.3.1; sys_platform == 'darwin'
\ No newline at end of file

From 5cabbffda818b9eb74c3634dacb328df0375d548 Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 17:55:26 +0100
Subject: [PATCH 3/8] - removed unused import statements - added macOS specific
 required library to requirements.txt - conditional import of pygrabber, which
 is unavailable for macOS

---
 modules/ui.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/ui.py b/modules/ui.py
index e83c3d0..574ae19 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -12,6 +12,7 @@ import pyvirtualcam
 if platform.system() == 'Darwin':  # macOS
     import AVFoundation
 
+# Import Windows specific modules only when on windows platform
 if os.name == 'nt':  # Windows
     from pygrabber.dshow_graph import FilterGraph
 

From 0e3805e2002e5e8900fdb22269387513c9e29312 Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 17:57:46 +0100
Subject: [PATCH 4/8] added headless argument to readme

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 361e6f5..3def2ae 100644
--- a/README.md
+++ b/README.md
@@ -164,6 +164,7 @@ options:
   --max-memory MAX_MEMORY                                  maximum amount of RAM in GB
   --execution-provider {cpu} [{cpu} ...]                   available execution provider (choices: cpu, ...)
   --execution-threads EXECUTION_THREADS                    number of execution threads
+  --headless                                               run in headless mode
   -v, --version                                            show program's version number and exit
 ```
 

From aa021b6aa04884d766495798f35854bece4b8efd Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 18:11:02 +0100
Subject: [PATCH 5/8] better import condition

---
 modules/ui.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/ui.py b/modules/ui.py
index 574ae19..2733dbb 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -13,7 +13,7 @@ if platform.system() == 'Darwin':  # macOS
     import AVFoundation
 
 # Import Windows specific modules only when on windows platform
-if os.name == 'nt':  # Windows
+if platform.system() == 'Windows' or platform.system() == 'Linux':  # Windows or Linux
     from pygrabber.dshow_graph import FilterGraph
 
 

From 07c735e9d2a90fb38be949915d05b83511486faa Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 18:31:06 +0100
Subject: [PATCH 6/8] Allows to set the upscale factor for  gfpgan
 face_enhancer

---
 modules/core.py                           | 5 ++++-
 modules/globals.py                        | 3 ++-
 modules/processors/frame/face_enhancer.py | 5 ++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/core.py b/modules/core.py
index a66340e..8c569b3 100644
--- a/modules/core.py
+++ b/modules/core.py
@@ -71,6 +71,9 @@ def parse_args() -> None:
     program.add_argument('--execution-threads', help='Number of execution threads', dest='execution_threads', type=int,
                          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',
                          version=f'{modules.metadata.name} {modules.metadata.version}')
 
@@ -100,7 +103,7 @@ def parse_args() -> None:
     modules.globals.execution_providers = decode_execution_providers(args.execution_provider)
     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
     modules.globals.fp_ui['face_enhancer'] = 'face_enhancer' in args.frame_processor
 
diff --git a/modules/globals.py b/modules/globals.py
index 2bc15fd..a435e4d 100644
--- a/modules/globals.py
+++ b/modules/globals.py
@@ -29,4 +29,5 @@ log_level = 'error'
 fp_ui: Dict[str, bool] = {}
 nsfw = None
 camera_input_combobox = None
-webcam_preview_running = False
\ No newline at end of file
+webcam_preview_running = False
+enhancer_upscale_factor = 1
diff --git a/modules/processors/frame/face_enhancer.py b/modules/processors/frame/face_enhancer.py
index a75f5c0..a39bef6 100644
--- a/modules/processors/frame/face_enhancer.py
+++ b/modules/processors/frame/face_enhancer.py
@@ -33,7 +33,10 @@ def get_face_enhancer() -> Any:
     with THREAD_LOCK:
         if FACE_ENHANCER is None:
             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
 
 def enhance_face(temp_frame: Frame) -> Frame:

From f4028d3949bec97031020ffa56b6801c86d38d5a Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 18:33:02 +0100
Subject: [PATCH 7/8] Fix underscore/hyphen

---
 modules/core.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/core.py b/modules/core.py
index 8c569b3..a0d45ca 100644
--- a/modules/core.py
+++ b/modules/core.py
@@ -71,8 +71,8 @@ def parse_args() -> None:
     program.add_argument('--execution-threads', help='Number of execution threads', dest='execution_threads', type=int,
                          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',
+    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',
                          version=f'{modules.metadata.name} {modules.metadata.version}')

From 4686716c5967a6a8aea4273db843cdac7f30bfa9 Mon Sep 17 00:00:00 2001
From: Michael <primke.michael@gmail.com>
Date: Sun, 22 Sep 2024 18:39:00 +0100
Subject: [PATCH 8/8] add to README.md

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 3def2ae..a71318d 100644
--- a/README.md
+++ b/README.md
@@ -165,6 +165,7 @@ options:
   --execution-provider {cpu} [{cpu} ...]                   available execution provider (choices: cpu, ...)
   --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
 ```