
My images have the size (128, 128, 128) and when I load them in I get a 5D tensor of size (batch_size, depth, heigt, width, number_of_channels), e.g. Training_generator = DataGenerator(partition, **params) Images = glob.glob(os.path.join(im_path, "*.tif")) Label_path = "some/path/for/the/label_images/" 'label_path': "some/path/for/the/label_images", X = X.reshape(self.batch_size, *self.dim, 1) Y = _categorical(img_Y, num_classes=self.n_classes) Img_Y = skimage.io.imread(os.path.join(label_path, ID))

Img_X = skimage.io.imread(os.path.join(im_path, ID)) Self.indexes = np.arange(len(self.list_IDs))ĭef _data_generation(self, list_IDs_temp): X, y = self._data_generation(list_IDs_temp) Return int(np.floor(len(self.list_IDs) / self.batch_size))


'Denotes the number of batches per epoch' N_classes=4, shuffle=True, augment=False): """This structure guarantees that the network will only train once on each sample per epoch"""ĭef _init_(self, list_IDs, im_path, label_path, batch_size=4, dim=(128, 128, 128), Since the ImageDataGenerator by keras is not suitable for 3D volumes, I started to write my own generator for keras (semantic segmentation, not classification!).ġ) If there is anybody out there that has adapted the ImageDataGenerator code to work with 3D volumes, please share it! This guy has done it for videos.Ģ) According to this tutorial I wrote a custom generator.Ĭlass DataGenerator():
