commit
b995eca033
|
@ -54,13 +54,17 @@ def get_face_enhancer() -> Any:
|
||||||
with THREAD_LOCK:
|
with THREAD_LOCK:
|
||||||
if FACE_ENHANCER is None:
|
if FACE_ENHANCER is None:
|
||||||
model_path = os.path.join(models_dir, "GFPGANv1.4.pth")
|
model_path = os.path.join(models_dir, "GFPGANv1.4.pth")
|
||||||
if platform.system() == "Darwin": # Mac OS
|
|
||||||
mps_device = None
|
match platform.system():
|
||||||
if torch.backends.mps.is_available():
|
case "Darwin": # Mac OS
|
||||||
mps_device = torch.device("mps")
|
if torch.backends.mps.is_available():
|
||||||
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # type: ignore[attr-defined]
|
mps_device = torch.device("mps")
|
||||||
else: # Other OS
|
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1, device=mps_device) # type: ignore[attr-defined]
|
||||||
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
|
else:
|
||||||
|
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
|
||||||
|
case _: # Other OS
|
||||||
|
FACE_ENHANCER = gfpgan.GFPGANer(model_path=model_path, upscale=1) # type: ignore[attr-defined]
|
||||||
|
|
||||||
return FACE_ENHANCER
|
return FACE_ENHANCER
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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 json
|
||||||
from pygrabber.dshow_graph import FilterGraph
|
|
||||||
import modules.globals
|
import modules.globals
|
||||||
import modules.metadata
|
import modules.metadata
|
||||||
from modules.face_analyser import (
|
from modules.face_analyser import (
|
||||||
|
@ -29,6 +28,9 @@ from modules.utilities import (
|
||||||
from modules.video_capture import VideoCapturer
|
from modules.video_capture import VideoCapturer
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
from pygrabber.dshow_graph import FilterGraph
|
||||||
|
|
||||||
ROOT = None
|
ROOT = None
|
||||||
POPUP = None
|
POPUP = None
|
||||||
POPUP_LIVE = None
|
POPUP_LIVE = None
|
||||||
|
@ -810,14 +812,30 @@ def get_available_cameras():
|
||||||
camera_indices = []
|
camera_indices = []
|
||||||
camera_names = []
|
camera_names = []
|
||||||
|
|
||||||
# Test the first 10 indices
|
if platform.system() == "Darwin": # macOS specific handling
|
||||||
for i in range(10):
|
# Try to open the default FaceTime camera first
|
||||||
cap = cv2.VideoCapture(i)
|
cap = cv2.VideoCapture(0)
|
||||||
if cap.isOpened():
|
if cap.isOpened():
|
||||||
camera_indices.append(i)
|
camera_indices.append(0)
|
||||||
camera_names.append(f"Camera {i}")
|
camera_names.append("FaceTime Camera")
|
||||||
cap.release()
|
cap.release()
|
||||||
|
|
||||||
|
# On macOS, additional cameras typically use indices 1 and 2
|
||||||
|
for i in [1, 2]:
|
||||||
|
cap = cv2.VideoCapture(i)
|
||||||
|
if cap.isOpened():
|
||||||
|
camera_indices.append(i)
|
||||||
|
camera_names.append(f"Camera {i}")
|
||||||
|
cap.release()
|
||||||
|
else:
|
||||||
|
# Linux camera detection - test first 10 indices
|
||||||
|
for i in range(10):
|
||||||
|
cap = cv2.VideoCapture(i)
|
||||||
|
if cap.isOpened():
|
||||||
|
camera_indices.append(i)
|
||||||
|
camera_names.append(f"Camera {i}")
|
||||||
|
cap.release()
|
||||||
|
|
||||||
if not camera_names:
|
if not camera_names:
|
||||||
return [], ["No cameras found"]
|
return [], ["No cameras found"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue