Skip to content
Snippets Groups Projects
Commit 5e4e50df authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[dataset] added a transform to resize images

parent 45119335
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ from .utils import FaceCropper ...@@ -6,6 +6,7 @@ from .utils import FaceCropper
from .utils import RollChannels from .utils import RollChannels
from .utils import ToTensor from .utils import ToTensor
from .utils import Normalize from .utils import Normalize
from .utils import Resize
from .utils import map_labels from .utils import map_labels
from .utils import ConcatDataset from .utils import ConcatDataset
......
...@@ -54,6 +54,20 @@ class Normalize(object): ...@@ -54,6 +54,20 @@ class Normalize(object):
sample['image'] = self.op(sample['image']) sample['image'] = self.op(sample['image'])
return sample return sample
class Resize(object):
def __init__(self, size):
self.op = transforms.Resize(size)
def __call__(self, sample):
# convert to PIL image
from PIL.Image import fromarray
img = fromarray(sample['image'].squeeze())
img = self.op(img)
sample['image'] = numpy.array(img)
sample['image'] = sample['image'][..., numpy.newaxis]
return sample
def map_labels(raw_labels, start_index=0): def map_labels(raw_labels, start_index=0):
""" """
Map the ID label to [0 - # of IDs] Map the ID label to [0 - # of IDs]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment