YYuanAnyVision / mxnet_mtcnn_face_detection

MTCNN face detection
738 stars 314 forks source link

How to tweak the parameters to get more faces? (some imgs that have faces but not detected) #28

Closed terencezl closed 6 years ago

terencezl commented 6 years ago

image

I see there are two methods, detect_face() and detect_face_limited(). The detect_face() signature is

            img: numpy array, bgr order of shape (1, 3, n, m)
                input image

But the actual shape checking treats an image as a [height, width, channel] array:

        # only works for color image
        if len(img.shape) != 3:
            return None

        # detected boxes
        total_boxes = []

        height, width, _ = img.shape

Therefore the detection fails at some point.

I also tried detect_face_limited(), and saw the [1] and [2] of threshold getting used to do the filtering and decreased those values to get more results. But still, e.g. this picture has four faces, and I'm getting as many as only one.

detector = MtcnnDetector(model_folder='mtcnn-model', ctx=mx.gpu(0), num_worker=1, accurate_landmark = True, threshold=[0.0,-1,-1], minsize=10)
img = cv2.imread("180112-news-friends.jpg")
detector.detect_face_limited(img, 2)

(array([[  5.78239929e+02,  -3.24641838e+01,   1.59770996e+03,
           8.00984070e+02,   2.69610956e-02]], dtype=float32),
 array([[ 932, 1277, 1178,  954, 1229,  302,  275,  414,  628,  599]], dtype=int32))

How can I get all those faces?