Buckets:
| # AutoPipeline | |
| 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. | |
| > [!TIP] | |
| > Check out the [AutoPipeline](../../tutorials/autopipeline) tutorial to learn how to use this API! | |
| ## AutoPipelineForText2Image[[diffusers.AutoPipelineForText2Image]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class diffusers.AutoPipelineForText2Image</name><anchor>diffusers.AutoPipelineForText2Image</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L289</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| [AutoPipelineForText2Image](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image) is a generic pipeline class that instantiates a text-to-image pipeline class. The | |
| specific underlying pipeline class is automatically selected from either the | |
| [from_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image.from_pretrained) or [from_pipe()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForText2Image.from_pipe) methods. | |
| This class cannot be instantiated using `__init__()` (throws an error). | |
| Class attributes: | |
| - **config_name** (`str`) -- The configuration filename that stores the class and module names of all the | |
| diffusion pipeline's components. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pretrained</name><anchor>diffusers.AutoPipelineForText2Image.from_pretrained</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L314</source><parameters>[{"name": "pretrained_model_or_path", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pretrained_model_or_path** (`str` or `os.PathLike`, *optional*) -- | |
| Can be either: | |
| - A string, the *repo id* (for example `CompVis/ldm-text2im-large-256`) of a pretrained pipeline | |
| hosted on the Hub. | |
| - A path to a *directory* (for example `./my_pipeline_directory/`) containing pipeline weights | |
| saved using | |
| [save_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/overview#diffusers.DiffusionPipeline.save_pretrained). | |
| - **torch_dtype** (`torch.dtype`, *optional*) -- | |
| Override the default `torch.dtype` and load the model with another dtype. | |
| - **force_download** (`bool`, *optional*, defaults to `False`) -- | |
| Whether or not to force the (re-)download of the model weights and configuration files, overriding the | |
| cached versions if they exist. | |
| - **cache_dir** (`Union[str, os.PathLike]`, *optional*) -- | |
| Path to a directory where a downloaded pretrained model configuration is cached if the standard cache | |
| is not used. | |
| - **proxies** (`Dict[str, str]`, *optional*) -- | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', | |
| 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. | |
| - **output_loading_info(`bool`,** *optional*, defaults to `False`) -- | |
| Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. | |
| - **local_files_only** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to only load local model weights and configuration files or not. If set to `True`, the model | |
| won't be downloaded from the Hub. | |
| - **token** (`str` or *bool*, *optional*) -- | |
| The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from | |
| `diffusers-cli login` (stored in `~/.huggingface`) is used. | |
| - **revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier | |
| allowed by Git. | |
| - **custom_revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, or a commit id similar to | |
| `revision` when loading a custom pipeline from the Hub. It can be a 🤗 Diffusers version when loading a | |
| custom pipeline from GitHub, otherwise it defaults to `"main"` when loading from the Hub. | |
| - **mirror** (`str`, *optional*) -- | |
| Mirror source to resolve accessibility issues if you’re downloading a model in China. We do not | |
| guarantee the timeliness or safety of the source, and you should refer to the mirror site for more | |
| information. | |
| - **device_map** (`str` or `Dict[str, Union[int, str, torch.device]]`, *optional*) -- | |
| A map that specifies where each submodule should go. It doesn’t need to be defined for each | |
| parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the | |
| same device. | |
| Set `device_map="auto"` to have 🤗 Accelerate automatically compute the most optimized `device_map`. For | |
| more information about each option see [designing a device | |
| map](https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map). | |
| - **max_memory** (`Dict`, *optional*) -- | |
| A dictionary device identifier for the maximum memory. Will default to the maximum memory available for | |
| each GPU and the available CPU RAM if unset. | |
| - **offload_folder** (`str` or `os.PathLike`, *optional*) -- | |
| The path to offload weights if device_map contains the value `"disk"`. | |
| - **offload_state_dict** (`bool`, *optional*) -- | |
| If `True`, temporarily offloads the CPU state dict to the hard drive to avoid running out of CPU RAM if | |
| the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to `True` | |
| when there is some disk offload. | |
| - **low_cpu_mem_usage** (`bool`, *optional*, defaults to `True` if torch version >= 1.9.0 else `False`) -- | |
| Speed up model loading only loading the pretrained weights and not initializing the weights. This also | |
| tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model. | |
| Only supported for PyTorch >= 1.9.0. If you are using an older version of PyTorch, setting this | |
| argument to `True` will raise an error. | |
| - **use_safetensors** (`bool`, *optional*, defaults to `None`) -- | |
| If set to `None`, the safetensors weights are downloaded if they're available **and** if the | |
| safetensors library is installed. If set to `True`, the model is forcibly loaded from safetensors | |
| weights. If set to `False`, safetensors weights are not loaded. | |
| - **kwargs** (remaining dictionary of keyword arguments, *optional*) -- | |
| Can be used to overwrite load and saveable variables (the pipeline components of the specific pipeline | |
| class). The overwritten components are passed directly to the pipelines `__init__` method. See example | |
| below for more information. | |
| - **variant** (`str`, *optional*) -- | |
| Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when | |
| loading `from_flax`.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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](/docs/diffusers/pr_12229/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline) object. | |
| The pipeline is set in evaluation mode (`model.eval()`) by default. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForText2Image.from_pretrained.example"> | |
| 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: | |
| - conv_in.weight: found shape torch.Size([320, 4, 3, 3]) in the checkpoint and torch.Size([320, 9, 3, 3]) in the model instantiated | |
| You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference. | |
| ``` | |
| </ExampleCodeBlock> | |
| > [!TIP] > To use private or [gated](https://huggingface.co/docs/hub/models-gated#gated-models) models, log-in | |
| with `hf > auth login`. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForText2Image.from_pretrained.example-2"> | |
| Examples: | |
| ```py | |
| >>> from diffusers import AutoPipelineForText2Image | |
| >>> pipeline = AutoPipelineForText2Image.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5") | |
| >>> image = pipeline(prompt).images[0] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pipe</name><anchor>diffusers.AutoPipelineForText2Image.from_pipe</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L462</source><parameters>[{"name": "pipeline", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pipeline** (`DiffusionPipeline`) -- | |
| an instantiated `DiffusionPipeline` object</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForText2Image.from_pipe.example"> | |
| ```py | |
| >>> 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] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div></div> | |
| ## AutoPipelineForImage2Image[[diffusers.AutoPipelineForImage2Image]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class diffusers.AutoPipelineForImage2Image</name><anchor>diffusers.AutoPipelineForImage2Image</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L579</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| [AutoPipelineForImage2Image](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image) is a generic pipeline class that instantiates an image-to-image pipeline class. The | |
| specific underlying pipeline class is automatically selected from either the | |
| [from_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pretrained) or [from_pipe()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pipe) methods. | |
| This class cannot be instantiated using `__init__()` (throws an error). | |
| Class attributes: | |
| - **config_name** (`str`) -- The configuration filename that stores the class and module names of all the | |
| diffusion pipeline's components. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pretrained</name><anchor>diffusers.AutoPipelineForImage2Image.from_pretrained</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L604</source><parameters>[{"name": "pretrained_model_or_path", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pretrained_model_or_path** (`str` or `os.PathLike`, *optional*) -- | |
| Can be either: | |
| - A string, the *repo id* (for example `CompVis/ldm-text2im-large-256`) of a pretrained pipeline | |
| hosted on the Hub. | |
| - A path to a *directory* (for example `./my_pipeline_directory/`) containing pipeline weights | |
| saved using | |
| [save_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/overview#diffusers.DiffusionPipeline.save_pretrained). | |
| - **torch_dtype** (`str` or `torch.dtype`, *optional*) -- | |
| Override the default `torch.dtype` and load the model with another dtype. | |
| - **force_download** (`bool`, *optional*, defaults to `False`) -- | |
| Whether or not to force the (re-)download of the model weights and configuration files, overriding the | |
| cached versions if they exist. | |
| - **cache_dir** (`Union[str, os.PathLike]`, *optional*) -- | |
| Path to a directory where a downloaded pretrained model configuration is cached if the standard cache | |
| is not used. | |
| - **proxies** (`Dict[str, str]`, *optional*) -- | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', | |
| 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. | |
| - **output_loading_info(`bool`,** *optional*, defaults to `False`) -- | |
| Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. | |
| - **local_files_only** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to only load local model weights and configuration files or not. If set to `True`, the model | |
| won't be downloaded from the Hub. | |
| - **token** (`str` or *bool*, *optional*) -- | |
| The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from | |
| `diffusers-cli login` (stored in `~/.huggingface`) is used. | |
| - **revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier | |
| allowed by Git. | |
| - **custom_revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, or a commit id similar to | |
| `revision` when loading a custom pipeline from the Hub. It can be a 🤗 Diffusers version when loading a | |
| custom pipeline from GitHub, otherwise it defaults to `"main"` when loading from the Hub. | |
| - **mirror** (`str`, *optional*) -- | |
| Mirror source to resolve accessibility issues if you’re downloading a model in China. We do not | |
| guarantee the timeliness or safety of the source, and you should refer to the mirror site for more | |
| information. | |
| - **device_map** (`str` or `Dict[str, Union[int, str, torch.device]]`, *optional*) -- | |
| A map that specifies where each submodule should go. It doesn’t need to be defined for each | |
| parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the | |
| same device. | |
| Set `device_map="auto"` to have 🤗 Accelerate automatically compute the most optimized `device_map`. For | |
| more information about each option see [designing a device | |
| map](https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map). | |
| - **max_memory** (`Dict`, *optional*) -- | |
| A dictionary device identifier for the maximum memory. Will default to the maximum memory available for | |
| each GPU and the available CPU RAM if unset. | |
| - **offload_folder** (`str` or `os.PathLike`, *optional*) -- | |
| The path to offload weights if device_map contains the value `"disk"`. | |
| - **offload_state_dict** (`bool`, *optional*) -- | |
| If `True`, temporarily offloads the CPU state dict to the hard drive to avoid running out of CPU RAM if | |
| the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to `True` | |
| when there is some disk offload. | |
| - **low_cpu_mem_usage** (`bool`, *optional*, defaults to `True` if torch version >= 1.9.0 else `False`) -- | |
| Speed up model loading only loading the pretrained weights and not initializing the weights. This also | |
| tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model. | |
| Only supported for PyTorch >= 1.9.0. If you are using an older version of PyTorch, setting this | |
| argument to `True` will raise an error. | |
| - **use_safetensors** (`bool`, *optional*, defaults to `None`) -- | |
| If set to `None`, the safetensors weights are downloaded if they're available **and** if the | |
| safetensors library is installed. If set to `True`, the model is forcibly loaded from safetensors | |
| weights. If set to `False`, safetensors weights are not loaded. | |
| - **kwargs** (remaining dictionary of keyword arguments, *optional*) -- | |
| Can be used to overwrite load and saveable variables (the pipeline components of the specific pipeline | |
| class). The overwritten components are passed directly to the pipelines `__init__` method. See example | |
| below for more information. | |
| - **variant** (`str`, *optional*) -- | |
| Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when | |
| loading `from_flax`.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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 [StableDiffusionControlNetImg2ImgPipeline](/docs/diffusers/pr_12229/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetImg2ImgPipeline) | |
| object. | |
| The pipeline is set in evaluation mode (`model.eval()`) by default. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForImage2Image.from_pretrained.example"> | |
| 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: | |
| - conv_in.weight: found shape torch.Size([320, 4, 3, 3]) in the checkpoint and torch.Size([320, 9, 3, 3]) in the model instantiated | |
| You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference. | |
| ``` | |
| </ExampleCodeBlock> | |
| > [!TIP] > To use private or [gated](https://huggingface.co/docs/hub/models-gated#gated-models) models, log-in | |
| with `hf > auth login`. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForImage2Image.from_pretrained.example-2"> | |
| Examples: | |
| ```py | |
| >>> from diffusers import AutoPipelineForImage2Image | |
| >>> pipeline = AutoPipelineForImage2Image.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5") | |
| >>> image = pipeline(prompt, image).images[0] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pipe</name><anchor>diffusers.AutoPipelineForImage2Image.from_pipe</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L763</source><parameters>[{"name": "pipeline", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pipeline** (`DiffusionPipeline`) -- | |
| an instantiated `DiffusionPipeline` object</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForImage2Image.from_pipe.example"> | |
| Examples: | |
| ```py | |
| >>> 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] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div></div> | |
| ## AutoPipelineForInpainting[[diffusers.AutoPipelineForInpainting]] | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>class diffusers.AutoPipelineForInpainting</name><anchor>diffusers.AutoPipelineForInpainting</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L886</source><parameters>[{"name": "*args", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters></docstring> | |
| [AutoPipelineForInpainting](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting) is a generic pipeline class that instantiates an inpainting pipeline class. The | |
| specific underlying pipeline class is automatically selected from either the | |
| [from_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting.from_pretrained) or [from_pipe()](/docs/diffusers/pr_12229/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting.from_pipe) methods. | |
| This class cannot be instantiated using `__init__()` (throws an error). | |
| Class attributes: | |
| - **config_name** (`str`) -- The configuration filename that stores the class and module names of all the | |
| diffusion pipeline's components. | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pretrained</name><anchor>diffusers.AutoPipelineForInpainting.from_pretrained</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L911</source><parameters>[{"name": "pretrained_model_or_path", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pretrained_model_or_path** (`str` or `os.PathLike`, *optional*) -- | |
| Can be either: | |
| - A string, the *repo id* (for example `CompVis/ldm-text2im-large-256`) of a pretrained pipeline | |
| hosted on the Hub. | |
| - A path to a *directory* (for example `./my_pipeline_directory/`) containing pipeline weights | |
| saved using | |
| [save_pretrained()](/docs/diffusers/pr_12229/en/api/pipelines/overview#diffusers.DiffusionPipeline.save_pretrained). | |
| - **torch_dtype** (`str` or `torch.dtype`, *optional*) -- | |
| Override the default `torch.dtype` and load the model with another dtype. | |
| - **force_download** (`bool`, *optional*, defaults to `False`) -- | |
| Whether or not to force the (re-)download of the model weights and configuration files, overriding the | |
| cached versions if they exist. | |
| - **cache_dir** (`Union[str, os.PathLike]`, *optional*) -- | |
| Path to a directory where a downloaded pretrained model configuration is cached if the standard cache | |
| is not used. | |
| - **proxies** (`Dict[str, str]`, *optional*) -- | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', | |
| 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. | |
| - **output_loading_info(`bool`,** *optional*, defaults to `False`) -- | |
| Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. | |
| - **local_files_only** (`bool`, *optional*, defaults to `False`) -- | |
| Whether to only load local model weights and configuration files or not. If set to `True`, the model | |
| won't be downloaded from the Hub. | |
| - **token** (`str` or *bool*, *optional*) -- | |
| The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from | |
| `diffusers-cli login` (stored in `~/.huggingface`) is used. | |
| - **revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier | |
| allowed by Git. | |
| - **custom_revision** (`str`, *optional*, defaults to `"main"`) -- | |
| The specific model version to use. It can be a branch name, a tag name, or a commit id similar to | |
| `revision` when loading a custom pipeline from the Hub. It can be a 🤗 Diffusers version when loading a | |
| custom pipeline from GitHub, otherwise it defaults to `"main"` when loading from the Hub. | |
| - **mirror** (`str`, *optional*) -- | |
| Mirror source to resolve accessibility issues if you’re downloading a model in China. We do not | |
| guarantee the timeliness or safety of the source, and you should refer to the mirror site for more | |
| information. | |
| - **device_map** (`str` or `Dict[str, Union[int, str, torch.device]]`, *optional*) -- | |
| A map that specifies where each submodule should go. It doesn’t need to be defined for each | |
| parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the | |
| same device. | |
| Set `device_map="auto"` to have 🤗 Accelerate automatically compute the most optimized `device_map`. For | |
| more information about each option see [designing a device | |
| map](https://hf.co/docs/accelerate/main/en/usage_guides/big_modeling#designing-a-device-map). | |
| - **max_memory** (`Dict`, *optional*) -- | |
| A dictionary device identifier for the maximum memory. Will default to the maximum memory available for | |
| each GPU and the available CPU RAM if unset. | |
| - **offload_folder** (`str` or `os.PathLike`, *optional*) -- | |
| The path to offload weights if device_map contains the value `"disk"`. | |
| - **offload_state_dict** (`bool`, *optional*) -- | |
| If `True`, temporarily offloads the CPU state dict to the hard drive to avoid running out of CPU RAM if | |
| the weight of the CPU state dict + the biggest shard of the checkpoint does not fit. Defaults to `True` | |
| when there is some disk offload. | |
| - **low_cpu_mem_usage** (`bool`, *optional*, defaults to `True` if torch version >= 1.9.0 else `False`) -- | |
| Speed up model loading only loading the pretrained weights and not initializing the weights. This also | |
| tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model. | |
| Only supported for PyTorch >= 1.9.0. If you are using an older version of PyTorch, setting this | |
| argument to `True` will raise an error. | |
| - **use_safetensors** (`bool`, *optional*, defaults to `None`) -- | |
| If set to `None`, the safetensors weights are downloaded if they're available **and** if the | |
| safetensors library is installed. If set to `True`, the model is forcibly loaded from safetensors | |
| weights. If set to `False`, safetensors weights are not loaded. | |
| - **kwargs** (remaining dictionary of keyword arguments, *optional*) -- | |
| Can be used to overwrite load and saveable variables (the pipeline components of the specific pipeline | |
| class). The overwritten components are passed directly to the pipelines `__init__` method. See example | |
| below for more information. | |
| - **variant** (`str`, *optional*) -- | |
| Load weights from a specified variant filename such as `"fp16"` or `"ema"`. This is ignored when | |
| loading `from_flax`.</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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 [StableDiffusionControlNetInpaintPipeline](/docs/diffusers/pr_12229/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetInpaintPipeline) | |
| object. | |
| The pipeline is set in evaluation mode (`model.eval()`) by default. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForInpainting.from_pretrained.example"> | |
| 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: | |
| - conv_in.weight: found shape torch.Size([320, 4, 3, 3]) in the checkpoint and torch.Size([320, 9, 3, 3]) in the model instantiated | |
| You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference. | |
| ``` | |
| </ExampleCodeBlock> | |
| > [!TIP] > To use private or [gated](https://huggingface.co/docs/hub/models-gated#gated-models) models, log-in | |
| with `hf > auth login`. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForInpainting.from_pretrained.example-2"> | |
| Examples: | |
| ```py | |
| >>> 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] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div> | |
| <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"> | |
| <docstring><name>from_pipe</name><anchor>diffusers.AutoPipelineForInpainting.from_pipe</anchor><source>https://github.com/huggingface/diffusers/blob/vr_12229/src/diffusers/pipelines/auto_pipeline.py#L1067</source><parameters>[{"name": "pipeline", "val": ""}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **pipeline** (`DiffusionPipeline`) -- | |
| an instantiated `DiffusionPipeline` object</paramsdesc><paramgroups>0</paramgroups></docstring> | |
| 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. | |
| <ExampleCodeBlock anchor="diffusers.AutoPipelineForInpainting.from_pipe.example"> | |
| Examples: | |
| ```py | |
| >>> 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] | |
| ``` | |
| </ExampleCodeBlock> | |
| </div></div> | |
| <EditOnGithub source="https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/auto_pipeline.md" /> |
Xet Storage Details
- Size:
- 31.1 kB
- Xet hash:
- 972e46e2289671ae9bd143f4738efc2fecd6031d18cfcf5ef53c30839b26ef33
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.