Repository: keras-team/autokeras

Issue:
Pretrained model for face detection
<!---
Please label your issue with `feature_request`.
-->

### Feature Description
<!---
A clear and concise description of idea/feature. If it is related to some problem you are facing, then explain the problem.
-->

### Reason
<!---
A clear and concise description of why this feature would be useful for the project.
-->

### Solution
<!---
A clear and concise description of what you want to happen.
-->
Use the model on pretrained on MTCNN algorithm. [Github link](https://github.com/kuaikuaikim/DFace) 



Discussion:

Resolving patch:
diff --git a/autokeras/image/face_detection_pretrained.py b/autokeras/image/face_detection_pretrained.py
--- a/autokeras/image/face_detection_pretrained.py
+++ b/autokeras/image/face_detection_pretrained.py
@@ -596,5 +596,6 @@ def detect_faces(pnet_path, rnet_path, onet_path, img_path, output_file_path):
     img = cv2.imread(img_path)
     img_bg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
     bboxs, landmarks = mtcnn_detector.detect_face(img)
-    vis_face(img_bg, bboxs, output_file_path, landmarks)
+    if output_file_path is not None:
+        vis_face(img_bg, bboxs, output_file_path, landmarks)
     return bboxs, landmarks
diff --git a/autokeras/pretrained.py b/autokeras/pretrained.py
--- a/autokeras/pretrained.py
+++ b/autokeras/pretrained.py
@@ -34,6 +34,8 @@ def predict(self, x_predict):
 
 
 class FaceDetectionPretrained(Pretrained):
+    """A class to predict faces using the MTCNN pre-trained model.
+    """
 
     def __init__(self):
         super(FaceDetectionPretrained, self).__init__()
@@ -46,6 +48,18 @@ def load(self, model_path=None):
         self.pnet, self.rnet, self.onet = Constant.FACE_DETECTION_PRETRAINED['FILE_PATHS']
 
     def predict(self, img_path, output_file_path=None):
+        """Predicts faces in an image.
+
+        Args:
+            img_path: A string. The path to the image on which the prediction is to be done.
+            output_file_path: A string. The path where the output image is to be saved after the prediction. `None` by default.
+
+        Returns:
+            A tuple containing numpy arrays of bounding boxes and landmarks. Bounding boxes are of shape `(n, 5)` and
+            landmarks are of shape `(n, 10)` where `n` is the number of faces predicted. Each bounding box is of length
+            5 and the corresponding rectangle is defined by the first four values. Each bounding box has five landmarks
+            represented by 10 coordinates.
+        """
         if not os.path.exists(img_path):
             raise ValueError('Image does not exist')
         return detect_faces(self.pnet, self.rnet, self.onet, img_path, output_file_path)


Test patch:
diff --git a/tests/test_pretrained.py b/tests/test_pretrained.py
--- a/tests/test_pretrained.py
+++ b/tests/test_pretrained.py
@@ -9,8 +9,9 @@ def test_face_detection():
     if os.path.exists(out_file):
         os.remove(out_file)
     face_detection = FaceDetectionPretrained()
-    bboxs, landmarks = face_detection.predict(img_file, out_file)
+    bboxs1, landmarks1 = face_detection.predict(img_file, out_file)
     assert os.path.exists(out_file)
+    bboxs2, landmarks2 = face_detection.predict(img_file)
+    assert bboxs1.shape == bboxs2.shape == (11, 5) and landmarks1.shape == landmarks2.shape == (11, 10)
     os.remove(img_file)
     os.remove(out_file)
-    assert bboxs.shape == (11, 5) and landmarks.shape == (11, 10)