base_diffusion_model ==================== .. py:module:: base_diffusion_model Module Contents --------------- .. py:class:: BaseDiffusionModel(diffuser) Initializes the object with the specified diffuser. BaseDiffusionModel is an abstract base class for different diffusion models implementations. It defines the interface that all diffusion models should adhere to. :param diffuser: The diffuser to use for the diffusion model. .. warning:: Do not instantiate this class directly. Instead, build your own diffusion model by inheriting from BaseDiffusionModel. (see :class:`~.SimpleUnet.SimpleUnet`) .. py:attribute:: diffuser :type: diffusion_models.gaussian_diffusion.base_diffuser.BaseDiffuser A diffuser to be used by the diffusion model. .. py:method:: diffuse(images) Diffuse a batch of images. :param images: 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. .. py:method:: denoise(images) Denoise a batch of images. :param images: A tensor containing a batch of images to denoise. :returns: A list of tensors containing a batch of denoised images. .. py:method:: forward(x, timestep) :abstractmethod: Forward pass of the diffusion model. The forward pass of the diffusion model, predicting the noise at a single step. :param x: A batch of noisy images. :param timestep: The timesteps of each image in the batch. :returns: A tensor representing the noise predicted for each image. .. py:method:: to(device = 'cpu') Moves the model to the specified device. This performs a similar behaviour to the `to` method of PyTorch. moving the DiffusionModel and all related artifacts to the specified device. :param device: The device to which the method should move the object. Default is "cpu". .. py:method:: compile(*args, **kwargs) Compiles the diffusion model. This performs a similar behaviour to the `compile` method of PyTorch. :returns: A compiled diffusion model.