forked from aitorzip/PyTorch-CycleGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomTransforms.py
More file actions
32 lines (26 loc) · 875 Bytes
/
customTransforms.py
File metadata and controls
32 lines (26 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from skimage.exposure import rescale_intensity
class RescaleToZeroOne(object):
#Converts a PyTorch Tensor with RGB Range [0, 255] to PyTorch Tensor [0,1]
def __call__(self, pic):
"""
Args:
pic (tensor or numpy.ndarray): Image to be rescaled.
Returns:
Tensor: Converted image.
"""
#return pic/255
return pic/pic.max()
def __repr__(self):
return self.__class__.__name__ + '()'
class RescaleToOneOne(object):
#Converts a PyTorch Tensor with RGB Range [0, 255] to PyTorch Tensor [0,1]
def __call__(self, pic):
"""
Args:
pic (tensor or numpy.ndarray): Image to be rescaled.
Returns:
Tensor: Converted image.
"""
return ((pic/pic.max())*2)-1
def __repr__(self):
return self.__class__.__name__ + '()'