Back to glossary

Term

Diffusers

Diffusers is an open-source Python library by Hugging Face for using and training diffusion models for image, video and audio generation. It is built on PyTorch and is structured into pipelines, models and schedulers.

Diffusers — explained in detail

Diffusers (officially 🤗 Diffusers) is an open-source Python library by Hugging Face for diffusion models — a class of generative models that create content by gradually removing noise from a random signal. The library bundles pretrained models and tools to generate images, video and audio from them, and also supports training your own diffusion models.

Diffusers is built on PyTorch and is deliberately modular. The goal is usability: a ready pipeline can be run in a few lines of code, while the individual building blocks can be swapped and customised when needed.

The three core building blocks

  • Pipelines: Preconfigured end-to-end workflows (e.g. text-to-image) that encapsulate all required components. Via the central DiffusionPipeline you load a model and generate results directly.
  • Models: The individual neural building blocks — such as UNets or diffusion transformers (DiTs), text encoders and variational autoencoders (VAEs).
  • Schedulers: Interchangeable algorithms that control the step-by-step denoising process and thereby determine the trade-off between speed and output quality.

This separation lets you combine the same models with different schedulers or assemble your own pipelines.

Context

Within the Hugging Face ecosystem, Diffusers is the counterpart to the Transformers library: while Transformers mainly provides language and sequence models, Diffusers specialises in diffusion models for generative media. Models (e.g. Stable Diffusion variants) are usually obtained from the Hugging Face Hub, often in the safetensors format.

Example / Practical use

For text-to-image generation you typically load a pretrained pipeline (e.g. a Stable Diffusion model) via DiffusionPipeline.from_pretrained(...), pass a text prompt and get a generated image back. To specialise a model on a particular style, you can fine-tune it through Diffusers — often efficiently via LoRA. This lets generative image creation be embedded in both research and production applications.

  • Diffusers vs. diffusion model: A diffusion model is the general model type; Diffusers is a concrete software library for using and training such models.
  • Diffusers vs. Transformers: Both are Hugging Face libraries. Transformers focuses on language/sequence models, Diffusers on diffusion models for image/video/audio.
  • Diffusers vs. Stable Diffusion: Stable Diffusion is one specific diffusion model; Diffusers is one of the tools that can run Stable Diffusion (and many other models).
  • Diffusers vs. Hugging Face Hub: The Hub is the platform from which models are obtained; Diffusers is the code that makes them runnable locally.

Related terms: Hugging Face, Transformers, safetensors, LoRA.

Entdecke mehr

Themenuebersicht