mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-07-06 21:12:08 -07:00
ImageProcessor.py refactoring
This commit is contained in:
parent
2d3d9874bf
commit
b3bc4e7345
1 changed files with 100 additions and 96 deletions
|
@ -847,7 +847,7 @@ class ImageProcessor:
|
||||||
else:
|
else:
|
||||||
raise ValueError('unsupported dtype')
|
raise ValueError('unsupported dtype')
|
||||||
|
|
||||||
def to_ufloat32(self) -> 'ImageProcessor':
|
def to_ufloat32(self, as_tanh=False) -> 'ImageProcessor':
|
||||||
"""
|
"""
|
||||||
Convert to uniform float32
|
Convert to uniform float32
|
||||||
if current image dtype uint8, then image will be divided by / 255.0
|
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:
|
if self._img.dtype == np.uint8:
|
||||||
self._img = self._img.astype(np.float32)
|
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
|
return self
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue