modelzoo.vision.pytorch.dit.input.scripts.create_imagenet_latents.LatentImageNetProcessor#

class modelzoo.vision.pytorch.dit.input.scripts.create_imagenet_latents.LatentImageNetProcessor[source]#

Bases: object

Methods

cleanup_dist

create_dataloader

Build ImageNet Dataloader :param split: The dataset split, can be one of train or val :type split: str

get_latest_latent_checkpoint

Get the latest saved log checkpoint :param log_path: Path to log dir :type log_path: str

get_resume_data

Get data from log ckpt to resume data generation process :param latent_ckpt_path: Path to log ckpt :type latent_ckpt_path: str

run

MAIN function

save_latent_tensors

Save the output latent tensors from VAE encoder to npz file :param vae_output: Concatenation of mean and logvar outputs from VAE corresponding to images at src_paths, shape=(2 * latent_size, latent_height, latent_width) :type vae_output: torch.Tensor :param label: Target label of image :type label: torch.Tensor :param src_paths List[str]: Path of image

save_logs

Save data generation log checkpoints to resume process later if needed. :param log_path: Path to save log ckpt used for data generation resume :type log_path: str :param global_rank: GPU global rank :type global_rank: int :param iter_num: Current iteration of dataloader on GPU with rank = global_rank :type iter_num: int :param total_num_batches: Total number of batches processed so far across all GPUs during the current data generation process :type total_num_batches: int.

set_data_transforms

Data transforms used for dataset creation :param horizontal_flip: If True, flip the image horizontally :type horizontal_flip: bool :param image_height: Height of resized image :type image_height: int :param image_width: Width of resized image :type image_width: int

setup_dist

__init__(args)[source]#
create_dataloader(split)[source]#

Build ImageNet Dataloader :param split: The dataset split, can be one of train or val :type split: str

Returns

torch.utils.data.Dataloader object that reads from ImageNet dataset

Return type

dataloader

get_latest_latent_checkpoint(log_path)[source]#

Get the latest saved log checkpoint :param log_path: Path to log dir :type log_path: str

Returns

Path to the last saved log ckpt

Return type

latest_filepath (str)

get_resume_data(latent_ckpt_path)[source]#

Get data from log ckpt to resume data generation process :param latent_ckpt_path: Path to log ckpt :type latent_ckpt_path: str

Returns

Index of sample to restart process resume_batches (int): Number of batches processed previously

Return type

resume_index (int)

run()[source]#

MAIN function

save_latent_tensors(vae_output, label, src_paths)[source]#

Save the output latent tensors from VAE encoder to npz file :param vae_output: Concatenation of mean and logvar outputs from VAE

corresponding to images at src_paths, shape=(2 * latent_size, latent_height, latent_width)

Parameters
  • label (torch.Tensor) – Target label of image

  • List[str] (src_paths) – Path of image

save_logs(log_path, global_rank, iter_num, total_num_batches)[source]#

Save data generation log checkpoints to resume process later if needed. :param log_path: Path to save log ckpt used for data generation resume :type log_path: str :param global_rank: GPU global rank :type global_rank: int :param iter_num: Current iteration of dataloader on GPU with rank = global_rank :type iter_num: int :param total_num_batches: Total number of batches processed so far across all GPUs

during the current data generation process

set_data_transforms(horizontal_flip, image_height, image_width)[source]#

Data transforms used for dataset creation :param horizontal_flip: If True, flip the image horizontally :type horizontal_flip: bool :param image_height: Height of resized image :type image_height: int :param image_width: Width of resized image :type image_width: int

Returns

torchvision.transforms composition to be applied to image target_transform : torchvision.transforms composition to be applied to target label

Return type

transform