Dataset

UnPairedDataset

class UnPairedDataset(img_path_a, img_path_b, pool_size, pool_prob, img_size, n_channels, img_extensions=['.png', '.jpg'], load_fn=<sphinx.ext.autodoc.importer._MockObject object>)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

Dataset to whold 2 unpaired datasets and returning samples from both of them.

Contains an Image pool for each dataset.

See also

UnPairedRandomSampler, ImagePool

Parameters:
  • img_path_a (str) – the directory path containing the data for image domain A
  • img_path_b (str) – the directory path containing the data for image domain B
  • pool_size (int) – the size for both image pools
  • pool_prob (float) – the sampling probability for both image pools
  • img_size (int) – the size of the input image
  • n_channels (int) – the number of image channels
  • img_extensions (list, optional) – valid file extensions for images (the default is [“.png”, “.jpg”])
  • load_fn (optional) – function to load a single sample (the default is default_load_fn_2d)

See also

delira.data_loading.dataset.AbstractDataset

get_sample_from_index(index)[source]

Returns the actual data given from an index Since this dataset contains two unpaired datasets, the index should be a tuple of ints containing the actual indices

If the index is out of bounds for the corresponding datasets it restarts at 0

Parameters:index (tuple) – a tuple of ints containing the actual indices
Returns:the samples from both dataset as specified by index
Return type:tuple

ImagePool

class ImagePool(poolsize=50, p=0.5)[source]

Bases: object

Class to buffer images on CPU to avoid huge memory overload enable the model to revisit already seen images. This should prevent them to be forgotten

Parameters:
  • poolsize (int, optional) – the size of the image pool (the default is 50),
  • p (float, optional) – the probability with which an image of the pool should be returned