In this blog, a simple diffusion model with a 2-layer Unet and a simple scheduler will be implemented to introduce the use of Diffusers

What is Diffusers


Transformers-like library for the diffusion model

Customize Components in Diffusers


We need to write wrapper classes to embed our modules into the Diffusers. Inherit from f“{Union[Scheduler | Model]}Mixin” and DiffusionPipeline and achieve basic APIs for Diffusers to run. Some comments are generated by AI.

  1. Scheduler

  2. Models

  3. Pipeline

    Strictly if the Scheduler and the Model are well prepared, just use Diffusers.DiffusionPipeline and pass the Scheduler and the Model as parameters(, as pipeline = cls(unet=unet_wrapped, scheduler=scheduler_wrapped)). But I still put an sample code here, in case I forget the usage one day

  4. Usage example