Skip to content
Snippets Groups Projects
Commit b30702b7 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

[preprocessor][FaceCrop] Load annotators if they are passed as a string

parent 992e72c0
No related branches found
No related tags found
2 merge requests!71Face crop improvements,!64Dask pipelines
...@@ -10,8 +10,8 @@ import logging ...@@ -10,8 +10,8 @@ import logging
from .Base import Base from .Base import Base
logger = logging.getLogger("bob.bio.face") logger = logging.getLogger("bob.bio.face")
from sklearn.utils import check_array from bob.bio.base import load_resource
from bob.pipelines.sample import SampleBatch
class FaceCrop(Base): class FaceCrop(Base):
"""Crops the face according to the given annotations. """Crops the face according to the given annotations.
...@@ -85,18 +85,18 @@ class FaceCrop(Base): ...@@ -85,18 +85,18 @@ class FaceCrop(Base):
mask_seed : int or None mask_seed : int or None
The random seed to apply for mask extrapolation. The random seed to apply for mask extrapolation.
allow_upside_down_normalized_faces: bool, optional
If ``False`` (default), a ValueError is raised when normalized faces are going to be
upside down compared to input image. This allows you to catch wrong annotations in
your database easily. If you are sure about your input, you can set this flag to
``True``.
.. warning:: .. warning::
When run in parallel, the same random seed will be applied to all When run in parallel, the same random seed will be applied to all
parallel processes. Hence, results of parallel execution will differ parallel processes. Hence, results of parallel execution will differ
from the results in serial execution. from the results in serial execution.
allow_upside_down_normalized_faces: bool, optional
If ``False`` (default), a ValueError is raised when normalized faces are going to be
upside down compared to input image. This allows you to catch wrong annotations in
your database easily. If you are sure about your input, you can set this flag to
``True``.
annotator : :any:`bob.bio.base.annotator.Annotator` annotator : :any:`bob.bio.base.annotator.Annotator`
If provided, the annotator will be used if the required annotations are If provided, the annotator will be used if the required annotations are
missing. missing.
...@@ -142,7 +142,7 @@ class FaceCrop(Base): ...@@ -142,7 +142,7 @@ class FaceCrop(Base):
self.mask_sigma = mask_sigma self.mask_sigma = mask_sigma
self.mask_neighbors = mask_neighbors self.mask_neighbors = mask_neighbors
self.mask_seed = mask_seed self.mask_seed = mask_seed
self.annotator = annotator self.annotator = load_resource(annotator, "annotator")
self.allow_upside_down_normalized_faces = allow_upside_down_normalized_faces self.allow_upside_down_normalized_faces = allow_upside_down_normalized_faces
# create objects required for face cropping # create objects required for face cropping
...@@ -300,7 +300,7 @@ class FaceCrop(Base): ...@@ -300,7 +300,7 @@ class FaceCrop(Base):
The cropped face. The cropped face.
""" """
def _crop(image, annot): def _crop(image, annot):
# if annotations are missing and cannot do anything else return None. # if annotations are missing and cannot do anything else return None.
if ( if (
not self.is_annotations_valid(annot) not self.is_annotations_valid(annot)
......
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