We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 357a397 + 131a7fb commit 1b60cf2Copy full SHA for 1b60cf2
deepface/detectors/FastMtCnn.py
@@ -62,13 +62,16 @@ def build_model(self) -> Any:
62
# this is not a must dependency. do not import it in the global level.
63
try:
64
from facenet_pytorch import MTCNN as fast_mtcnn
65
+ import torch
66
except ModuleNotFoundError as e:
67
raise ImportError(
68
"FastMtcnn is an optional detector, ensure the library is installed."
69
"Please install using 'pip install facenet-pytorch' "
70
) from e
71
- face_detector = fast_mtcnn(device="cpu")
72
+ device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
73
+ face_detector = fast_mtcnn(device=device)
74
+
75
return face_detector
76
77
0 commit comments