MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / Scale

Class Scale

transforms/joint_transforms.py:293–319  ·  view source on GitHub ↗

Scale image such that longer side is == size

Source from the content-addressed store, hash-verified

291
292
293class Scale(object):
294 """
295 Scale image such that longer side is == size
296 """
297
298 def __init__(self, size):
299 self.size = size
300
301 def __call__(self, img, mask):
302 assert img.size == mask.size
303 w, h = img.size
304
305 if w > h:
306 long_edge = w
307 else:
308 long_edge = h
309
310 if long_edge == self.size:
311 return img, mask
312
313 scale = self.size / long_edge
314 target_w = int(w * scale)
315 target_h = int(h * scale)
316 target_size = (target_w, target_h)
317
318 return img.resize(target_size, Image.BILINEAR), \
319 mask.resize(target_size, Image.NEAREST)
320
321
322class new_Scale(object):

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected