Shortcuts

GrowScaleImgDataset

class mmedit.datasets.GrowScaleImgDataset(data_roots: dict, pipeline, len_per_stage=1000000, gpu_samples_per_scale=None, gpu_samples_base=32, io_backend: Optional[str] = None, file_lists: Optional[Union[str, dict]] = None, test_mode=False)[source]

Grow Scale Unconditional Image Dataset.

This dataset is similar with UnconditionalImageDataset, but offer more dynamic functionalities for the supporting complex algorithms, like PGGAN.

Highlight functionalities:

  1. Support growing scale dataset. The motivation is to decrease data pre-processing load in CPU. In this dataset, you can provide imgs_roots like:

    {'64': 'path_to_64x64_imgs',
     '512': 'path_to_512x512_imgs'}
    

    Then, in training scales lower than 64x64, this dataset will set self.imgs_root as ‘path_to_64x64_imgs’;

  2. Offer samples_per_gpu according to different scales. In this dataset, self.samples_per_gpu will help runner to know the updated batch size.

Basically, This dataset contains raw images for training unconditional GANs. Given a root dir, we will recursively find all images in this root. The transformation on data is defined by the pipeline.

Parameters
  • imgs_root (str) – Root path for unconditional images.

  • pipeline (list[dict | callable]) – A sequence of data transforms.

  • len_per_stage (int, optional) – The length of dataset for each scale. This args change the length dataset by concatenating or extracting subset. If given a value less than 0., the original length will be kept. Defaults to 1e6.

  • gpu_samples_per_scale (dict | None, optional) – Dict contains samples_per_gpu for each scale. For example, {'32': 4} will set the scale of 32 with samples_per_gpu=4, despite other scale with samples_per_gpu=self.gpu_samples_base.

  • gpu_samples_base (int, optional) – Set default samples_per_gpu for each scale. Defaults to 32.

  • io_backend (str, optional) – The storage backend type. Options are “disk”, “ceph”, “memcached”, “lmdb”, “http” and “petrel”. Default: None.

  • test_mode (bool, optional) – If True, the dataset will work in test mode. Otherwise, in train mode. Default to False.

concat_imgs_list_to(num)[source]

Concat image list to specified length.

Parameters

num (int) – The length of the concatenated image list.

load_data_list()[source]

Load annotations.

prepare_test_data(idx)[source]

Prepare testing data.

Parameters

idx (int) – Index of current batch.

Returns

Prepared training data batch.

Return type

dict

prepare_train_data(idx)[source]

Prepare training data.

Parameters

idx (int) – Index of current batch.

Returns

Prepared training data batch.

Return type

dict

update_annotations(curr_scale)[source]

Update annotations.

Parameters

curr_scale (int) – Current image scale.

Returns

Whether to update.

Return type

bool

Read the Docs v: zyh/doc-notfound-extend
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.