AutoPipeline (original) (raw)

The AutoPipeline is designed to make it easy to load a checkpoint for a task without needing to know the specific pipeline class. Based on the task, the AutoPipeline automatically retrieves the correct pipeline class from the checkpoint model_index.json file.

Check out the AutoPipeline tutorial to learn how to use this API!

AutoPipelineForText2Image

class diffusers.AutoPipelineForText2Image

< source >

( *args **kwargs )

AutoPipelineForText2Image is a generic pipeline class that instantiates a text-to-image pipeline class. The specific underlying pipeline class is automatically selected from either thefrom_pretrained() or from_pipe() methods.

This class cannot be instantiated using __init__() (throws an error).

Class attributes:

from_pretrained

< source >

( pretrained_model_or_path **kwargs )

Parameters

Instantiates a text-to-image Pytorch diffusion pipeline from pretrained pipeline weight.

The from_pretrained() method takes care of returning the correct pipeline class instance by:

  1. Detect the pipeline class of the pretrained_model_or_path based on the _class_name property of its config object
  2. Find the text-to-image pipeline linked to the pipeline class using pattern matching on pipeline class name.

If a controlnet argument is passed, it will instantiate a StableDiffusionControlNetPipeline object.

The pipeline is set in evaluation mode (model.eval()) by default.

If you get the error message below, you need to finetune the weights for your downstream task:

Some weights of UNet2DConditionModel were not initialized from the model checkpoint at stable-diffusion-v1-5/stable-diffusion-v1-5 and are newly initialized because the shapes did not match:

To use private or gated models, log-in withhuggingface-cli login.

Examples:

from diffusers import AutoPipelineForText2Image

pipeline = AutoPipelineForText2Image.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5") image = pipeline(prompt).images[0]

from_pipe

< source >

( pipeline **kwargs )

Parameters

Instantiates a text-to-image Pytorch diffusion pipeline from another instantiated diffusion pipeline class.

The from_pipe() method takes care of returning the correct pipeline class instance by finding the text-to-image pipeline linked to the pipeline class using pattern matching on pipeline class name.

All the modules the pipeline contains will be used to initialize the new pipeline without reallocating additional memory.

The pipeline is set in evaluation mode (model.eval()) by default.

from diffusers import AutoPipelineForText2Image, AutoPipelineForImage2Image

pipe_i2i = AutoPipelineForImage2Image.from_pretrained( ... "stable-diffusion-v1-5/stable-diffusion-v1-5", requires_safety_checker=False ... )

pipe_t2i = AutoPipelineForText2Image.from_pipe(pipe_i2i) image = pipe_t2i(prompt).images[0]

AutoPipelineForImage2Image

class diffusers.AutoPipelineForImage2Image

< source >

( *args **kwargs )

AutoPipelineForImage2Image is a generic pipeline class that instantiates an image-to-image pipeline class. The specific underlying pipeline class is automatically selected from either thefrom_pretrained() or from_pipe() methods.

This class cannot be instantiated using __init__() (throws an error).

Class attributes:

from_pretrained

< source >

( pretrained_model_or_path **kwargs )

Parameters

Instantiates a image-to-image Pytorch diffusion pipeline from pretrained pipeline weight.

The from_pretrained() method takes care of returning the correct pipeline class instance by:

  1. Detect the pipeline class of the pretrained_model_or_path based on the _class_name property of its config object
  2. Find the image-to-image pipeline linked to the pipeline class using pattern matching on pipeline class name.

If a controlnet argument is passed, it will instantiate a StableDiffusionControlNetImg2ImgPipelineobject.

The pipeline is set in evaluation mode (model.eval()) by default.

If you get the error message below, you need to finetune the weights for your downstream task:

Some weights of UNet2DConditionModel were not initialized from the model checkpoint at stable-diffusion-v1-5/stable-diffusion-v1-5 and are newly initialized because the shapes did not match:

To use private or gated models, log-in withhuggingface-cli login.

Examples:

from diffusers import AutoPipelineForImage2Image

pipeline = AutoPipelineForImage2Image.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5") image = pipeline(prompt, image).images[0]

from_pipe

< source >

( pipeline **kwargs )

Parameters

Instantiates a image-to-image Pytorch diffusion pipeline from another instantiated diffusion pipeline class.

The from_pipe() method takes care of returning the correct pipeline class instance by finding the image-to-image pipeline linked to the pipeline class using pattern matching on pipeline class name.

All the modules the pipeline contains will be used to initialize the new pipeline without reallocating additional memory.

The pipeline is set in evaluation mode (model.eval()) by default.

Examples:

from diffusers import AutoPipelineForText2Image, AutoPipelineForImage2Image

pipe_t2i = AutoPipelineForText2Image.from_pretrained( ... "stable-diffusion-v1-5/stable-diffusion-v1-5", requires_safety_checker=False ... )

pipe_i2i = AutoPipelineForImage2Image.from_pipe(pipe_t2i) image = pipe_i2i(prompt, image).images[0]

AutoPipelineForInpainting

class diffusers.AutoPipelineForInpainting

< source >

( *args **kwargs )

AutoPipelineForInpainting is a generic pipeline class that instantiates an inpainting pipeline class. The specific underlying pipeline class is automatically selected from either thefrom_pretrained() or from_pipe() methods.

This class cannot be instantiated using __init__() (throws an error).

Class attributes:

from_pretrained

< source >

( pretrained_model_or_path **kwargs )

Parameters

Instantiates a inpainting Pytorch diffusion pipeline from pretrained pipeline weight.

The from_pretrained() method takes care of returning the correct pipeline class instance by:

  1. Detect the pipeline class of the pretrained_model_or_path based on the _class_name property of its config object
  2. Find the inpainting pipeline linked to the pipeline class using pattern matching on pipeline class name.

If a controlnet argument is passed, it will instantiate a StableDiffusionControlNetInpaintPipelineobject.

The pipeline is set in evaluation mode (model.eval()) by default.

If you get the error message below, you need to finetune the weights for your downstream task:

Some weights of UNet2DConditionModel were not initialized from the model checkpoint at stable-diffusion-v1-5/stable-diffusion-v1-5 and are newly initialized because the shapes did not match:

To use private or gated models, log-in withhuggingface-cli login.

Examples:

from diffusers import AutoPipelineForInpainting

pipeline = AutoPipelineForInpainting.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5") image = pipeline(prompt, image=init_image, mask_image=mask_image).images[0]

from_pipe

< source >

( pipeline **kwargs )

Parameters

Instantiates a inpainting Pytorch diffusion pipeline from another instantiated diffusion pipeline class.

The from_pipe() method takes care of returning the correct pipeline class instance by finding the inpainting pipeline linked to the pipeline class using pattern matching on pipeline class name.

All the modules the pipeline class contain will be used to initialize the new pipeline without reallocating additional memory.

The pipeline is set in evaluation mode (model.eval()) by default.

Examples:

from diffusers import AutoPipelineForText2Image, AutoPipelineForInpainting

pipe_t2i = AutoPipelineForText2Image.from_pretrained( ... "DeepFloyd/IF-I-XL-v1.0", requires_safety_checker=False ... )

pipe_inpaint = AutoPipelineForInpainting.from_pipe(pipe_t2i) image = pipe_inpaint(prompt, image=init_image, mask_image=mask_image).images[0]

< > Update on GitHub