Skip to content

Data Handler

class DataHandler

DataHandler generate augmented batches used for training or validation.

  • lr_dir: directory containing the Low Res images.

  • hr_dir: directory containing the High Res images.

  • patch_size: integer, size of the patches extracted from LR images.

  • scale: integer, upscaling factor.

  • n_validation_samples: integer, size of the validation set. Only provided if the DataHandler is used to generate validation sets.


def __init__(lr_dir, hr_dir, patch_size, scale, n_validation_samples)


def get_batch(batch_size, idx, flatness)

Returns a dictionary with keys ('lr', 'hr') containing training batches of Low Res and High Res image patches.

  • batch_size: integer.

  • flatness: float in [0,1], is the patch "flatness" threshold. Determines what level of detail the patches need to meet. 0 means any patch is accepted.


def get_validation_batches(batch_size)

Returns a batch for each image in the validation set.


def get_validation_set(batch_size)

Returns a batch for each image in the validation set. Flattens and splits them to feed it to Keras's model.evaluate.