diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index b1fdc3b..ae0c61c 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -18,6 +18,7 @@ import tensorflow as tf import keras import bz2 from deepface.commons import distance +from mtcnn import MTCNN def loadBase64Img(uri): encoded_data = uri.split(',')[1] @@ -275,9 +276,7 @@ def detect_face(img, detector_backend = 'opencv', grayscale = False, enforce_det raise ValueError("Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.") elif detector_backend == 'mtcnn': - - from mtcnn import MTCNN #this is not a must library within deepface - + mtcnn_detector = MTCNN() detections = mtcnn_detector.detect_faces(img) @@ -432,7 +431,7 @@ def align_face(img, detector_backend = 'opencv'): return img #return img anyway elif detector_backend == 'mtcnn': - from mtcnn import MTCNN + mtcnn_detector = MTCNN() detections = mtcnn_detector.detect_faces(img) diff --git a/requirements.txt b/requirements.txt index 2d40593..51d35c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ keras>=2.2.0 Flask>=1.1.2 lightgbm>=2.3.1 dlib>=19.20.0 +mtcnn>=0.1.0 \ No newline at end of file diff --git a/setup.py b/setup.py index f0bd82a..a6e4f07 100644 --- a/setup.py +++ b/setup.py @@ -20,5 +20,5 @@ setuptools.setup( "Operating System :: OS Independent", ], python_requires='>=3.5.5', - install_requires=["numpy>=1.14.0", "pandas>=0.23.4", "tqdm>=4.30.0", "gdown>=3.10.1", "Pillow>=5.2.0", "opencv-python>=3.4.4", "tensorflow>=1.9.0", "keras>=2.2.0", "Flask>=1.1.2"] + install_requires=["numpy>=1.14.0", "pandas>=0.23.4", "tqdm>=4.30.0", "gdown>=3.10.1", "Pillow>=5.2.0", "opencv-python>=3.4.4", "tensorflow>=1.9.0", "keras>=2.2.0", "Flask>=1.1.2", "mtcnn>=0.1.0"] )