Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
p_per_sample=self.Config.P_SAMP))
if self.Config.DAUG_NOISE:
tfs.append(GaussianNoiseTransform(noise_variance=self.Config.DAUG_NOISE_VARIANCE,
p_per_sample=self.Config.P_SAMP))
if self.Config.DAUG_MIRROR:
tfs.append(MirrorTransform())
if self.Config.DAUG_FLIP_PEAKS:
tfs.append(FlipVectorAxisTransform())
tfs.append(NumpyToTensor(keys=["data", "seg"], cast_to="float"))
#num_cached_per_queue 1 or 2 does not really make a difference
batch_gen = MultiThreadedAugmenter(batch_generator, Compose(tfs), num_processes=num_processes,
num_cached_per_queue=1, seeds=None, pin_memory=True)
return batch_gen # data: (batch_size, channels, x, y), seg: (batch_size, channels, x, y)
patch_center_dist_from_border=cf.da_kwargs['rand_crop_dist'],
do_elastic_deform=cf.da_kwargs['do_elastic_deform'],
alpha=cf.da_kwargs['alpha'], sigma=cf.da_kwargs['sigma'],
do_rotation=cf.da_kwargs['do_rotation'], angle_x=cf.da_kwargs['angle_x'],
angle_y=cf.da_kwargs['angle_y'], angle_z=cf.da_kwargs['angle_z'],
do_scale=cf.da_kwargs['do_scale'], scale=cf.da_kwargs['scale'],
random_crop=cf.da_kwargs['random_crop'])
my_transforms.append(spatial_transform)
else:
my_transforms.append(CenterCropTransform(crop_size=cf.patch_size[:cf.dim]))
my_transforms.append(ConvertSegToBoundingBoxCoordinates(cf.dim, cf.roi_items, False, cf.class_specific_seg))
all_transforms = Compose(my_transforms)
# multithreaded_generator = SingleThreadedAugmenter(data_gen, all_transforms)
multithreaded_generator = MultiThreadedAugmenter(data_gen, all_transforms, num_processes=data_gen.n_filled_threads,
seeds=range(data_gen.n_filled_threads))
return multithreaded_generator
do_rotation=cf.da_kwargs['do_rotation'], angle_x=cf.da_kwargs['angle_x'],
angle_y=cf.da_kwargs['angle_y'], angle_z=cf.da_kwargs['angle_z'],
do_scale=cf.da_kwargs['do_scale'], scale=cf.da_kwargs['scale'],
random_crop=cf.da_kwargs['random_crop'],
border_mode_data=cf.da_kwargs['border_mode_data'])
my_transforms.append(spatial_transform)
else:
my_transforms.append(CenterCropTransform(crop_size=cf.patch_size[:cf.dim]))
if cf.create_bounding_box_targets:
my_transforms.append(ConvertSegToBoundingBoxCoordinates(cf.dim, cf.roi_items, False, cf.class_specific_seg))
#batch receives entry 'bb_target' w bbox coordinates as [y1,x1,y2,x2,z1,z2].
#my_transforms.append(ConvertSegToOnehotTransform(classes=range(cf.num_seg_classes)))
all_transforms = Compose(my_transforms)
#MTAugmenter creates iterator from data iterator data_gen after applying the composed transform all_transforms
multithreaded_generator = MultiThreadedAugmenter(data_gen, all_transforms, num_processes=data_gen.n_filled_threads,
seeds=range(data_gen.n_filled_threads))
return multithreaded_generator
border_mode_data=cf.da_kwargs['border_mode_data'])
my_transforms.append(spatial_transform)
gamma_transform = GammaTransform(gamma_range=cf.da_kwargs["gamma_range"], invert_image=False,
per_channel=False, retain_stats=False)
my_transforms.append(gamma_transform)
else:
my_transforms.append(CenterCropTransform(crop_size=cf.patch_size[:cf.dim]))
if cf.create_bounding_box_targets:
my_transforms.append(ConvertSegToBoundingBoxCoordinates(cf.dim, cf.roi_items, False, cf.class_specific_seg))
#batch receives entry 'bb_target' w bbox coordinates as [y1,x1,y2,x2,z1,z2].
#my_transforms.append(ConvertSegToOnehotTransform(classes=range(cf.num_seg_classes)))
all_transforms = Compose(my_transforms)
#MTAugmenter creates iterator from data iterator data_gen after applying the composed transform all_transforms
multithreaded_generator = MultiThreadedAugmenter(data_gen, all_transforms, num_processes=cf.n_workers,
seeds=np.random.randint(0,cf.n_workers*2,size=cf.n_workers))
return multithreaded_generator
if self.Config.DAUG_RESAMPLE:
tfs.append(SimulateLowResolutionTransform(zoom_range=(0.5, 1), p_per_sample=0.2))
if self.Config.DAUG_NOISE:
tfs.append(GaussianNoiseTransform(noise_variance=(0, 0.05), p_per_sample=0.2))
if self.Config.DAUG_MIRROR:
tfs.append(MirrorTransform())
if self.Config.DAUG_FLIP_PEAKS:
tfs.append(FlipVectorAxisTransform())
tfs.append(NumpyToTensor(keys=["data", "seg"], cast_to="float"))
# num_cached_per_queue 1 or 2 does not really make a difference
batch_gen = MultiThreadedAugmenter(batch_generator, Compose(tfs), num_processes=num_processes,
num_cached_per_queue=1, seeds=None, pin_memory=True)
return batch_gen # data: (batch_size, channels, x, y), seg: (batch_size, channels, x, y)
patch_center_dist_from_border=cf.da_kwargs['rand_crop_dist'],
do_elastic_deform=cf.da_kwargs['do_elastic_deform'],
alpha=cf.da_kwargs['alpha'], sigma=cf.da_kwargs['sigma'],
do_rotation=cf.da_kwargs['do_rotation'], angle_x=cf.da_kwargs['angle_x'],
angle_y=cf.da_kwargs['angle_y'], angle_z=cf.da_kwargs['angle_z'],
do_scale=cf.da_kwargs['do_scale'], scale=cf.da_kwargs['scale'],
random_crop=cf.da_kwargs['random_crop'])
my_transforms.append(spatial_transform)
else:
my_transforms.append(CenterCropTransform(crop_size=cf.patch_size[:cf.dim]))
my_transforms.append(ConvertSegToBoundingBoxCoordinates(cf.dim, get_rois_from_seg_flag=False, class_specific_seg_flag=cf.class_specific_seg_flag))
all_transforms = Compose(my_transforms)
# multithreaded_generator = SingleThreadedAugmenter(data_gen, all_transforms)
multithreaded_generator = MultiThreadedAugmenter(data_gen, all_transforms, num_processes=cf.n_workers, seeds=range(cf.n_workers))
return multithreaded_generator