import{s as Qe,n as Ke,o as eo}from"../chunks/scheduler.53228c21.js";import{S as oo,i as to,e as d,s as n,c,h as no,a as l,d as t,b as s,f as w,g as m,j as g,k as x,l as r,m as i,n as p,t as f,o as u,p as _}from"../chunks/index.100fac89.js";import{C as so}from"../chunks/CopyLLMTxtMenu.999d3d86.js";import{D as ee}from"../chunks/Docstring.46d0934e.js";import{C as Pe}from"../chunks/CodeBlock.d30a6509.js";import{H as ne,E as io}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d27ae4df.js";function ro(Oe){let y,se,oe,ie,T,re,$,de,k,Le='The ControlNet model was introduced in <a href="https://huggingface.co/papers/2302.05543" rel="nofollow">Adding Conditional Control to Text-to-Image Diffusion Models</a> by Lvmin Zhang, Anyi Rao, Maneesh Agrawala. It provides a greater degree of control over text-to-image generation by conditioning the model on additional inputs such as edge maps, depth maps, segmentation maps, and keypoints for pose detection.',le,U,We="The abstract from the paper is:",ae,J,ze="<em>We present ControlNet, a neural network architecture to add spatial conditioning controls to large, pretrained text-to-image diffusion models. ControlNet locks the production-ready large diffusion models, and reuses their deep and robust encoding layers pretrained with billions of images as a strong backbone to learn a diverse set of conditional controls. The neural architecture is connected with “zero convolutions” (zero-initialized convolution layers) that progressively grow the parameters from zero and ensure that no harmful noise could affect the finetuning. We test various conditioning controls, eg, edges, depth, segmentation, human pose, etc, with Stable Diffusion, using single or multiple conditions, with or without prompts. We show that the training of ControlNets is robust with small (&lt;50k) and large (&gt;1m) datasets. Extensive results show that ControlNet may facilitate wider applications to control image diffusion models.</em>",ce,j,me,Z,Ie=`By default the <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a> should be loaded with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>, but it can also be loaded
from the original format using <code>FromOriginalModelMixin.from_single_file</code> as follows:`,pe,R,fe,D,ue,q,Ye='Control-LoRA is introduced by Stability AI in <a href="https://huggingface.co/stabilityai/control-lora" rel="nofollow">stabilityai/control-lora</a> by adding low-rank parameter efficient fine tuning to ControlNet. This approach offers a more efficient and compact method to bring model control to a wider variety of consumer GPUs.',_e,G,he,B,ge,a,O,$e,A,Ee="A ControlNet model.",ke,v,L,Ue,V,He='The <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a> forward method.',Je,M,W,je,F,Ae='Instantiate a <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a> from <a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>.',Ze,b,z,Re,S,Ve="Enable sliced attention computation.",De,X,Fe=`When this option is enabled, the attention module splits the input tensor in slices to compute attention in
several steps. This is useful for saving some memory in exchange for a small decrease in speed.`,qe,N,I,Ge,P,Se="Disables custom attention processors and sets the default attention implementation.",be,Y,ye,C,E,Be,Q,Xe='The output of <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a>.',Ce,H,ve,te,Me;return T=new so({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new ne({props:{title:"ControlNetModel",local:"controlnetmodel",headingTag:"h1"}}),j=new ne({props:{title:"Loading from the original format",local:"loading-from-the-original-format",headingTag:"h2"}}),R=new Pe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZSUyQyUyMENvbnRyb2xOZXRNb2RlbCUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZsbGx5YXN2aWVsJTJGQ29udHJvbE5ldC12MS0xJTJGYmxvYiUyRm1haW4lMkZjb250cm9sX3YxMXBfc2QxNV9jYW5ueS5wdGglMjIlMjAlMjAlMjMlMjBjYW4lMjBhbHNvJTIwYmUlMjBhJTIwbG9jYWwlMjBwYXRoJTBBY29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3NpbmdsZV9maWxlKHVybCklMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGYmxvYiUyRm1haW4lMkZ2MS01LXBydW5lZC5zYWZldGVuc29ycyUyMiUyMCUyMCUyMyUyMGNhbiUyMGFsc28lMjBiZSUyMGElMjBsb2NhbCUyMHBhdGglMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uQ29udHJvbE5ldFBpcGVsaW5lLmZyb21fc2luZ2xlX2ZpbGUodXJsJTJDJTIwY29udHJvbG5ldCUzRGNvbnRyb2xuZXQp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel

url = <span class="hljs-string">&quot;https://huggingface.co/lllyasviel/ControlNet-v1-1/blob/main/control_v11p_sd15_canny.pth&quot;</span>  <span class="hljs-comment"># can also be a local path</span>
controlnet = ControlNetModel.from_single_file(url)

url = <span class="hljs-string">&quot;https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/blob/main/v1-5-pruned.safetensors&quot;</span>  <span class="hljs-comment"># can also be a local path</span>
pipe = StableDiffusionControlNetPipeline.from_single_file(url, controlnet=controlnet)`,wrap:!1}}),D=new ne({props:{title:"Loading from Control LoRA",local:"loading-from-control-lora",headingTag:"h2"}}),G=new Pe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbnRyb2xOZXRNb2RlbCUyQyUyMFVOZXQyRENvbmRpdGlvbk1vZGVsJTBBJTBBbG9yYV9pZCUyMCUzRCUyMCUyMnN0YWJpbGl0eWFpJTJGY29udHJvbC1sb3JhJTIyJTBBbG9yYV9maWxlbmFtZSUyMCUzRCUyMCUyMmNvbnRyb2wtTG9SQXMtcmFuazEyOCUyRmNvbnRyb2wtbG9yYS1jYW5ueS1yYW5rMTI4LnNhZmV0ZW5zb3JzJTIyJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFjb250cm9sbmV0JTIwJTNEJTIwQ29udHJvbE5ldE1vZGVsLmZyb21fdW5ldCh1bmV0KS50byhkZXZpY2UlM0QlMjJjdWRhJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiklMEFjb250cm9sbmV0LmxvYWRfbG9yYV9hZGFwdGVyKGxvcmFfaWQlMkMlMjB3ZWlnaHRfbmFtZSUzRGxvcmFfZmlsZW5hbWUlMkMlMjBwcmVmaXglM0ROb25lJTJDJTIwY29udHJvbG5ldF9jb25maWclM0Rjb250cm9sbmV0LmNvbmZpZyk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ControlNetModel, UNet2DConditionModel

