ImageProcessor.py refactoring

This commit is contained in:
iperov 2022-05-18 14:24:39 +04:00
parent 2d3d9874bf
commit b3bc4e7345

View file

@ -847,7 +847,7 @@ class ImageProcessor:
else:
raise ValueError('unsupported dtype')
def to_ufloat32(self) -> 'ImageProcessor':
def to_ufloat32(self, as_tanh=False) -> 'ImageProcessor':
"""
Convert to uniform float32
if current image dtype uint8, then image will be divided by / 255.0
@ -855,7 +855,11 @@ class ImageProcessor:
"""
if self._img.dtype == np.uint8:
self._img = self._img.astype(np.float32)
self._img /= 255.0
if as_tanh:
self._img /= 127.5
self._img -= 1.0
else:
self._img /= 255.0
return self