Commit c422554f authored by Laurent COLBOIS's avatar Laurent COLBOIS

Change color channel AFTER cropping for legacy baselines, as some croppers...

Change color channel AFTER cropping for legacy baselines, as some croppers (mainly BoundingBoxCropAnnotator) use MTCNN internally which expects RGB images
parent df0b3ff7
Pipeline #53998 passed with stage
in 27 minutes and 27 seconds
......@@ -119,7 +119,7 @@ class INormLBP(Base):
"""
def _crop_one_sample(image, annotations=None):
image = self.change_color_channel(image)
if self.cropper is not None:
# TODO: USE THE TAG `ALLOW_ANNOTATIONS`
image = (
......@@ -127,11 +127,13 @@ class INormLBP(Base):
if annotations is None
else self.cropper.transform([image], [annotations])
)
# LBP's doesn't work with batches, so we have to work this out
image = self.lbp_extractor(image[0])
# Also, we change the color channel *after* cropping : some croppers use MTCNN internally, that works on multichannel images
image = self.change_color_channel(image[0])
image = self.lbp_extractor(image)
else:
# Handle with the cropper is None
image = self.change_color_channel(image)
image = self.lbp_extractor(image)
return self.data_type(image)
......@@ -139,7 +141,9 @@ class INormLBP(Base):
if annotations is None:
return [_crop_one_sample(data) for data in X]
else:
return [_crop_one_sample(data, annot) for data, annot in zip(X, annotations)]
return [
_crop_one_sample(data, annot) for data, annot in zip(X, annotations)
]
def __getstate__(self):
d = dict(self.__dict__)
......
......@@ -109,7 +109,7 @@ class TanTriggs(Base):
"""
def _crop_one_sample(image, annotations=None):
image = self.change_color_channel(image)
if self.cropper is not None:
# TODO: USE THE TAG `ALLOW_ANNOTATIONS`
image = (
......@@ -117,17 +117,22 @@ class TanTriggs(Base):
if annotations is None
else self.cropper.transform([image], [annotations])
)
image = self.tan_triggs(image[0])
# We change the color channel *after* cropping : some croppers use MTCNN internally, that works on multichannel images
image = self.change_color_channel(image[0])
image = self.tan_triggs(image)
else:
# Handle with the cropper is None
image = self.change_color_channel(image)
image = self.tan_triggs(image)
return self.data_type(image)
if annotations is None:
return [_crop_one_sample(data) for data in X]
else:
return [_crop_one_sample(data, annot) for data, annot in zip(X, annotations)]
return [
_crop_one_sample(data, annot) for data, annot in zip(X, annotations)
]
def __getstate__(self):
d = dict(self.__dict__)
......
Markdown is supported
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