import{s as Oe,n as Ke,o as Qe}from"../chunks/scheduler.53228c21.js";import{S as eo,i as oo,e as a,s,c as p,h as to,a as d,d as o,b as n,f as y,g as f,j as h,k as C,l as r,m as i,n as m,t as u,o as _,p as g}from"../chunks/index.100fac89.js";import{C as so}from"../chunks/CopyLLMTxtMenu.fb2ec027.js";import{D as X}from"../chunks/Docstring.86a664ae.js";import{C as no}from"../chunks/CodeBlock.d30a6509.js";import{H as Pe,E as ro}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.09d4dba9.js";function io(Ue){let A,se,oe,ne,T,re,x,ie,N,Be='SparseControlNetModel is an implementation of ControlNet for <a href="https://huggingface.co/papers/2307.04725" rel="nofollow">AnimateDiff</a>.',ae,S,Ge='ControlNet 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, and Maneesh Agrawala.',de,$,Ve='The SparseCtrl version of ControlNet was introduced in <a href="https://huggingface.co/papers/2311.16933" rel="nofollow">SparseCtrl: Adding Sparse Controls to Text-to-Video Diffusion Models</a> for achieving controlled generation in text-to-video diffusion models by Yuwei Guo, Ceyuan Yang, Anyi Rao, Maneesh Agrawala, Dahua Lin, and Bo Dai.',le,k,je="The abstract from the paper is:",ce,F,qe='<em>The development of text-to-video (T2V), i.e., generating videos with a given text prompt, has been significantly advanced in recent years. However, relying solely on text prompts often results in ambiguous frame composition due to spatial uncertainty. The research community thus leverages the dense structure signals, e.g., per-frame depth/edge sequences, to enhance controllability, whose collection accordingly increases the burden of inference. In this work, we present SparseCtrl to enable flexible structure control with temporally sparse signals, requiring only one or a few inputs, as shown in Figure 1. It incorporates an additional condition encoder to process these sparse signals while leaving the pre-trained T2V model untouched. The proposed approach is compatible with various modalities, including sketches, depth maps, and RGB images, providing more practical control for video generation and promoting applications such as storyboarding, depth rendering, keyframe animation, and interpolation. Extensive experiments demonstrate the generalization of SparseCtrl on both original and personalized T2V generators. Codes and models will be publicly available at <a href="https://guoyww.github.io/projects/SparseCtrl" rel="nofollow">this https URL</a>.</em>',pe,D,fe,I,me,L,ue,l,J,we,z,He=`A SparseControlNet model as described in <a href="https://huggingface.co/papers/2311.16933" rel="nofollow">SparseCtrl: Adding Sparse Controls to Text-to-Video Diffusion
Models</a>.`,Te,v,U,xe,E,Re='The <a href="/docs/diffusers/main/en/api/models/controlnet_sparsectrl#diffusers.SparseControlNetModel">SparseControlNetModel</a> forward method.',Ne,M,B,Se,W,Ze='Instantiate a <a href="/docs/diffusers/main/en/api/models/controlnet_sparsectrl#diffusers.SparseControlNetModel">SparseControlNetModel</a> from <a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>.',$e,b,G,ke,Y,Xe="Enable sliced attention computation.",Fe,O,ze=`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.`,De,P,V,Ie,K,Ee="Sets the attention processor to use to compute attention.",Le,w,j,Je,Q,We="Disables custom attention processors and sets the default attention implementation.",_e,q,ge,H,R,he,Z,be,te,Ae;return T=new so({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),x=new Pe({props:{title:"SparseControlNetModel",local:"sparsecontrolnetmodel",headingTag:"h1"}}),D=new Pe({props:{title:"Example for loading SparseControlNetModel",local:"example-for-loading-sparsecontrolnetmodel",headingTag:"h2"}}),I=new no({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3BhcnNlQ29udHJvbE5ldE1vZGVsJTBBJTBBJTIzJTIwZnAzMiUyMHZhcmlhbnQlMjBpbiUyMGZsb2F0MTYlMEElMjMlMjAxLiUyMFNjcmliYmxlJTIwY2hlY2twb2ludCUwQWNvbnRyb2xuZXQlMjAlM0QlMjBTcGFyc2VDb250cm9sTmV0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmd1b3l3dyUyRmFuaW1hdGVkaWZmLXNwYXJzZWN0cmwtc2NyaWJibGUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBJTIzJTIwMi4lMjBSR0IlMjBjaGVja3BvaW50JTBBY29udHJvbG5ldCUyMCUzRCUyMFNwYXJzZUNvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZ3VveXd3JTJGYW5pbWF0ZWRpZmYtc3BhcnNlY3RybC1yZ2IlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBJTBBJTIzJTIwRm9yJTIwbG9hZGluZyUyMGZwMTYlMjB2YXJpYW50JTJDJTIwcGFzcyUyMCU2MHZhcmlhbnQlM0QlMjJmcDE2JTIyJTYwJTIwYXMlMjBhbiUyMGFkZGl0aW9uYWwlMjBwYXJhbWV0ZXI=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> SparseControlNetModel

<span class="hljs-comment"># fp32 variant in float16</span>
<span class="hljs-comment"># 1. Scribble checkpoint</span>
controlnet = SparseControlNetModel.from_pretrained(<span class="hljs-string">&quot;guoyww/animatediff-sparsectrl-scribble&quot;</span>, torch_dtype=torch.float16)

<span class="hljs-comment"># 2. RGB checkpoint</span>
controlnet = SparseControlNetModel.from_pretrained(<span class="hljs-string">&quot;guoyww/animatediff-sparsectrl-rgb&quot;</span>, torch_dtype=torch.float16)

<span class="hljs-comment"># For loading fp16 variant, pass \`variant=&quot;fp16&quot;\` as an additional parameter</span>`,wrap:!1}}),L=new Pe({props:{title:"SparseControlNetModel",local:"diffusers.SparseControlNetModel",headingTag:"h2"}}),J=new X({props:{name:"class diffusers.SparseControlNetModel",anchor:"diffusers.SparseControlNetModel",parameters:[{name:"in_channels",val:": int = 4"},{name:"conditioning_channels",val:": int = 4"},{name:"flip_sin_to_cos",val:": bool = True"},{name:"freq_shift",val:": int = 0"},{name:"down_block_types",val:": typing.Tuple[str, ...] = ('CrossAttnDownBlockMotion', 'CrossAttnDownBlockMotion', 'CrossAttnDownBlockMotion', 'DownBlockMotion')"},{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 = 768"},{name:"transformer_layers_per_block",val:": typing.Union[int, typing.Tuple[int, ...]] = 1"},{name:"transformer_layers_per_mid_block",val:": typing.Union[int, typing.Tuple[int], NoneType] = None"},{name:"temporal_transformer_layers_per_block",val:": typing.Union[int, typing.Tuple[int, ...]] = 1"},{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:"upcast_attention",val:": bool = False"},{name:"resnet_time_scale_shift",val:": str = 'default'"},{name:"conditioning_embedding_out_channels",val:": typing.Optional[typing.Tuple[int, ...]] = (16, 32, 96, 256)"},{name:"global_pool_conditions",val:": bool = False"},{name:"controlnet_conditioning_channel_order",val:": str = 'rgb'"},{name:"motion_max_seq_length",val:": int = 32"},{name:"motion_num_attention_heads",val:": int = 8"},{name:"concat_conditioning_mask",val:": bool = True"},{name:"use_simplified_condition_embedding",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.SparseControlNetModel.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.SparseControlNetModel.conditioning_channels",description:`<strong>conditioning_channels</strong> (<code>int</code>, defaults to 4) &#x2014;
The number of input channels in the controlnet conditional embedding module. If
<code>concat_condition_embedding</code> is True, the value provided here is incremented by 1.`,name:"conditioning_channels"},{anchor:"diffusers.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.transformer_layers_per_mid_block",description:`<strong>transformer_layers_per_mid_block</strong> (<code>int</code> or <code>Tuple[int]</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of transformer layers to use in each layer in the middle block.`,name:"transformer_layers_per_mid_block"},{anchor:"diffusers.SparseControlNetModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code> or <code>Tuple[int]</code>, defaults to 8) &#x2014;
The dimension of the attention heads.`,name:"attention_head_dim"},{anchor:"diffusers.SparseControlNetModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code> or <code>Tuple[int]</code>, <em>optional</em>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.SparseControlNetModel.use_linear_projection",description:"<strong>use_linear_projection</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;",name:"use_linear_projection"},{anchor:"diffusers.SparseControlNetModel.upcast_attention",description:"<strong>upcast_attention</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;",name:"upcast_attention"},{anchor:"diffusers.SparseControlNetModel.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.SparseControlNetModel.conditioning_embedding_out_channels",description:`<strong>conditioning_embedding_out_channels</strong> (<code>Tuple[int]</code>, 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.SparseControlNetModel.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.SparseControlNetModel.controlnet_conditioning_channel_order",description:"<strong>controlnet_conditioning_channel_order</strong> (<code>str</code>, defaults to <code>rgb</code>) &#x2014;",name:"controlnet_conditioning_channel_order"},{anchor:"diffusers.SparseControlNetModel.motion_max_seq_length",description:`<strong>motion_max_seq_length</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The maximum sequence length to use in the motion module.`,name:"motion_max_seq_length"},{anchor:"diffusers.SparseControlNetModel.motion_num_attention_heads",description:`<strong>motion_num_attention_heads</strong> (<code>int</code> or <code>Tuple[int]</code>, defaults to <code>8</code>) &#x2014;
The number of heads to use in each attention layer of the motion module.`,name:"motion_num_attention_heads"},{anchor:"diffusers.SparseControlNetModel.concat_conditioning_mask",description:"<strong>concat_conditioning_mask</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;",name:"concat_conditioning_mask"},{anchor:"diffusers.SparseControlNetModel.use_simplified_condition_embedding",description:"<strong>use_simplified_condition_embedding</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;",name:"use_simplified_condition_embedding"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_sparsectrl.py#L96"}}),U=new X({props:{name:"forward",anchor:"diffusers.SparseControlNetModel.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:"timestep_cond",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"cross_attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"conditioning_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"guess_mode",val:": bool = False"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.SparseControlNetModel.forward.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
The noisy input tensor.`,name:"sample"},{anchor:"diffusers.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.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.SparseControlNetModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>ControlNetOutput</code> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_sparsectrl.py#L593",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, a <code>ControlNetOutput</code> 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><code>ControlNetOutput</code> <strong>or</strong> <code>tuple</code></p>
`}}),B=new X({props:{name:"from_unet",anchor:"diffusers.SparseControlNetModel.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.SparseControlNetModel.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_sparsectrl#diffusers.SparseControlNetModel">SparseControlNetModel</a>. All configuration options are also
copied where applicable.`,name:"unet"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_sparsectrl.py#L387"}}),G=new X({props:{name:"set_attention_slice",anchor:"diffusers.SparseControlNetModel.set_attention_slice",parameters:[{name:"slice_size",val:": typing.Union[str, int, typing.List[int]]"}],parametersDescription:[{anchor:"diffusers.SparseControlNetModel.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_sparsectrl.py#L528"}}),V=new X({props:{name:"set_attn_processor",anchor:"diffusers.SparseControlNetModel.set_attn_processor",parameters:[{name:"processor",val:": typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.SD3IPAdapterJointAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor, typing.Dict[str, typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.SD3IPAdapterJointAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor]]]"}],parametersDescription:[{anchor:"diffusers.SparseControlNetModel.set_attn_processor.processor",description:`<strong>processor</strong> (<code>dict</code> of <code>AttentionProcessor</code> or only <code>AttentionProcessor</code>) &#x2014;
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for <strong>all</strong> <code>Attention</code> layers.</p>
<p>If <code>processor</code> is a dict, the key needs to define the path to the corresponding cross attention
processor. This is strongly recommended when setting trainable attention processors.`,name:"processor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_sparsectrl.py#L477"}}),j=new X({props:{name:"set_default_attn_processor",anchor:"diffusers.SparseControlNetModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_sparsectrl.py#L512"}}),q=new Pe({props:{title:"SparseControlNetOutput",local:"diffusers.models.controlnet_sparsectrl.SparseControlNetOutput",headingTag:"h2"}}),R=new X({props:{name:"class diffusers.models.controlnet_sparsectrl.SparseControlNetOutput",anchor:"diffusers.models.controlnet_sparsectrl.SparseControlNetOutput",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sparsectrl.py#L30"}}),Z=new ro({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_sparsectrl.md"}}),{c(){A=a("meta"),se=s(),oe=a("p"),ne=s(),p(T.$$.fragment),re=s(),p(x.$$.fragment),ie=s(),N=a("p"),N.innerHTML=Be,ae=s(),S=a("p"),S.innerHTML=Ge,de=s(),$=a("p"),$.innerHTML=Ve,le=s(),k=a("p"),k.textContent=je,ce=s(),F=a("p"),F.innerHTML=qe,pe=s(),p(D.$$.fragment),fe=s(),p(I.$$.fragment),me=s(),p(L.$$.fragment),ue=s(),l=a("div"),p(J.$$.fragment),we=s(),z=a("p"),z.innerHTML=He,Te=s(),v=a("div"),p(U.$$.fragment),xe=s(),E=a("p"),E.innerHTML=Re,Ne=s(),M=a("div"),p(B.$$.fragment),Se=s(),W=a("p"),W.innerHTML=Ze,$e=s(),b=a("div"),p(G.$$.fragment),ke=s(),Y=a("p"),Y.textContent=Xe,Fe=s(),O=a("p"),O.textContent=ze,De=s(),P=a("div"),p(V.$$.fragment),Ie=s(),K=a("p"),K.textContent=Ee,Le=s(),w=a("div"),p(j.$$.fragment),Je=s(),Q=a("p"),Q.textContent=We,_e=s(),p(q.$$.fragment),ge=s(),H=a("div"),p(R.$$.fragment),he=s(),p(Z.$$.fragment),be=s(),te=a("p"),this.h()},l(e){const t=to("svelte-u9bgzb",document.head);A=d(t,"META",{name:!0,content:!0}),t.forEach(o),se=n(e),oe=d(e,"P",{}),y(oe).forEach(o),ne=n(e),f(T.$$.fragment,e),re=n(e),f(x.$$.fragment,e),ie=n(e),N=d(e,"P",{"data-svelte-h":!0}),h(N)!=="svelte-11my3xx"&&(N.innerHTML=Be),ae=n(e),S=d(e,"P",{"data-svelte-h":!0}),h(S)!=="svelte-1v2xz23"&&(S.innerHTML=Ge),de=n(e),$=d(e,"P",{"data-svelte-h":!0}),h($)!=="svelte-1pcd88w"&&($.innerHTML=Ve),le=n(e),k=d(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-1cwsb16"&&(k.textContent=je),ce=n(e),F=d(e,"P",{"data-svelte-h":!0}),h(F)!=="svelte-uew8uc"&&(F.innerHTML=qe),pe=n(e),f(D.$$.fragment,e),fe=n(e),f(I.$$.fragment,e),me=n(e),f(L.$$.fragment,e),ue=n(e),l=d(e,"DIV",{class:!0});var c=y(l);f(J.$$.fragment,c),we=n(c),z=d(c,"P",{"data-svelte-h":!0}),h(z)!=="svelte-1w3vs31"&&(z.innerHTML=He),Te=n(c),v=d(c,"DIV",{class:!0});var ye=y(v);f(U.$$.fragment,ye),xe=n(ye),E=d(ye,"P",{"data-svelte-h":!0}),h(E)!=="svelte-ul1ug5"&&(E.innerHTML=Re),ye.forEach(o),Ne=n(c),M=d(c,"DIV",{class:!0});var Ce=y(M);f(B.$$.fragment,Ce),Se=n(Ce),W=d(Ce,"P",{"data-svelte-h":!0}),h(W)!=="svelte-24gfcg"&&(W.innerHTML=Ze),Ce.forEach(o),$e=n(c),b=d(c,"DIV",{class:!0});var ee=y(b);f(G.$$.fragment,ee),ke=n(ee),Y=d(ee,"P",{"data-svelte-h":!0}),h(Y)!=="svelte-7fahc0"&&(Y.textContent=Xe),Fe=n(ee),O=d(ee,"P",{"data-svelte-h":!0}),h(O)!=="svelte-1yjwkav"&&(O.textContent=ze),ee.forEach(o),De=n(c),P=d(c,"DIV",{class:!0});var ve=y(P);f(V.$$.fragment,ve),Ie=n(ve),K=d(ve,"P",{"data-svelte-h":!0}),h(K)!=="svelte-1o77hl2"&&(K.textContent=Ee),ve.forEach(o),Le=n(c),w=d(c,"DIV",{class:!0});var Me=y(w);f(j.$$.fragment,Me),Je=n(Me),Q=d(Me,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-1lxcwhv"&&(Q.textContent=We),Me.forEach(o),c.forEach(o),_e=n(e),f(q.$$.fragment,e),ge=n(e),H=d(e,"DIV",{class:!0});var Ye=y(H);f(R.$$.fragment,Ye),Ye.forEach(o),he=n(e),f(Z.$$.fragment,e),be=n(e),te=d(e,"P",{}),y(te).forEach(o),this.h()},h(){C(A,"name","hf:doc:metadata"),C(A,"content",ao),C(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(H,"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,t){r(document.head,A),i(e,se,t),i(e,oe,t),i(e,ne,t),m(T,e,t),i(e,re,t),m(x,e,t),i(e,ie,t),i(e,N,t),i(e,ae,t),i(e,S,t),i(e,de,t),i(e,$,t),i(e,le,t),i(e,k,t),i(e,ce,t),i(e,F,t),i(e,pe,t),m(D,e,t),i(e,fe,t),m(I,e,t),i(e,me,t),m(L,e,t),i(e,ue,t),i(e,l,t),m(J,l,null),r(l,we),r(l,z),r(l,Te),r(l,v),m(U,v,null),r(v,xe),r(v,E),r(l,Ne),r(l,M),m(B,M,null),r(M,Se),r(M,W),r(l,$e),r(l,b),m(G,b,null),r(b,ke),r(b,Y),r(b,Fe),r(b,O),r(l,De),r(l,P),m(V,P,null),r(P,Ie),r(P,K),r(l,Le),r(l,w),m(j,w,null),r(w,Je),r(w,Q),i(e,_e,t),m(q,e,t),i(e,ge,t),i(e,H,t),m(R,H,null),i(e,he,t),m(Z,e,t),i(e,be,t),i(e,te,t),Ae=!0},p:Ke,i(e){Ae||(u(T.$$.fragment,e),u(x.$$.fragment,e),u(D.$$.fragment,e),u(I.$$.fragment,e),u(L.$$.fragment,e),u(J.$$.fragment,e),u(U.$$.fragment,e),u(B.$$.fragment,e),u(G.$$.fragment,e),u(V.$$.fragment,e),u(j.$$.fragment,e),u(q.$$.fragment,e),u(R.$$.fragment,e),u(Z.$$.fragment,e),Ae=!0)},o(e){_(T.$$.fragment,e),_(x.$$.fragment,e),_(D.$$.fragment,e),_(I.$$.fragment,e),_(L.$$.fragment,e),_(J.$$.fragment,e),_(U.$$.fragment,e),_(B.$$.fragment,e),_(G.$$.fragment,e),_(V.$$.fragment,e),_(j.$$.fragment,e),_(q.$$.fragment,e),_(R.$$.fragment,e),_(Z.$$.fragment,e),Ae=!1},d(e){e&&(o(se),o(oe),o(ne),o(re),o(ie),o(N),o(ae),o(S),o(de),o($),o(le),o(k),o(ce),o(F),o(pe),o(fe),o(me),o(ue),o(l),o(_e),o(ge),o(H),o(he),o(be),o(te)),o(A),g(T,e),g(x,e),g(D,e),g(I,e),g(L,e),g(J),g(U),g(B),g(G),g(V),g(j),g(q,e),g(R),g(Z,e)}}}const ao='{"title":"SparseControlNetModel","local":"sparsecontrolnetmodel","sections":[{"title":"Example for loading SparseControlNetModel","local":"example-for-loading-sparsecontrolnetmodel","sections":[],"depth":2},{"title":"SparseControlNetModel","local":"diffusers.SparseControlNetModel","sections":[],"depth":2},{"title":"SparseControlNetOutput","local":"diffusers.models.controlnet_sparsectrl.SparseControlNetOutput","sections":[],"depth":2}],"depth":1}';function lo(Ue){return Qe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class go extends eo{constructor(A){super(),oo(this,A,lo,io,Oe,{})}}export{go as component};
