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
Transformers-like library for the diffusion model
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.
Scheduler
Models
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
Usage example