blueoil
blueoil copied to clipboard
Pillow version has different resizing results
There is a resize process in pre_process, but the default interpolation method differs depending on the Pillow version, so it seems to affect learning.
https://github.com/blue-oil/blueoil/blob/master/lmnet/lmnet/pre_processor.py#L38
Pillow v7.0.0 https://github.com/python-pillow/Pillow/blob/7.0.0/src/PIL/Image.py#L1786
Pillow v6.2.2 https://github.com/python-pillow/Pillow/blob/6.2.2/src/PIL/Image.py#L1830
I think it is good to set the default interpolation method of blueoil's resize function to BICUBIC.
RESAMPLE_NEAREST = PIL.Image.NEAREST
RESAMPLE_BICUBIC = PIL.Image.BICUBIC
def resize(image, size=[256, 256], resumple=RESAMPLE_BICUBIC):
...
class Resize(Processor):
def __init__(self, size, resample=RESAMPLE_BICUBIC):
self.size = size
self.resample = resample
def __call__(self, image, mask=None, **kwargs):
image = resize(image, size=self.size, resample=self.resample)
if mask is not None:
mask = resize(mask, size=self.size, resample=self.resample)
return dict({'image': image, 'mask': mask}, **kwargs)
It may be unnecessary because the version of Pillow is specified in requirement.txt.
https://github.com/blue-oil/blueoil/blob/master/requirements.txt#L6
Yes, that's a good point, I agree about this, it would be good to specify the type of resampling. Otherwise, in the future, we might upgrade Pillow and not realize that the default resampling type has changed.
But, so far, we have been using resample=NEAREST
default, I guess? So maybe we should specify that one.
It's interesting, in release note 2.7.0, they say the quality of NEAREST
is close to BICUBIC
. But in release note 7.0.0, they say NEAREST
is fast but low quality.