Shortcuts

mmagic.datasets.singan_dataset

Module Contents

Classes

SinGANDataset

SinGAN Dataset.

Functions

create_real_pyramid(real, min_size, max_size, ...)

Create image pyramid.

mmagic.datasets.singan_dataset.create_real_pyramid(real, min_size, max_size, scale_factor_init)[source]

Create image pyramid.

This function is modified from the official implementation: https://github.com/tamarott/SinGAN/blob/master/SinGAN/functions.py#L221

In this implementation, we adopt the rescaling function from MMCV. :param real: The real image array. :type real: np.array :param min_size: The minimum size for the image pyramid. :type min_size: int :param max_size: The maximum size for the image pyramid. :type max_size: int :param scale_factor_init: The initial scale factor. :type scale_factor_init: float

class mmagic.datasets.singan_dataset.SinGANDataset(data_root, min_size, max_size, scale_factor_init, pipeline, num_samples=- 1)[source]

Bases: mmengine.dataset.BaseDataset

SinGAN Dataset.

In this dataset, we create an image pyramid and save it in the cache.

Parameters
  • img_path (str) – Path to the single image file.

  • min_size (int) – Min size of the image pyramid. Here, the number will be set to the min(H, W).

  • max_size (int) – Max size of the image pyramid. Here, the number will be set to the max(H, W).

  • scale_factor_init (float) – Rescale factor. Note that the actual factor we use may be a little bit different from this value.

  • num_samples (int, optional) – The number of samples (length) in this dataset. Defaults to -1.

full_init()[source]

Skip the full init process for SinGANDataset.

load_data_list(min_size, max_size, scale_factor_init)[source]

Load annotations for SinGAN Dataset.

Parameters
  • min_size (int) – The minimum size for the image pyramid.

  • max_size (int) – The maximum size for the image pyramid.

  • scale_factor_init (float) – The initial scale factor.

__getitem__(index)[source]

Get :attr:self.data_dict. For SinGAN, we use single image with different resolution to train the model.

Parameters

idx (int) – This will be ignored in SinGANDataset.

Returns

Dict contains input image in different resolution. self.pipeline.

Return type

dict

__len__()[source]

Get the length of filtered dataset and automatically call full_init if the dataset has not been fully init.

Returns

The length of filtered dataset.

Return type

int

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.