Diffusers documentation
Coming from DiffusionPipeline
Get started
Inference
Using diffusion pipelines
Adapters and personalization
Optimize and scale
Basic performance
Inference
Community methods
Quantization
Hardware-specific acceleration
Serving and scaling
Modular Diffusers
OverviewQuickstartComing from DiffusionPipelineStatesModularPipelineBlocksSequentialPipelineBlocksLoopSequentialPipelineBlocksAutoPipelineBlocksModularPipelineGuidersComponentsManagerAuto docstring and parameter templatesBuilding Custom BlocksUsing Custom Blocks with Mellon
Train and fine-tune
Resources
Contribute
API
You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v0.41.0).
Coming from DiffusionPipeline
If you are familiar with DiffusionPipeline and are working with a ModularPipeline for the first time, a few things work differently. They are listed here so that you have them in mind before you go through the quickstart.
- Loading is lazy and flexible. from_pretrained() builds the pipeline from the repository’s
modular_model_index.jsonwithout loading any weights. load_components() then loads them, and it doesn’t have to be all at once: by default it loads everything, but you can load only the components you name withnames, or the set one workflow needs withworkflow. update_components() lets you reuse a component you already have, or one that differs from the repository’s spec. See Loading components and Updating components. - ModularPipeline reads a different index,
modular_model_index.json, but it also works with a repository that only has amodel_index.json, as long as the model has a modular pipeline. The reverse is not true: DiffusionPipeline and theAutoPipelineclasses don’t work with a repository that only has amodular_model_index.json. - A call returns the pipeline state, which holds the intermediate values too (
prompt_embeds,latents, …). Ask for what you need with theoutputargument,output="images"oroutput=["images", "latents"], or read an attribute of the state, as in the quickstart. See States. - Classifier-free guidance is supported in the
guidercomponent, not aguidance_scalecall argument:pipe.update_components(guider=ClassifierFreeGuidance(guidance_scale=5.0)). See the guiders guide. - There is no
callback_on_step_end; however, you can insert a block into the denoising loop to use your existing callback functions. See Modular pipelines in the callbacks guide. - The pipeline is a graph of blocks that you can change (pop, insert, replace) before building it with init_pipeline();
pipe.blocksreturns a copy, so edit the blocks first. See Compose new workflows. - Offloading is handled by a ComponentsManager, which can serve several pipelines that share components. See the ComponentsManager guide.