diff --git a/bob/bio/face/config/baseline/helpers.py b/bob/bio/face/config/baseline/helpers.py index c9795bdcc32e13cd6e0c98d9a78cb8a220b7496c..5a8cc9440dd45875b5bc5e275365a493ee7af075 100644 --- a/bob/bio/face/config/baseline/helpers.py +++ b/bob/bio/face/config/baseline/helpers.py @@ -1,6 +1,6 @@ from sklearn.pipeline import make_pipeline from bob.pipelines import wrap -from bob.bio.face.helpers import face_crop_solver +from bob.bio.face import helpers import numpy as np import logging @@ -237,7 +237,7 @@ def make_cropper( transform_extra_arguments for wrapping the cropper with a SampleWrapper. """ - face_cropper = face_crop_solver( + face_cropper = helpers.face_crop_solver( cropped_image_size=cropped_image_size, cropped_positions=cropped_positions, fixed_positions=fixed_positions, diff --git a/doc/conf.py b/doc/conf.py index be5f7f3fffe99bc877ef4849f826968b1499eb6b..cc6627616e420fec5db36ff5807f2808f668accb 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -26,7 +26,7 @@ extensions = [ 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinx.ext.mathjax', - #'matplotlib.sphinxext.plot_directive' + 'matplotlib.sphinxext.plot_directive' ] # Be picky about warnings diff --git a/doc/faq.rst b/doc/faq.rst index bebdd9a2452922526d73dd675cd5d6d02ddd120b..cf281bd6074c813f76a2333aecf41479458013f4 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -38,35 +38,6 @@ There are currently three available modes : 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) +.. plot:: plot/default_crops.py + :include-source: True \ No newline at end of file diff --git a/doc/img/cropping_example_dnn.png b/doc/img/cropping_example_dnn.png deleted file mode 100644 index 0b38460273d53be65bcfecc7a9a198913e49c26c..0000000000000000000000000000000000000000 Binary files a/doc/img/cropping_example_dnn.png and /dev/null differ diff --git a/doc/img/cropping_example_legacy.png b/doc/img/cropping_example_legacy.png deleted file mode 100644 index ccfbba980f986b8f5d415dbf467799e9edd3504b..0000000000000000000000000000000000000000 Binary files a/doc/img/cropping_example_legacy.png and /dev/null differ diff --git a/doc/img/cropping_example_pad.png b/doc/img/cropping_example_pad.png deleted file mode 100644 index 81c5aab312a9e972be971647d589b70a57240f74..0000000000000000000000000000000000000000 Binary files a/doc/img/cropping_example_pad.png and /dev/null differ diff --git a/doc/plot/default_crops.py b/doc/plot/default_crops.py new file mode 100644 index 0000000000000000000000000000000000000000..2507cd4fa71f6c5abe128b0d385a535914a5728a --- /dev/null +++ b/doc/plot/default_crops.py @@ -0,0 +1,43 @@ +import bob.io.image +from bob.bio.face.helpers import get_default_cropped_positions +from bob.bio.face.preprocessor import FaceCrop +import matplotlib.pyplot as plt + +src = bob.io.image.load("../img/cropping_example_source.png") +modes = ["legacy", "dnn", "pad"] +cropped_images = [] + + +SIZE = 160 +# Pick cropping mode +for mode in modes: + if mode == "legacy": + cropped_image_size = (SIZE, 4 * SIZE // 5) + else: + cropped_image_size = (SIZE, SIZE) + + annotation_type = "eyes-center" + # Load default cropped positions + cropped_positions = get_default_cropped_positions( + mode, cropped_image_size, annotation_type + ) + + # Instanciate cropper and crop + cropper = FaceCrop( + cropped_image_size=cropped_image_size, + cropped_positions=cropped_positions, + fixed_positions={"reye": (480, 380), "leye": (480, 650)}, + color_channel="rgb", + ) + + cropped_images.append(cropper.transform([src])[0].astype("uint8")) + + +# Visualize cropped images +fig, axes = plt.subplots(2, 2, figsize=(10, 10)) + +for i, (img, label) in enumerate(zip([src] + cropped_images, ["original"] + modes)): + ax = axes[i // 2, i % 2] + ax.axis("off") + ax.imshow(bob.io.image.to_matplotlib(img)) + ax.set_title(label)