diffusion_models.gaussian_diffusion.ddimm_diffuser ================================================== .. py:module:: diffusion_models.gaussian_diffusion.ddimm_diffuser Module Contents --------------- .. py:class:: DenoisingMode Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: Linear :value: 'linear' .. py:attribute:: Quadratic :value: 'quadratic' .. py:class:: DdimDiffuser(beta_scheduler, mode = DenoisingMode.Quadratic, number_of_steps = 20) Initializes the class instance. :param beta_scheduler: The beta scheduler instance to be used. :type beta_scheduler: BaseBetaScheduler .. py:attribute:: number_of_steps Number of steps to use in the denoising process. .. py:attribute:: mode Linear or Quadratic sampling. .. py:attribute:: device :type: str :value: 'cpu' The device to use. Defaults to cpu. .. py:property:: steps :type: List[int] Returns the list of steps used in the denoising process. .. py:method:: get_timestep(number_of_images, idx) Get timestep information used for denoising. .. py:method:: from_checkpoint(checkpoint) :classmethod: Instantiate a DDIM Diffuser from a training checkpoint. :param checkpoint: The training checkpoint object containing the trained model's parameters and configuration. :returns: An instance of the DdimDiffuser class initialized with the parameters loaded from the given checkpoint. .. py:method:: to(device = 'cpu') Moves the data to the specified device. This performs a similar behaviour to the `to` method of PyTorch. moving the GaussianDiffuser and the BetaScheduler to the specified device. :param device: The device to which the method should move the object. Default is "cpu". .. rubric:: Example >>> ddim_diffuser = DdimDiffuser() >>> ddim_diffuser = ddim_diffuser.to(device="cuda") .. py:method:: diffuse_batch(images) Diffuse a batch of images. Diffuse the given batch of images by adding noise based on the beta scheduler. :param images: Batch of images to diffuse. Shape should be ``(B, C, H, W)``. :returns: A tuple containing three tensors - images: Diffused batch of images. - noise: Noise added to the images. - timesteps: Timesteps used for diffusion. .. py:method:: denoise_batch(images, model) Denoise a batch of images. This denoises a batch images. This is the image generation process. :param images: A batch of noisy images. :param model: The model to be used for denoising. :returns: A list of tensors containing a batch of denoised images.