def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True, mean=None, stdev=None): rs = np.random.RandomState() if mean is None or stdev is None: mean = 0 std = 1 print("No mean and std given!") trsfm = [t3d.Normalize(mean, stdev), t3d.ToTensor(True)] self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm) super(hdf5_3d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True, mean=None, std=None): if mean is None or std is None: mean = 0 std = 1 print("No mean and std given!") #mean = 8.71 #std = 22.02 trsfm_train = transforms.Compose([ transforms.Resize(90), transforms.RandomHorizontalFlip(), #transforms.RandomAffine(45, translate=(.05,.05), scale=(0.95,1.05), shear=None, resample=False, fillcolor=0), transforms.CenterCrop(64), transforms.ToTensor(), transforms.Normalize(mean=[mean], std=[std]), ]) trsfm_test = transforms.Compose([ transforms.Resize(90), transforms.CenterCrop(64), transforms.ToTensor(), transforms.Normalize(mean=[mean], std=[std]), ]) ''' means and std for IMPRS dataset allDAPI_volume 141.42 18.85 mask_avgproj 128.16, 0.54 mask_maxproj 128.51, 1.23 mask_sumproj 126.145, 31.49 mask_volume 128.23, 0.84 ''' if training == True: trsfm = trsfm_train else: trsfm = trsfm_test self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm) super(hdf5_2d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True): rs = np.random.RandomState() mean = 143.68 stdev = 23.53 trsfm_train = [ #t3d.shotNoise(rs, alpha = 0.7, execution_prob = 0.2), #t3d.Downsample(rs, factor = 4.0, order=2), #t3d.RandomFlip(rs), t3d.RandomRotate90(rs), #t3d.RandomContrast(rs, factor = 0.8, execution_probability=0.2), #t3d.ElasticDeformation(rs, 3, alpha=20, sigma=3, execution_probability=0.2), #t3d.GaussianNoise(rs, 3), t3d.Normalize(mean, stdev), t3d.ToTensor(True) ] trsfm_test = [t3d.Normalize(mean, stdev), t3d.ToTensor(True)] ''' means and std for IMPRS dataset allDAPI_volume 141.42 18.85 mask_avgproj 128.16, 0.54 mask_maxproj 128.51, 1.23 mask_sumproj 126.145, 31.49 mask_volume 128.23, 0.84 allDAPI_volume0701 140.61 17.60 ''' if training == True: trsfm = trsfm_train else: trsfm = trsfm_test self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm) super(hdf5_3d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True, dataset=None, mean=0, stdev=1): rs = np.random.RandomState() trsfm_train = [ t3d.RandomRotate90(rs), t3d.Normalize(mean, stdev), t3d.ToTensor(True) ] trsfm_test = [t3d.Normalize(mean, stdev), t3d.ToTensor(True)] if training == True: trsfm = trsfm_train else: trsfm = trsfm_test self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class if dataset == None: self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm) else: self.dataset = dataset super(hdf5_3d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True, projected=False): if projected: rs = 256 cc = 224 else: rs = 90 cc = 64 trsfm_train = transforms.Compose([ transforms.Resize(rs), transforms.RandomHorizontalFlip(), transforms.RandomAffine(5, translate=(.05, .05), scale=(0.95, 1.05), shear=None, resample=False, fillcolor=0), transforms.CenterCrop(cc), transforms.ToTensor(), transforms.Normalize(mean=[8.18], std=[19.91]), ]) trsfm_test = transforms.Compose([ transforms.Resize(rs), transforms.CenterCrop(cc), transforms.ToTensor(), transforms.Normalize(mean=[8.18], std=[19.91]), ]) ''' means and std for IMPRS dataset allDAPI_volume 141.42 18.85 mask_avgproj 128.16, 0.54 mask_maxproj 128.51, 1.23 mask_sumproj 126.145, 31.49 mask_volume 128.23, 0.84 ''' if training == True: trsfm = trsfm_train else: trsfm = trsfm_test self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm, projection=projected) super(hdf5_2d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
def __init__(self, hdf5_path, batch_size, shuffle=True, shape=[7, 32, 32], validation_split=0.0, num_workers=1, training=True, mean=None, stdev=None): rs = np.random.RandomState() if mean is None or stdev is None: mean = 0 std = 1 print("No mean and std given!") #mean = 15.26 #stdev = 18.21 trsfm_train = [ t3d.shotNoise(rs, alpha=0.8, execution_prob=0.3), t3d.Downsample(rs, factor=999, order=0, execution_prob=0.2), t3d.RandomFlip(rs), t3d.RandomRotate90(rs), t3d.RandomRotate(rs, angle_spectrum=35, axes=[(1, 2)], mode='constant', order=0), t3d.Translate(rs, pixels=8, execution_prob=0.3), t3d.RandomContrast(rs, factor=0.8, execution_probability=0.3), #t3d.ElasticDeformation(rs, 3, alpha=20, sigma=3, execution_probability=0.2), #t3d.GaussianNoise(rs, 3), t3d.Normalize(mean, stdev), t3d.ToTensor(True) ] trsfm_test = [ #t3d.shotNoise(rs, alpha = 0.4, execution_prob = 1.0), #t3d.Downsample(rs, factor = 4.0, order=0, execution_prob = 1.0), t3d.Normalize(mean, stdev), t3d.ToTensor(True) ] ''' means and std for IMPRS dataset allDAPI_volume 141.42 18.85 mask_avgproj 128.16, 0.54 mask_maxproj 128.51, 1.23 mask_sumproj 126.145, 31.49 mask_volume 128.23, 0.84 allDAPI_volume0701 140.61 17.60 ''' if training == True: trsfm = trsfm_train else: trsfm = trsfm_test self.hdf5_path = hdf5_path self.batch_size = batch_size self.shape = shape importlib.reload( databases ) #used to get load any recent changes from database class self.dataset = databases.hdf5dataset(hdf5_path, shape=self.shape, training=training, transforms=trsfm) super(hdf5_3d_dataloader, self).__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)