in segmentation/util/transform.py [0:0]
def __init__(self, size, crop_type='center', padding=None, ignore_label=255):
if isinstance(size, int):
self.crop_h = size
self.crop_w = size
elif isinstance(size, collections.Iterable) and len(size) == 2 \
and isinstance(size[0], int) and isinstance(size[1], int) \
and size[0] > 0 and size[1] > 0:
self.crop_h = size[0]
self.crop_w = size[1]
else:
raise (RuntimeError("crop size error.\n"))
if crop_type == 'center' or crop_type == 'rand':
self.crop_type = crop_type
else:
raise (RuntimeError("crop type error: rand | center\n"))
if padding is None:
self.padding = padding
elif isinstance(padding, list):
if all(isinstance(i, numbers.Number) for i in padding):
self.padding = padding
else:
raise (RuntimeError("padding in Crop() should be a number list\n"))
if len(padding) != 3:
raise (RuntimeError("padding channel is not equal with 3\n"))
else:
raise (RuntimeError("padding in Crop() should be a number list\n"))
if isinstance(ignore_label, int):
self.ignore_label = ignore_label
else:
raise (RuntimeError("ignore_label should be an integer number\n"))