mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
raise legible error message for optional import
This commit is contained in:
parent
fceeccb14b
commit
adfb29dfc7
@ -6,11 +6,19 @@ from deepface.commons.logger import Logger
|
|||||||
|
|
||||||
logger = Logger(module="detectors.DlibWrapper")
|
logger = Logger(module="detectors.DlibWrapper")
|
||||||
|
|
||||||
|
|
||||||
def build_model():
|
def build_model():
|
||||||
|
|
||||||
home = functions.get_deepface_home()
|
home = functions.get_deepface_home()
|
||||||
|
|
||||||
import dlib # this requirement is not a must that's why imported here
|
# this is not a must dependency. do not import it in the global level.
|
||||||
|
try:
|
||||||
|
import dlib
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
raise ImportError(
|
||||||
|
"Dlib is an optional detector, ensure the library is installed."
|
||||||
|
"Please install using 'pip install dlib' "
|
||||||
|
) from e
|
||||||
|
|
||||||
# check required file exists in the home/.deepface/weights folder
|
# check required file exists in the home/.deepface/weights folder
|
||||||
if os.path.isfile(home + "/.deepface/weights/shape_predictor_5_face_landmarks.dat") != True:
|
if os.path.isfile(home + "/.deepface/weights/shape_predictor_5_face_landmarks.dat") != True:
|
||||||
@ -40,7 +48,14 @@ def build_model():
|
|||||||
|
|
||||||
def detect_face(detector, img, align=True):
|
def detect_face(detector, img, align=True):
|
||||||
|
|
||||||
import dlib # this requirement is not a must that's why imported here
|
# this is not a must dependency. do not import it in the global level.
|
||||||
|
try:
|
||||||
|
import dlib
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
raise ImportError(
|
||||||
|
"Dlib is an optional detector, ensure the library is installed."
|
||||||
|
"Please install using 'pip install dlib' "
|
||||||
|
) from e
|
||||||
|
|
||||||
resp = []
|
resp = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user