Skip to content
Snippets Groups Projects
Commit 3161603c authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'fix-multicrop' into 'master'

Resolve "MultiFace crop issue"

Closes #45

See merge request !114
parents 272fdae8 f7576d9f
No related branches found
No related tags found
1 merge request!114Resolve "MultiFace crop issue"
Pipeline #49864 passed
...@@ -374,7 +374,7 @@ class FaceCrop(Base): ...@@ -374,7 +374,7 @@ class FaceCrop(Base):
class MultiFaceCrop(Base): class MultiFaceCrop(Base):
""" Wraps around FaceCrop to enable a dynamical cropper that can handle several annotation types. """Wraps around FaceCrop to enable a dynamical cropper that can handle several annotation types.
Initialization and usage is similar to the FaceCrop, but the main difference here is that one specifies Initialization and usage is similar to the FaceCrop, but the main difference here is that one specifies
a *list* of cropped_positions, and optionally a *list* of associated fixed positions. a *list* of cropped_positions, and optionally a *list* of associated fixed positions.
...@@ -400,26 +400,39 @@ class MultiFaceCrop(Base): ...@@ -400,26 +400,39 @@ class MultiFaceCrop(Base):
allow_upside_down_normalized_faces=False, allow_upside_down_normalized_faces=False,
**kwargs, **kwargs,
): ):
# Check parameters
assert isinstance(cropped_positions_list, list) assert isinstance(cropped_positions_list, list)
if fixed_positions_list is None: if fixed_positions_list is None:
fixed_positions_list = [None] * len(cropped_positions_list) fixed_positions_list = [None] * len(cropped_positions_list)
assert isinstance(fixed_positions_list, list) assert isinstance(fixed_positions_list, list)
# copy parameters (sklearn convention : each explicit __init__ argument *has* to become an attribute of the estimator)
self.cropped_image_size = cropped_image_size
self.cropped_positions_list = cropped_positions_list
self.fixed_positions_list = fixed_positions_list
self.mask_sigma = mask_sigma
self.mask_neighbors = mask_neighbors
self.mask_seed = mask_seed
if isinstance(annotator, str):
annotator = load_resource(annotator, "annotator")
self.annotator = annotator
self.allow_upside_down_normalized_faces = allow_upside_down_normalized_faces
# Instantiate individual croppers
self.croppers = {} self.croppers = {}
for cropped_positions, fixed_positions in zip( for cropped_positions, fixed_positions in zip(
cropped_positions_list, fixed_positions_list self.cropped_positions_list, self.fixed_positions_list
): ):
assert len(cropped_positions) == 2 assert len(cropped_positions) == 2
self.croppers[tuple(cropped_positions)] = FaceCrop( self.croppers[tuple(cropped_positions)] = FaceCrop(
cropped_image_size, self.cropped_image_size,
cropped_positions, cropped_positions,
fixed_positions, fixed_positions,
mask_sigma, self.mask_sigma,
mask_neighbors, self.mask_neighbors,
mask_seed, self.mask_seed,
annotator, self.annotator,
allow_upside_down_normalized_faces, self.allow_upside_down_normalized_faces,
**kwargs, **kwargs,
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment