Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apple M1 GPU Option to Class 'DlibDetector' #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions face_alignment/detection/dlib/dlib_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, device, path_to_detector=None, verbose=False):
warnings.warn('Warning: this detector is deprecated. Please use a different one, i.e.: S3FD.')

# Initialise the face detector
if 'cuda' in device:
if 'cuda' in device or 'mps' in device:
if path_to_detector is None:
path_to_detector = load_file_from_url(
"https://www.adrianbulat.com/downloads/dlib/mmod_human_face_detector.dat")
Expand All @@ -28,7 +28,7 @@ def detect_from_image(self, tensor_or_path):

detected_faces = self.face_detector(cv2.cvtColor(image, cv2.COLOR_BGR2GRAY))

if 'cuda' not in self.device:
if 'cuda' not in self.device and 'mps' not in self.device:
detected_faces = [[d.left(), d.top(), d.right(), d.bottom()] for d in detected_faces]
else:
detected_faces = [[d.rect.left(), d.rect.top(), d.rect.right(), d.rect.bottom()] for d in detected_faces]
Expand Down