diffusion_models.gaussian_diffusion.base_diffuser

Module Contents

class BaseDiffuser(beta_scheduler)[source]

Initializes the object with the specified beta scheduler.

BaseDiffuser is an abstract base class for different diffuser implementations. It defines the interface that all diffusers should adhere to.

Parameters:

beta_scheduler (BaseBetaScheduler) – The beta scheduler used by the diffuser.

Warning

Do not instantiate this class directly. Instead, build your own Diffuser by inheriting from BaseDiffuser. (see GaussianDiffuser)

beta_scheduler: BaseBetaScheduler[source]

The beta scheduler used by the diffuser.

property steps: List[int][source]
Abstractmethod:

Returns the list of steps used in the denoising process.

abstract get_timestep(number_of_images, idx)[source]

Get timestep information used for denoising.

abstract diffuse_batch(images)[source]

Diffuse a batch of images.

Parameters:

images (Tensor) – A tensor containing a batch of images.

Returns:

A tuple containing three tensors

  • images: Diffused batch of images.

  • noise: Noise added to the images.

  • timesteps: Timesteps used for diffusion.

Return type:

Tuple[Tensor, Tensor, Tensor]

abstract denoise_batch(images, model)[source]

Denoise a batch of images.

Parameters:
  • images (Tensor) – A tensor containing a batch of images to denoise.

  • model (BaseDiffusionModel) – The model to be used for denoising.

Returns:

A list of tensors containing a batch of denoised images.

Return type:

List[Tensor]

abstract to(device='cpu')[source]

Moves the data to the specified device.

This performs a similar behaviour to the to method of PyTorch.

Parameters:

device (str) – The device to which the method should move the data. It should be a string indicating the desired device. Default is “cpu”.