diff --git a/bob/bio/face/config/baseline/helpers.py b/bob/bio/face/config/baseline/helpers.py index dc9b91483777509633001d510edf1cbc3147f2b3..575c4267283feeda246513e989f5a4d957595b60 100644 --- a/bob/bio/face/config/baseline/helpers.py +++ b/bob/bio/face/config/baseline/helpers.py @@ -252,12 +252,12 @@ def get_default_cropped_positions(mode, cropped_image_size, annotation_type): """ if mode == "legacy": return legacy_default_cropping(cropped_image_size, annotation_type) - elif mode in ["facenet", "arcface"]: + elif mode in ["dnn", "facenet", "arcface"]: return dnn_default_cropping(cropped_image_size, annotation_type) elif mode == "pad": return pad_default_cropping(cropped_image_size, annotation_type) else: - raise ValueError("Unknown default cropping mode {}".format(mode)) + raise ValueError("Unknown default cropping mode `{}`".format(mode)) def make_cropper( diff --git a/doc/faq.rst b/doc/faq.rst index e60e626f6f9815f7a2c9a77b7819e6374dd8f16c..f67d297596c3ad818634f7a257c7eef9d3773d91 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -11,4 +11,63 @@ The recipe below helps you to set a face cropper based on eye positions. .. literalinclude:: faq/facecrop.py -.. figure:: ./faq/img/ada_cropped.png \ No newline at end of file +.. figure:: ./faq/img/ada_cropped.png + + +How to choose the cropped positions ? +================================= + +The ideal cropped positions are dependent on the specific application you are using the face cropper in. +Some face embedding extractors work well on loosely cropped faces, while others require the face to be tightly cropped. +We provide a few reasonable defaults that are used in our implemented baselines. They are accessible through an utilitary function, +:any:`bob.bio.face.config.baseline.helpers.get_default_cropped_positions`. +:: + + import bob.bio.face.config.baseline.helpers.get_default_cropped_positions + mode = 'legacy' + cropped_image_size=(160, 160) + annotation_type='eyes-center' + cropped_positions = get_default_cropped_positions(mode, cropped_image_size, annotation_type) + + +There are currently three available modes : + +* :code:`legacy` Tight crop, used in non neural-net baselines such as :code:`gabor-graph`, :code:`lgbphs` or :code:`lda`. + It is typically use with a 5:4 aspect ratio for the :code:`cropped_image_size` +* :code:`dnn` Loose crop, used for neural-net baselines such as the ArcFace or FaceNet models. +* :code:`pad` Tight crop used in some PAD baselines in :ref:`bob.pad.face` + +We present hereafter a visual example of those crops for the `eyes-center` annotation type. + +.. figure:: img/cropping_example_source.png + :height: 250px + :align: left + :alt: Source image + :figclass: align-center + + Original face image + +.. figure:: img/cropping_example_legacy.png + :height: 250px + :align: right + :alt: Legacy crop + :figclass: align-center + + Legacy crop (160 x 128) + +.. figure:: img/cropping_example_dnn.png + :height: 250px + :align: left + :alt: DNN crop + :figclass: align-center + + DNN crop (160 x 160) + +.. figure:: img/cropping_example_pad.png + :height: 250px + :align: right + :alt: PAD crop + :figclass: align-center + + PAD crop (160 x 160) + \ No newline at end of file diff --git a/doc/img/cropping_example_dnn.png b/doc/img/cropping_example_dnn.png new file mode 100644 index 0000000000000000000000000000000000000000..0b38460273d53be65bcfecc7a9a198913e49c26c Binary files /dev/null and b/doc/img/cropping_example_dnn.png differ diff --git a/doc/img/cropping_example_legacy.png b/doc/img/cropping_example_legacy.png new file mode 100644 index 0000000000000000000000000000000000000000..ccfbba980f986b8f5d415dbf467799e9edd3504b Binary files /dev/null and b/doc/img/cropping_example_legacy.png differ diff --git a/doc/img/cropping_example_pad.png b/doc/img/cropping_example_pad.png new file mode 100644 index 0000000000000000000000000000000000000000..81c5aab312a9e972be971647d589b70a57240f74 Binary files /dev/null and b/doc/img/cropping_example_pad.png differ diff --git a/doc/img/cropping_example_source.png b/doc/img/cropping_example_source.png new file mode 100644 index 0000000000000000000000000000000000000000..cd4de029371ba1a224ea6006906a9640021d8295 Binary files /dev/null and b/doc/img/cropping_example_source.png differ