def __init__(self, data_path, label_path, input_shape, mode='image-level', split=None, train=None, len_epoch=1000, preprocess='z', transform=None, target_transform=None, dtypes=('uint8', 'uint8')): self.data_path = data_path self.label_path = label_path self.input_shape = input_shape self.mode = mode self.len_epoch = len_epoch self.transform = transform self.target_transform = target_transform self.data = read_tif(data_path, dtype=dtypes[0]) self.labels = read_tif(label_path, dtype=dtypes[1]) mu, std = self.get_stats() self.mu = mu self.std = std self.preprocess = preprocess if preprocess == 'z': self.data = normalize(self.data, mu, std) elif preprocess == 'unit': self.data = normalize(self.data, 0, 255) self.labels = normalize(self.labels, 0, 255) if split is not None: if train: s = int(split * self.data.shape[2]) self.data = self.data[:, :, :s] self.labels = self.labels[:, :, :s] else: s = int(split * self.data.shape[2]) self.data = self.data[:, :, s:] self.labels = self.labels[:, :, s:]
def __init__(self, data_path, label_path, input_shape, len_epoch=1000, preprocess='z', transform=None, target_transform=None, dtypes=('uint8','uint8')): self.data_path = data_path self.label_path = label_path self.input_shape = input_shape self.len_epoch = len_epoch self.transform = transform self.target_transform = target_transform self.data = read_tif(data_path, dtype=dtypes[0]) self.labels = read_tif(label_path, dtype=dtypes[1]) mu, std = self.get_stats() self.mu = mu self.std = std self.preprocess = preprocess if preprocess == 'z': self.data = normalize(self.data, mu, std) elif preprocess == 'unit': self.data = normalize(self.data, 0, 255) self.labels = normalize(self.labels, 0, 255)
def __init__(self, data_path, input_shapes, len_epoch=1000, preprocess='z', transform=None, dtype='uint8'): self.data_path = data_path self.input_shapes = input_shapes self.len_epoch = len_epoch self.transform = transform self.data = read_tif(data_path, dtype=dtype) mu, std = self.get_stats() self.mu = mu self.std = std self.preprocess = preprocess if preprocess == 'z': self.data = normalize(self.data, mu, std) elif preprocess == 'unit': self.data = normalize(self.data, 0, 255)
default=0) args = parser.parse_args() args.input_size = [int(item) for item in args.input_size.split(',')] """ Setup writing directory """ print('[%s] Setting up write directories' % (datetime.datetime.now())) if args.write_dir is not None: if not os.path.exists(args.write_dir): os.mkdir(args.write_dir) """ Load and normalize the data """ print('[%s] Loading and normalizing the data' % (datetime.datetime.now())) test_data = read_tif(args.data, dtype='uint8') mu = np.mean(test_data) std = np.std(test_data) test_data = normalize(test_data, mu, std) if len(test_data.shape) < 3: test_data = test_data[np.newaxis, ...] """ Load the network """ print('[%s] Loading network' % (datetime.datetime.now())) net = load_net(args.net) """ Segmentation """ print('[%s] Starting segmentation' % (datetime.datetime.now())) segmentation = segment_pixels(test_data,