def get_train_augmentors(self, input_shape, output_shape, view=False): shape_augs = [ imgaug.Affine( shear=5, # in degree scale=(0.8, 1.2), rotate_max_deg=179, translate_frac=(0.01, 0.01), interp=cv2.INTER_NEAREST, border=cv2.BORDER_CONSTANT), imgaug.Flip(vert=True), imgaug.Flip(horiz=True), imgaug.CenterCrop(input_shape), ] input_augs = self.input_augs label_augs = [] if self.model_type == 'unet' or self.model_type == 'micronet': label_augs =[GenInstanceUnetMap(crop_shape=output_shape)] if self.model_type == 'dcan': label_augs =[GenInstanceContourMap(crop_shape=output_shape)] if self.model_type == 'dist': label_augs = [GenInstanceDistance(crop_shape=output_shape, inst_norm=False)] if self.model_type == 'np_hv' or self.model_type == 'np_hv_opt': label_augs = [GenInstanceHV(crop_shape=output_shape)] if self.model_type == 'np_dist': label_augs = [GenInstanceDistance(crop_shape=output_shape, inst_norm=True)] if not self.type_classification: label_augs.append(BinarizeLabel()) if not view: label_augs.append(imgaug.CenterCrop(output_shape)) return shape_augs, input_augs, label_augs
def get_train_augmentors(self, input_shape, output_shape, view=False): print(input_shape, output_shape) shape_augs = [ imgaug.Affine( shear=5, # in degree scale=(0.8, 1.2), rotate_max_deg=179, translate_frac=(0.01, 0.01), interp=cv2.INTER_NEAREST, border=cv2.BORDER_CONSTANT), imgaug.Flip(vert=True), imgaug.Flip(horiz=True), imgaug.CenterCrop(input_shape), ] input_augs = [ imgaug.RandomApplyAug( imgaug.RandomChooseAug([ GaussianBlur(), MedianBlur(), imgaug.GaussianNoise(), ]), 0.5), # standard color augmentation imgaug.RandomOrderAug([ imgaug.Hue((-8, 8), rgb=True), imgaug.Saturation(0.2, rgb=True), imgaug.Brightness(26, clip=True), imgaug.Contrast((0.75, 1.25), clip=True), ]), imgaug.ToUint8(), ] label_augs = [] if self.model_type == 'unet' or self.model_type == 'micronet': label_augs = [GenInstanceUnetMap(crop_shape=output_shape)] if self.model_type == 'dcan': label_augs = [GenInstanceContourMap(crop_shape=output_shape)] if self.model_type == 'dist': label_augs = [ GenInstanceDistance(crop_shape=output_shape, inst_norm=False) ] if self.model_type == 'np_hv': label_augs = [GenInstanceHV(crop_shape=output_shape)] if self.model_type == 'np_dist': label_augs = [ GenInstanceDistance(crop_shape=output_shape, inst_norm=True) ] if not self.type_classification: label_augs.append(BinarizeLabel()) if not view: label_augs.append(imgaug.CenterCrop(output_shape)) return shape_augs, input_augs, label_augs
def get_train_augmentors(self, view=False): shape_augs = [ imgaug.Affine( shear=5, # in degree scale=(0.8, 1.2), rotate_max_deg=179, translate_frac=(0.01, 0.01), interp=cv2.INTER_NEAREST, border=cv2.BORDER_CONSTANT), imgaug.Flip(vert=True), imgaug.Flip(horiz=True), imgaug.CenterCrop(self.train_input_shape), ] input_augs = [ imgaug.RandomApplyAug( imgaug.RandomChooseAug([ GaussianBlur(), MedianBlur(), imgaug.GaussianNoise(), ]), 0.5), # standard color augmentation imgaug.RandomOrderAug([ imgaug.Hue((-8, 8), rgb=True), imgaug.Saturation(0.2, rgb=True), imgaug.Brightness(26, clip=True), imgaug.Contrast((0.75, 1.25), clip=True), ]), imgaug.ToUint8(), ] # default to 'xy' if self.model_mode != 'np+dst': label_augs = [GenInstanceXY(self.train_mask_shape)] else: label_augs = [GenInstanceDistance(self.train_mask_shape)] label_augs.append(BinarizeLabel()) if not view: label_augs.append(imgaug.CenterCrop(self.train_mask_shape)) return shape_augs, input_augs, label_augs
def get_train_augmentors(self, input_shape, output_shape, view=False): print(input_shape, output_shape) if self.model_mode == "class_rotmnist": shape_augs = [ imgaug.Affine(rotate_max_deg=359, interp=cv2.INTER_NEAREST, border=cv2.BORDER_CONSTANT), ] input_augs = [] else: shape_augs = [ imgaug.Affine( rotate_max_deg=359, translate_frac=(0.01, 0.01), interp=cv2.INTER_NEAREST, border=cv2.BORDER_REFLECT, ), imgaug.Flip(vert=True), imgaug.Flip(horiz=True), imgaug.CenterCrop(input_shape), ] input_augs = [ imgaug.RandomApplyAug( imgaug.RandomChooseAug([ GaussianBlur(), MedianBlur(), imgaug.GaussianNoise(), ]), 0.5, ), # Standard colour augmentation imgaug.RandomOrderAug([ imgaug.Hue((-8, 8), rgb=True), imgaug.Saturation(0.2, rgb=True), imgaug.Brightness(26, clip=True), imgaug.Contrast((0.75, 1.25), clip=True), ]), imgaug.ToUint8(), ] if self.model_mode == "seg_gland": label_augs = [] label_augs = [GenInstanceContourMap(mode=self.model_mode)] label_augs.append(BinarizeLabel()) if not view: label_augs.append(imgaug.CenterCrop(output_shape)) else: label_augs.append(imgaug.CenterCrop(input_shape)) return shape_augs, input_augs, label_augs elif self.model_mode == "seg_nuc": label_augs = [] label_augs = [GenInstanceMarkerMap()] label_augs.append(BinarizeLabel()) if not view: label_augs.append(imgaug.CenterCrop(output_shape)) else: label_augs.append(imgaug.CenterCrop(input_shape)) return shape_augs, input_augs, label_augs else: return shape_augs, input_augs