benzina.torch.dataloader

class benzina.torch.dataloader.DataLoader(dataset, shape, path=None, batch_size=1, shuffle=False, sampler=None, batch_sampler=None, collate_fn=<sphinx.ext.autodoc.importer._MockObject object>, drop_last=False, timeout=0, device=None, multibuffering=3, seed=None, bias_transform=None, norm_transform=None, warp_transform=None)[source]

Loads images from a benzina.torch.dataset.Dataset. Encapsulates a sampler and data processing transformations.

Parameters:
  • dataset (benzina.torch.dataset.Dataset) – dataset from which to load the data.
  • shape (int or tuple of ints) – set the shape of the samples. Note that this does not imply a resize of the image but merely set the shape of the tensor in which the data will be copied.
  • path (str, optional) – path to the archive from which samples will be decoded. If not specified, the dataloader will attempt to get it from dataset.
  • batch_size (int, optional) – how many samples per batch to load. (default: 1)
  • shuffle (bool, optional) – set to True to have the data reshuffled at every epoch. (default: False)
  • sampler (torch.utils.data.Sampler, optional) – defines the strategy to draw samples from the dataset. If specified, shuffle must be False.
  • batch_sampler (torch.utils.data.Sampler, optional) – like sampler, but returns a batch of indices at a time. Mutually exclusive with batch_size, shuffle, sampler, and drop_last.
  • collate_fn (callable, optional) – merges a list of samples to form a mini-batch.
  • drop_last (bool, optional) – set to True to drop the last incomplete batch, if the dataset size is not divisible by the batch size. If False and the size of dataset is not divisible by the batch size, then the last batch will be smaller. (default: False)
  • timeout (numeric, optional) – if positive, the timeout value for collecting a batch. Should always be non-negative. (default: 0)
  • device (torch.device, optional) – set the device to use. Note that only CUDA devices are supported for the moment.
  • multibuffering (int, optional) – set the size of the multibuffering buffer. (default: 3)
  • seed (int, optional) – set the seed for the random transformations.
  • bias_transform (benzina.torch.operations.BiasTransform or float, optional) – set the bias transformation. Values to substract a pixel’s channels with. Note that this transformation is applied before norm_transform.
  • norm_transform (benzina.torch.operations.NormTransform or float or iterable of float, optional) – set the normalization transformation. Values to multiply a pixel’s channels with. Note that this transformation is applied after bias_transform.
  • warp_transform (benzina.torch.operations.WarpTransform or iterable of float, optional) – set the warp transformation or use as the arguments to initialize a WarpTransform.