def train_transforms(sample, image_shape, jittering, **kwargs): """ Training data augmentation transformations Parameters ---------- sample : dict Sample to be augmented image_shape : tuple (height, width) Image dimension to reshape jittering : tuple (brightness, contrast, saturation, hue) Color jittering parameters Returns ------- sample : dict Augmented sample """ # (orig_w, orig_h) = sample['rgb'].size # (h, w) = shape # factor = w/orig_w # h=h*factor if len(image_shape) > 0: sample = resize_sample(sample, image_shape) sample = duplicate_sample(sample) if len(jittering) > 0: sample = colorjitter_sample(sample, jittering) if "max_roll_angle" in kwargs: sample = rotate_sample(sample, degrees=kwargs["max_roll_angle"]) if "random_center_crop" in kwargs: if kwargs["random_center_crop"]: sample = random_center_crop_sample(sample) sample = to_tensor_sample(sample) return sample
def train_transforms(sample, image_shape, jittering): """ Training data augmentation transformations Parameters ---------- sample : dict Sample to be augmented image_shape : tuple (height, width) Image dimension to reshape jittering : tuple (brightness, contrast, saturation, hue) Color jittering parameters Returns ------- sample : dict Augmented sample """ if len(image_shape) > 0: sample = resize_sample(sample, image_shape) sample = duplicate_sample(sample) if len(jittering) > 0: sample = colorjitter_sample(sample, jittering) sample = to_tensor_sample(sample) return sample
def train_transforms(sample, image_shape, jittering, crop_train_borders): """ Training data augmentation transformations Parameters ---------- sample : dict Sample to be augmented image_shape : tuple (height, width) Image dimension to reshape jittering : tuple (brightness, contrast, saturation, hue) Color jittering parameters crop_train_borders : tuple (left, top, right, down) Border for cropping Returns ------- sample : dict Augmented sample """ if len(crop_train_borders) > 0: borders = parse_crop_borders(crop_train_borders, sample['rgb'].size[::-1]) sample = crop_sample(sample, borders) if len(image_shape) > 0: sample = resize_sample(sample, image_shape) sample = duplicate_sample(sample) if len(jittering) > 0: sample = colorjitter_sample(sample, jittering) sample = to_tensor_sample(sample) return sample