lora_id = <span class="hljs-string">&quot;stabilityai/control-lora&quot;</span>
lora_filename = <span class="hljs-string">&quot;control-LoRAs-rank128/control-lora-canny-rank128.safetensors&quot;</span>

unet = UNet2DConditionModel.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, torch_dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
controlnet = ControlNetModel.from_unet(unet).to(device=<span class="hljs-string">&quot;cuda&quot;</span>, dtype=torch.bfloat16)
controlnet.load_lora_adapter(lora_id, weight_name=lora_filename, prefix=<span class="hljs-literal">None</span>, controlnet_config=controlnet.config)`,wrap:!1}}),B=new ne({props:{title:"ControlNetModel",local:"diffusers.ControlNetModel",headingTag:"h2"}}),O=new ee({props:{name:"class diffusers.ControlNetModel",anchor:"diffusers.ControlNetModel",parameters:[{name:"in_channels",val:": int = 4"},{name:"conditioning_channels",val:": int = 3"},{name:"flip_sin_to_cos",val:": bool = True"},{name:"freq_shift",val:": int = 0"},{name:"down_block_types",val:": typing.Tuple[str, ...] = ('CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'DownBlock2D')"},{name:"mid_block_type",val:": typing.Optional[str] = 'UNetMidBlock2DCrossAttn'"},{name:"only_cross_attention",val:": typing.Union[bool, typing.Tuple[bool]] = False"},{name:"block_out_channels",val:": typing.Tuple[int, ...] = (320, 640, 1280, 1280)"},{name:"layers_per_block",val:": int = 2"},{name:"downsample_padding",val:": int = 1"},{name:"mid_block_scale_factor",val:": float = 1"},{name:"act_fn",val:": str = 'silu'"},{name:"norm_num_groups",val:": typing.Optional[int] = 32"},{name:"norm_eps",val:": float = 1e-05"},{name:"cross_attention_dim",val:": int = 1280"},{name:"transformer_layers_per_block",val:": typing.Union[int, typing.Tuple[int, ...]] = 1"},{name:"encoder_hid_dim",val:": typing.Optional[int] = None"},{name:"encoder_hid_dim_type",val:": typing.Optional[str] = None"},{name:"attention_head_dim",val:": typing.Union[int, typing.Tuple[int, ...]] = 8"},{name:"num_attention_heads",val:": typing.Union[int, typing.Tuple[int, ...], NoneType] = None"},{name:"use_linear_projection",val:": bool = False"},{name:"class_embed_type",val:": typing.Optional[str] = None"},{name:"addition_embed_type",val:": typing.Optional[str] = None"},{name:"addition_time_embed_dim",val:": typing.Optional[int] = None"},{name:"num_class_embeds",val:": typing.Optional[int] = None"},{name:"upcast_attention",val:": bool = False"},{name:"resnet_time_scale_shift",val:": str = 'default'"},{name:"projection_class_embeddings_input_dim",val:": typing.Optional[int] = None"},{name:"controlnet_conditioning_channel_order",val:": str = 'rgb'"},{name:"conditioning_embedding_out_channels",val:": typing.Optional[typing.Tuple[int, ...]] = (16, 32, 96, 256)"},{name:"global_pool_conditions",val:": bool = False"},{name:"addition_embed_type_num_heads",val:": int = 64"}],parametersDescription:[{anchor:"diffusers.ControlNetModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to 4) &#x2014;
The number of channels in the input sample.`,name:"in_channels"},{anchor:"diffusers.ControlNetModel.flip_sin_to_cos",description:`<strong>flip_sin_to_cos</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to flip the sin to cos in the time embedding.`,name:"flip_sin_to_cos"},{anchor:"diffusers.ControlNetModel.freq_shift",description:`<strong>freq_shift</strong> (<code>int</code>, defaults to 0) &#x2014;
The frequency shift to apply to the time embedding.`,name:"freq_shift"},{anchor:"diffusers.ControlNetModel.down_block_types",description:`<strong>down_block_types</strong> (<code>tuple[str]</code>, defaults to <code>(&quot;CrossAttnDownBlock2D&quot;, &quot;CrossAttnDownBlock2D&quot;, &quot;CrossAttnDownBlock2D&quot;, &quot;DownBlock2D&quot;)</code>) &#x2014;
The tuple of downsample blocks to use.`,name:"down_block_types"},{anchor:"diffusers.ControlNetModel.only_cross_attention",description:"<strong>only_cross_attention</strong> (<code>Union[bool, Tuple[bool]]</code>, defaults to <code>False</code>) &#x2014;",name:"only_cross_attention"},{anchor:"diffusers.ControlNetModel.block_out_channels",description:`<strong>block_out_channels</strong> (<code>tuple[int]</code>, defaults to <code>(320, 640, 1280, 1280)</code>) &#x2014;
The tuple of output channels for each block.`,name:"block_out_channels"},{anchor:"diffusers.ControlNetModel.layers_per_block",description:`<strong>layers_per_block</strong> (<code>int</code>, defaults to 2) &#x2014;
The number of layers per block.`,name:"layers_per_block"},{anchor:"diffusers.ControlNetModel.downsample_padding",description:`<strong>downsample_padding</strong> (<code>int</code>, defaults to 1) &#x2014;
The padding to use for the downsampling convolution.`,name:"downsample_padding"},{anchor:"diffusers.ControlNetModel.mid_block_scale_factor",description:`<strong>mid_block_scale_factor</strong> (<code>float</code>, defaults to 1) &#x2014;
The scale factor to use for the mid block.`,name:"mid_block_scale_factor"},{anchor:"diffusers.ControlNetModel.act_fn",description:`<strong>act_fn</strong> (<code>str</code>, defaults to &#x201C;silu&#x201D;) &#x2014;
The activation function to use.`,name:"act_fn"},{anchor:"diffusers.ControlNetModel.norm_num_groups",description:`<strong>norm_num_groups</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of groups to use for the normalization. If None, normalization and activation layers is skipped
in post-processing.`,name:"norm_num_groups"},{anchor:"diffusers.ControlNetModel.norm_eps",description:`<strong>norm_eps</strong> (<code>float</code>, defaults to 1e-5) &#x2014;
The epsilon to use for the normalization.`,name:"norm_eps"},{anchor:"diffusers.ControlNetModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (<code>int</code>, defaults to 1280) &#x2014;
The dimension of the cross attention features.`,name:"cross_attention_dim"},{anchor:"diffusers.ControlNetModel.transformer_layers_per_block",description:`<strong>transformer_layers_per_block</strong> (<code>int</code> or <code>Tuple[int]</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of transformer blocks of type <code>BasicTransformerBlock</code>. Only relevant for
<code>~models.unet_2d_blocks.CrossAttnDownBlock2D</code>, <code>~models.unet_2d_blocks.CrossAttnUpBlock2D</code>,
<code>~models.unet_2d_blocks.UNetMidBlock2DCrossAttn</code>.`,name:"transformer_layers_per_block"},{anchor:"diffusers.ControlNetModel.encoder_hid_dim",description:`<strong>encoder_hid_dim</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
If <code>encoder_hid_dim_type</code> is defined, <code>encoder_hidden_states</code> will be projected from <code>encoder_hid_dim</code>
dimension to <code>cross_attention_dim</code>.`,name:"encoder_hid_dim"},{anchor:"diffusers.ControlNetModel.encoder_hid_dim_type",description:`<strong>encoder_hid_dim_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
If given, the <code>encoder_hidden_states</code> and potentially other embeddings are down-projected to text
embeddings of dimension <code>cross_attention</code> according to <code>encoder_hid_dim_type</code>.`,name:"encoder_hid_dim_type"},{anchor:"diffusers.ControlNetModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>Union[int, Tuple[int]]</code>, defaults to 8) &#x2014;
The dimension of the attention heads.`,name:"attention_head_dim"},{anchor:"diffusers.ControlNetModel.use_linear_projection",description:"<strong>use_linear_projection</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;",name:"use_linear_projection"},{anchor:"diffusers.ControlNetModel.class_embed_type",description:`<strong>class_embed_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The type of class embedding to use which is ultimately summed with the time embeddings. Choose from None,
<code>&quot;timestep&quot;</code>, <code>&quot;identity&quot;</code>, <code>&quot;projection&quot;</code>, or <code>&quot;simple_projection&quot;</code>.`,name:"class_embed_type"},{anchor:"diffusers.ControlNetModel.addition_embed_type",description:`<strong>addition_embed_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Configures an optional embedding which will be summed with the time embeddings. Choose from <code>None</code> or
&#x201C;text&#x201D;. &#x201C;text&#x201D; will use the <code>TextTimeEmbedding</code> layer.`,name:"addition_embed_type"},{anchor:"diffusers.ControlNetModel.num_class_embeds",description:`<strong>num_class_embeds</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Input dimension of the learnable embedding matrix to be projected to <code>time_embed_dim</code>, when performing
class conditioning with <code>class_embed_type</code> equal to <code>None</code>.`,name:"num_class_embeds"},{anchor:"diffusers.ControlNetModel.upcast_attention",description:"<strong>upcast_attention</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;",name:"upcast_attention"},{anchor:"diffusers.ControlNetModel.resnet_time_scale_shift",description:`<strong>resnet_time_scale_shift</strong> (<code>str</code>, defaults to <code>&quot;default&quot;</code>) &#x2014;
Time scale shift config for ResNet blocks (see <code>ResnetBlock2D</code>). Choose from <code>default</code> or <code>scale_shift</code>.`,name:"resnet_time_scale_shift"},{anchor:"diffusers.ControlNetModel.projection_class_embeddings_input_dim",description:`<strong>projection_class_embeddings_input_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The dimension of the <code>class_labels</code> input when <code>class_embed_type=&quot;projection&quot;</code>. Required when
<code>class_embed_type=&quot;projection&quot;</code>.`,name:"projection_class_embeddings_input_dim"},{anchor:"diffusers.ControlNetModel.controlnet_conditioning_channel_order",description:`<strong>controlnet_conditioning_channel_order</strong> (<code>str</code>, defaults to <code>&quot;rgb&quot;</code>) &#x2014;
The channel order of conditional image. Will convert to <code>rgb</code> if it&#x2019;s <code>bgr</code>.`,name:"controlnet_conditioning_channel_order"},{anchor:"diffusers.ControlNetModel.conditioning_embedding_out_channels",description:`<strong>conditioning_embedding_out_channels</strong> (<code>tuple[int]</code>, <em>optional</em>, defaults to <code>(16, 32, 96, 256)</code>) &#x2014;
The tuple of output channel for each block in the <code>conditioning_embedding</code> layer.`,name:"conditioning_embedding_out_channels"},{anchor:"diffusers.ControlNetModel.global_pool_conditions",description:`<strong>global_pool_conditions</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
TODO(Patrick) - unused parameter.`,name:"global_pool_conditions"},{anchor:"diffusers.ControlNetModel.addition_embed_type_num_heads",description:`<strong>addition_embed_type_num_heads</strong> (<code>int</code>, defaults to 64) &#x2014;
The number of heads to use for the <code>TextTimeEmbedding</code> layer.`,name:"addition_embed_type_num_heads"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L110"}}),L=new ee({props:{name:"forward",anchor:"diffusers.ControlNetModel.forward",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Union[torch.Tensor, float, int]"},{name:"encoder_hidden_states",val:": Tensor"},{name:"controlnet_cond",val:": Tensor"},{name:"conditioning_scale",val:": float = 1.0"},{name:"class_labels",val:": typing.Optional[torch.Tensor] = None"},{name:"timestep_cond",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"added_cond_kwargs",val:": typing.Optional[typing.Dict[str, torch.Tensor]] = None"},{name:"cross_attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"guess_mode",val:": bool = False"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.ControlNetModel.forward.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
The noisy input tensor.`,name:"sample"},{anchor:"diffusers.ControlNetModel.forward.timestep",description:`<strong>timestep</strong> (<code>Union[torch.Tensor, float, int]</code>) &#x2014;
The number of timesteps to denoise an input.`,name:"timestep"},{anchor:"diffusers.ControlNetModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
The encoder hidden states.`,name:"encoder_hidden_states"},{anchor:"diffusers.ControlNetModel.forward.controlnet_cond",description:`<strong>controlnet_cond</strong> (<code>torch.Tensor</code>) &#x2014;
The conditional input tensor of shape <code>(batch_size, sequence_length, hidden_size)</code>.`,name:"controlnet_cond"},{anchor:"diffusers.ControlNetModel.forward.conditioning_scale",description:`<strong>conditioning_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
The scale factor for ControlNet outputs.`,name:"conditioning_scale"},{anchor:"diffusers.ControlNetModel.forward.class_labels",description:`<strong>class_labels</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Optional class labels for conditioning. Their embeddings will be summed with the timestep embeddings.`,name:"class_labels"},{anchor:"diffusers.ControlNetModel.forward.timestep_cond",description:`<strong>timestep_cond</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Additional conditional embeddings for timestep. If provided, the embeddings will be summed with the
timestep_embedding passed through the <code>self.time_embedding</code> layer to obtain the final timestep
embeddings.`,name:"timestep_cond"},{anchor:"diffusers.ControlNetModel.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. If <code>1</code> the mask
is kept, otherwise if <code>0</code> it is discarded. Mask will be converted into a bias, which adds large
negative values to the attention scores corresponding to &#x201C;discard&#x201D; tokens.`,name:"attention_mask"},{anchor:"diffusers.ControlNetModel.forward.added_cond_kwargs",description:`<strong>added_cond_kwargs</strong> (<code>dict</code>) &#x2014;
Additional conditions for the Stable Diffusion XL UNet.`,name:"added_cond_kwargs"},{anchor:"diffusers.ControlNetModel.forward.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict[str]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttnProcessor</code>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.ControlNetModel.forward.guess_mode",description:`<strong>guess_mode</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
In this mode, the ControlNet encoder tries its best to recognize the input content of the input even if
you remove all prompts. A <code>guidance_scale</code> between 3.0 and 5.0 is recommended.`,name:"guess_mode"},{anchor:"diffusers.ControlNetModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.models.controlnets.ControlNetOutput">ControlNetOutput</a> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L601",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, a <a
  href="/docs/diffusers/main/en/api/models/controlnet#diffusers.models.controlnets.ControlNetOutput"
>ControlNetOutput</a> is returned,
otherwise a tuple is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/models/controlnet#diffusers.models.controlnets.ControlNetOutput"
>ControlNetOutput</a> <strong>or</strong> <code>tuple</code></p>
`}}),W=new ee({props:{name:"from_unet",anchor:"diffusers.ControlNetModel.from_unet",parameters:[{name:"unet",val:": UNet2DConditionModel"},{name:"controlnet_conditioning_channel_order",val:": str = 'rgb'"},{name:"conditioning_embedding_out_channels",val:": typing.Optional[typing.Tuple[int, ...]] = (16, 32, 96, 256)"},{name:"load_weights_from_unet",val:": bool = True"},{name:"conditioning_channels",val:": int = 3"}],parametersDescription:[{anchor:"diffusers.ControlNetModel.from_unet.unet",description:`<strong>unet</strong> (<code>UNet2DConditionModel</code>) &#x2014;
The UNet model weights to copy to the <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a>. All configuration options are also copied
where applicable.`,name:"unet"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L443"}}),z=new ee({props:{name:"set_attention_slice",anchor:"diffusers.ControlNetModel.set_attention_slice",parameters:[{name:"slice_size",val:": typing.Union[str, int, typing.List[int]]"}],parametersDescription:[{anchor:"diffusers.ControlNetModel.set_attention_slice.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code> or <code>list(int)</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, input to the attention heads is halved, so attention is computed in two steps. If
<code>&quot;max&quot;</code>, maximum amount of memory is saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L536"}}),I=new ee({props:{name:"set_default_attn_processor",anchor:"diffusers.ControlNetModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L520"}}),Y=new ne({props:{title:"ControlNetOutput",local:"diffusers.models.controlnets.ControlNetOutput",headingTag:"h2"}}),E=new ee({props:{name:"class diffusers.models.controlnets.ControlNetOutput",anchor:"diffusers.models.controlnets.ControlNetOutput",parameters:[{name:"down_block_res_samples",val:": typing.Tuple[torch.Tensor]"},{name:"mid_block_res_sample",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.models.controlnets.ControlNetOutput.down_block_res_samples",description:`<strong>down_block_res_samples</strong> (<code>tuple[torch.Tensor]</code>) &#x2014;
A tuple of downsample activations at different resolutions for each downsampling block. Each tensor should
be of shape <code>(batch_size, channel * resolution, height //resolution, width // resolution)</code>. Output can be
used to condition the original UNet&#x2019;s downsampling activations.`,name:"down_block_res_samples"},{anchor:"diffusers.models.controlnets.ControlNetOutput.mid_down_block_re_sample",description:`<strong>mid_down_block_re_sample</strong> (<code>torch.Tensor</code>) &#x2014;
The activation of the middle block (the lowest sample resolution). Each tensor should be of shape
<code>(batch_size, channel * lowest_resolution, height // lowest_resolution, width // lowest_resolution)</code>.
Output can be used to condition the original UNet&#x2019;s middle block activation.`,name:"mid_down_block_re_sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet.py#L46"}}),H=new io({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet.md"}}),{c(){y=d("meta"),se=n(),oe=d("p"),ie=n(),c(T.$$.fragment),re=n(),c($.$$.fragment),de=n(),k=d("p"),k.innerHTML=Le,le=n(),U=d("p"),U.textContent=We,ae=n(),J=d("p"),J.innerHTML=ze,ce=n(),c(j.$$.fragment),me=n(),Z=d("p"),Z.innerHTML=Ie,pe=n(),c(R.$$.fragment),fe=n(),c(D.$$.fragment),ue=n(),q=d("p"),q.innerHTML=Ye,_e=n(),c(G.$$.fragment),he=n(),c(B.$$.fragment),ge=n(),a=d("div"),c(O.$$.fragment),$e=n(),A=d("p"),A.textContent=Ee,ke=n(),v=d("div"),c(L.$$.fragment),Ue=n(),V=d("p"),V.innerHTML=He,Je=n(),M=d("div"),c(W.$$.fragment),je=n(),F=d("p"),F.innerHTML=Ae,Ze=n(),b=d("div"),c(z.$$.fragment),Re=n(),S=d("p"),S.textContent=Ve,De=n(),X=d("p"),X.textContent=Fe,qe=n(),N=d("div"),c(I.$$.fragment),Ge=n(),P=d("p"),P.textContent=Se,be=n(),c(Y.$$.fragment),ye=n(),C=d("div"),c(E.$$.fragment),Be=n(),Q=d("p"),Q.innerHTML=Xe,Ce=n(),c(H.$$.fragment),ve=n(),te=d("p"),this.h()},l(e){const o=no("svelte-u9bgzb",document.head);y=l(o,"META",{name:!0,content:!0}),o.forEach(t),se=s(e),oe=l(e,"P",{}),w(oe).forEach(t),ie=s(e),m(T.$$.fragment,e),re=s(e),m($.$$.fragment,e),de=s(e),k=l(e,"P",{"data-svelte-h":!0}),g(k)!=="svelte-1s65p96"&&(k.innerHTML=Le),le=s(e),U=l(e,"P",{"data-svelte-h":!0}),g(U)!=="svelte-1cwsb16"&&(U.textContent=We),ae=s(e),J=l(e,"P",{"data-svelte-h":!0}),g(J)!=="svelte-fbiw6t"&&(J.innerHTML=ze),ce=s(e),m(j.$$.fragment,e),me=s(e),Z=l(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-1czirv2"&&(Z.innerHTML=Ie),pe=s(e),m(R.$$.fragment,e),fe=s(e),m(D.$$.fragment,e),ue=s(e),q=l(e,"P",{"data-svelte-h":!0}),g(q)!=="svelte-fvsrzz"&&(q.innerHTML=Ye),_e=s(e),m(G.$$.fragment,e),he=s(e),m(B.$$.fragment,e),ge=s(e),a=l(e,"DIV",{class:!0});var h=w(a);m(O.$$.fragment,h),$e=s(h),A=l(h,"P",{"data-svelte-h":!0}),g(A)!=="svelte-1cnm7fm"&&(A.textContent=Ee),ke=s(h),v=l(h,"DIV",{class:!0});var Ne=w(v);m(L.$$.fragment,Ne),Ue=s(Ne),V=l(Ne,"P",{"data-svelte-h":!0}),g(V)!=="svelte-796i8l"&&(V.innerHTML=He),Ne.forEach(t),Je=s(h),M=l(h,"DIV",{class:!0});var we=w(M);m(W.$$.fragment,we),je=s(we),F=l(we,"P",{"data-svelte-h":!0}),g(F)!=="svelte-zjwdt6"&&(F.innerHTML=Ae),we.forEach(t),Ze=s(h),b=l(h,"DIV",{class:!0});var K=w(b);m(z.$$.fragment,K),Re=s(K),S=l(K,"P",{"data-svelte-h":!0}),g(S)!=="svelte-7fahc0"&&(S.textContent=Ve),De=s(K),X=l(K,"P",{"data-svelte-h":!0}),g(X)!=="svelte-1yjwkav"&&(X.textContent=Fe),K.forEach(t),qe=s(h),N=l(h,"DIV",{class:!0});var xe=w(N);m(I.$$.fragment,xe),Ge=s(xe),P=l(xe,"P",{"data-svelte-h":!0}),g(P)!=="svelte-1lxcwhv"&&(P.textContent=Se),xe.forEach(t),h.forEach(t),be=s(e),m(Y.$$.fragment,e),ye=s(e),C=l(e,"DIV",{class:!0});var Te=w(C);m(E.$$.fragment,Te),Be=s(Te),Q=l(Te,"P",{"data-svelte-h":!0}),g(Q)!=="svelte-1r4jaih"&&(Q.innerHTML=Xe),Te.forEach(t),Ce=s(e),m(H.$$.fragment,e),ve=s(e),te=l(e,"P",{}),w(te).forEach(t),this.h()},h(){x(y,"name","hf:doc:metadata"),x(y,"content",lo),x(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,o){r(document.head,y),i(e,se,o),i(e,oe,o),i(e,ie,o),p(T,e,o),i(e,re,o),p($,e,o),i(e,de,o),i(e,k,o),i(e,le,o),i(e,U,o),i(e,ae,o),i(e,J,o),i(e,ce,o),p(j,e,o),i(e,me,o),i(e,Z,o),i(e,pe,o),p(R,e,o),i(e,fe,o),p(D,e,o),i(e,ue,o),i(e,q,o),i(e,_e,o),p(G,e,o),i(e,he,o),p(B,e,o),i(e,ge,o),i(e,a,o),p(O,a,null),r(a,$e),r(a,A),r(a,ke),r(a,v),p(L,v,null),r(v,Ue),r(v,V),r(a,Je),r(a,M),p(W,M,null),r(M,je),r(M,F),r(a,Ze),r(a,b),p(z,b,null),r(b,Re),r(b,S),r(b,De),r(b,X),r(a,qe),r(a,N),p(I,N,null),r(N,Ge),r(N,P),i(e,be,o),p(Y,e,o),i(e,ye,o),i(e,C,o),p(E,C,null),r(C,Be),r(C,Q),i(e,Ce,o),p(H,e,o),i(e,ve,o),i(e,te,o),Me=!0},p:Ke,i(e){Me||(f(T.$$.fragment,e),f($.$$.fragment,e),f(j.$$.fragment,e),f(R.$$.fragment,e),f(D.$$.fragment,e),f(G.$$.fragment,e),f(B.$$.fragment,e),f(O.$$.fragment,e),f(L.$$.fragment,e),f(W.$$.fragment,e),f(z.$$.fragment,e),f(I.$$.fragment,e),f(Y.$$.fragment,e),f(E.$$.fragment,e),f(H.$$.fragment,e),Me=!0)},o(e){u(T.$$.fragment,e),u($.$$.fragment,e),u(j.$$.fragment,e),u(R.$$.fragment,e),u(D.$$.fragment,e),u(G.$$.fragment,e),u(B.$$.fragment,e),u(O.$$.fragment,e),u(L.$$.fragment,e),u(W.$$.fragment,e),u(z.$$.fragment,e),u(I.$$.fragment,e),u(Y.$$.fragment,e),u(E.$$.fragment,e),u(H.$$.fragment,e),Me=!1},d(e){e&&(t(se),t(oe),t(ie),t(re),t(de),t(k),t(le),t(U),t(ae),t(J),t(ce),t(me),t(Z),t(pe),t(fe),t(ue),t(q),t(_e),t(he),t(ge),t(a),t(be),t(ye),t(C),t(Ce),t(ve),t(te)),t(y),_(T,e),_($,e),_(j,e),_(R,e),_(D,e),_(G,e),_(B,e),_(O),_(L),_(W),_(z),_(I),_(Y,e),_(E),_(H,e)}}}const lo='{"title":"ControlNetModel","local":"controlnetmodel","sections":[{"title":"Loading from the original format","local":"loading-from-the-original-format","sections":[],"depth":2},{"title":"Loading from Control LoRA","local":"loading-from-control-lora","sections":[],"depth":2},{"title":"ControlNetModel","local":"diffusers.ControlNetModel","sections":[],"depth":2},{"title":"ControlNetOutput","local":"diffusers.models.controlnets.ControlNetOutput","sections":[],"depth":2}],"depth":1}';function ao(Oe){return eo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ho extends oo{constructor(y){super(),to(this,y,ao,ro,Qe,{})}}export{ho as component};
