Skip to content
Snippets Groups Projects
Commit d9b94d07 authored by Laurent COLBOIS's avatar Laurent COLBOIS
Browse files

Added face crop examples in the doc

parent 9c50df1a
No related branches found
No related tags found
1 merge request!119Refactor baseline config helpers
Pipeline #50958 failed
......@@ -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(
......
......@@ -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
doc/img/cropping_example_dnn.png

44.1 KiB

doc/img/cropping_example_legacy.png

34.4 KiB

doc/img/cropping_example_pad.png

42.6 KiB

doc/img/cropping_example_source.png

1.18 MiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment