Commit d9b94d07 authored by Laurent COLBOIS's avatar Laurent COLBOIS
Browse files

Added face crop examples in the doc

parent 9c50df1a
Pipeline #50958 failed with stage
in 26 minutes and 3 seconds
......@@ -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)
raise ValueError("Unknown default cropping mode {}".format(mode))
raise ValueError("Unknown default cropping mode `{}`".format(mode))
def make_cropper(
......@@ -11,4 +11,63 @@ The recipe below helps you to set a face cropper based on eye positions.
.. literalinclude:: faq/
.. 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,
mode = 'legacy'
cropped_image_size=(160, 160)
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment