Community pipelines
Community pipelines
For more information about community pipelines, please have a look at this issue.
Community examples consist of both inference and training examples that have been added by the community. Please have a look at the following table to get an overview of all community examples. Click on the Code Example to get a copy-and-paste ready code example that you can try out. If a community doesnβt work as expected, please open an issue and ping the author on it.
CLIP Guided Stable Diffusion
Doing CLIP guidance for text to image generation with Stable Diffusion
One Step U-Net (Dummy)
Example showcasing of how to use Community Pipelines (see https://github.com/huggingface/diffusers/issues/841)
-
Stable Diffusion Interpolation
Interpolate the latent space of Stable Diffusion between different prompts/seeds
-
Stable Diffusion Mega
One Stable Diffusion Pipeline with all functionalities of Text2Image, Image2Image and Inpainting
-
Long Prompt Weighting Stable Diffusion
One Stable Diffusion Pipeline without tokens length limit, and support parsing weighting in prompt.
-
Speech to Image
Using automatic-speech-recognition to transcribe text and Stable Diffusion to generate images
-
To load a custom pipeline you just need to pass the custom_pipeline argument to DiffusionPipeline, as one of the files in diffusers/examples/community. Feel free to send a PR with your own pipelines, we will merge them quickly.
Copied
pipe = DiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4", custom_pipeline="filename_in_the_community_folder", use_safetensors=True
)Example usages
CLIP Guided Stable Diffusion
CLIP guided stable diffusion can help to generate more realistic images by guiding stable diffusion at every denoising step with an additional CLIP model.
The following code requires roughly 12GB of GPU RAM.
Copied
The images list contains a list of PIL images that can be saved locally or displayed directly in a google colab. Generated images tend to be of higher qualtiy than natively using stable diffusion. E.g. the above script generates the following images:
.

One Step Unet
The dummy βone-step-unetβ can be run as follows:
Copied
Note: This community pipeline is not useful as a feature, but rather just serves as an example of how community pipelines can be added (see https://github.com/huggingface/diffusers/issues/841).
Stable Diffusion Interpolation
The following code can be run on a GPU of at least 8GB VRAM and should take approximately 5 minutes.
Copied
The output of the walk(...) function returns a list of images saved under the folder as defined in output_dir. You can use these images to create videos of stable diffusion.
Please have a look at https://github.com/nateraw/stable-diffusion-videos for more in-detail information on how to create videos using stable diffusion as well as more feature-complete functionality.
Stable Diffusion Mega
The Stable Diffusion Mega Pipeline lets you use the main use cases of the stable diffusion pipeline in a single class.
Copied
As shown above this one pipeline can run all both βtext-to-imageβ, βimage-to-imageβ, and βinpaintingβ in one pipeline.
Long Prompt Weighting Stable Diffusion
The Pipeline lets you input prompt without 77 token length limit. And you can increase words weighting by using β()β or decrease words weighting by using β[]β The Pipeline also lets you use the main use cases of the stable diffusion pipeline in a single class.
pytorch
Copied
onnxruntime
Copied
if you see Token indices sequence length is longer than the specified maximum sequence length for this model ( *** > 77 ) . Running this sequence through the model will result in indexing errors. Do not worry, it is normal.
Speech to Image
The following code can generate an image from an audio sample using pre-trained OpenAI whisper-small and Stable Diffusion.
Copied
This example produces the following image:

Last updated