From ebc1aa4a82e4ae9660f80f4e24e0029c625ab18e Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Tue, 14 May 2019 18:50:43 +0200 Subject: [PATCH] Use the same keypoint names as bob.ip.mtcnn (cafe implementation) --- bob/ip/tensorflow_extractor/MTCNN.py | 10 ++++---- .../data/mtcnn/mtcnn.json | 24 +++++++++---------- bob/ip/tensorflow_extractor/test.py | 1 + doc/plot/detect_faces_mtcnn.py | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/bob/ip/tensorflow_extractor/MTCNN.py b/bob/ip/tensorflow_extractor/MTCNN.py index 75765a8..1e21778 100644 --- a/bob/ip/tensorflow_extractor/MTCNN.py +++ b/bob/ip/tensorflow_extractor/MTCNN.py @@ -93,7 +93,7 @@ class MTCNN: list A list of annotations. Annotations are dictionaries that contain the following keys: ``topleft``, ``bottomright``, ``reye``, ``leye``, ``nose``, - ``right_of_mouth``, ``left_of_mouth``, and ``quality``. + ``mouthright``, ``mouthleft``, and ``quality``. """ boxes, scores, landmarks = self.detect(img) annots = [] @@ -103,8 +103,8 @@ class MTCNN: right_eye = lm[0], lm[5] left_eye = lm[1], lm[6] nose = lm[2], lm[7] - right_of_mouth = lm[3], lm[8] - left_of_mouth = lm[4], lm[9] + mouthright = lm[3], lm[8] + mouthleft = lm[4], lm[9] annots.append( { "topleft": topleft, @@ -112,8 +112,8 @@ class MTCNN: "reye": right_eye, "leye": left_eye, "nose": nose, - "right_of_mouth": right_of_mouth, - "left_of_mouth": left_of_mouth, + "mouthright": mouthright, + "mouthleft": mouthleft, "quality": prob, } ) diff --git a/bob/ip/tensorflow_extractor/data/mtcnn/mtcnn.json b/bob/ip/tensorflow_extractor/data/mtcnn/mtcnn.json index 522b939..65f18d6 100644 --- a/bob/ip/tensorflow_extractor/data/mtcnn/mtcnn.json +++ b/bob/ip/tensorflow_extractor/data/mtcnn/mtcnn.json @@ -20,11 +20,11 @@ 81.764984, 136.25734 ], - "right_of_mouth": [ + "mouthright": [ 88.05158, 128.52052 ], - "left_of_mouth": [ + "mouthleft": [ 84.64868, 150.7494 ], @@ -51,11 +51,11 @@ 71.690926, 454.36282 ], - "right_of_mouth": [ + "mouthright": [ 75.266556, 438.5781 ], - "left_of_mouth": [ + "mouthleft": [ 82.32741, 454.99423 ], @@ -82,11 +82,11 @@ 104.02164, 56.380474 ], - "right_of_mouth": [ + "mouthright": [ 111.99057, 49.277725 ], - "left_of_mouth": [ + "mouthleft": [ 104.45787, 69.476105 ], @@ -113,11 +113,11 @@ 138.73158, 257.6499 ], - "right_of_mouth": [ + "mouthright": [ 142.67319, 246.85234 ], - "left_of_mouth": [ + "mouthleft": [ 143.5627, 267.6805 ], @@ -144,11 +144,11 @@ 86.6857, 344.3223 ], - "right_of_mouth": [ + "mouthright": [ 94.80564, 331.12646 ], - "left_of_mouth": [ + "mouthleft": [ 96.63391, 351.96518 ], @@ -175,11 +175,11 @@ 151.32994, 182.92662 ], - "right_of_mouth": [ + "mouthright": [ 159.72272, 175.2344 ], - "left_of_mouth": [ + "mouthleft": [ 156.25536, 193.2938 ], diff --git a/bob/ip/tensorflow_extractor/test.py b/bob/ip/tensorflow_extractor/test.py index 9c34130..dff72a5 100644 --- a/bob/ip/tensorflow_extractor/test.py +++ b/bob/ip/tensorflow_extractor/test.py @@ -90,6 +90,7 @@ def test_mtcnn(): annots = mtcnn.annotations(img) ref_annots = json.load(open(ref_annots)) + assert len(annots) == len(ref_annots), (len(annots), len(ref_annots)) for a, aref in zip(annots, ref_annots): for k, v in a.items(): vref = aref[k] diff --git a/doc/plot/detect_faces_mtcnn.py b/doc/plot/detect_faces_mtcnn.py index 42c3a3d..570f6b7 100644 --- a/doc/plot/detect_faces_mtcnn.py +++ b/doc/plot/detect_faces_mtcnn.py @@ -35,8 +35,8 @@ for annotations in detections: ("reye", "r"), ("leye", "g"), ("nose", "b"), - ("right_of_mouth", "k"), - ("left_of_mouth", "w"), + ("mouthright", "k"), + ("mouthleft", "w"), ): plt.gca().add_patch( Circle( -- GitLab