import{s as at,n as it,o as dt}from"../chunks/scheduler.182ea377.js";import{S as lt,i as ct,g as r,s as n,r as u,A as mt,h as a,f as o,c as s,j as v,u as p,x as m,k as w,y as t,a as c,v as h,d as g,t as _,w as b}from"../chunks/index.abf12888.js";import{D as x}from"../chunks/Docstring.93f6f462.js";import{H as je}from"../chunks/Heading.16916d63.js";function ft(qe){let $,ae,se,ie,L,de,P,Re='The <a href="https://huggingface.co/papers/1505.04597" rel="nofollow">UNet</a> model was originally introduced by Ronneberger et al for biomedical image segmentation, but it is also commonly used in 🤗 Diffusers because it outputs images that are the same size as the input. It is one of the most important components of a diffusion system because it facilitates the actual diffusion process. There are several variants of the UNet model in 🤗 Diffusers, depending on it’s number of dimensions and whether it is a conditional model or not. This is a 2D UNet model.',le,I,We="The abstract from the paper is:",ce,O,Ge='<em>There is large consent that successful training of deep networks requires many thousand annotated training samples. In this paper, we present a network and training strategy that relies on the strong use of data augmentation to use the available annotated samples more efficiently. The architecture consists of a contracting path to capture context and a symmetric expanding path that enables precise localization. We show that such a network can be trained end-to-end from very few images and outperforms the prior best method (a sliding-window convolutional network) on the ISBI challenge for segmentation of neuronal structures in electron microscopic stacks. Using the same network trained on transmitted light microscopy images (phase contrast and DIC) we won the ISBI cell tracking challenge 2015 in these categories by a large margin. Moreover, the network is fast. Segmentation of a 512x512 image takes less than a second on a recent GPU. The full implementation (based on Caffe) and the trained networks are available at <a href="http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net" rel="nofollow">http://lmb.informatik.uni-freiburg.de/people/ronneber/u-net</a>.</em>',me,H,fe,i,A,ke,W,Xe=`A modified conditional 2D UNet model that takes a noisy sample, conditional state, and a timestep and returns a
sample shaped output.`,ye,G,Je=`This model inherits from <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin">ModelMixin</a>. Check the superclass documentation for it’s generic methods implemented
for all models (such as downloading or saving).`,Te,k,z,Ue,X,Ke="Disables the FreeU mechanism.",Ne,y,S,Ce,J,Qe=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,De,f,E,Le,K,Ye='Enables the FreeU mechanism from <a href="https://arxiv.org/abs/2309.11497" rel="nofollow">https://arxiv.org/abs/2309.11497</a>.',Pe,Q,Ze="The suffixes after the scaling factors represent the stage blocks where they are being applied.",Ie,Y,et=`Please refer to the <a href="https://github.com/ChenyangSi/FreeU" rel="nofollow">official repository</a> for combinations of values that
are known to work well for different pipelines such as Stable Diffusion v1, v2, and Stable Diffusion XL.`,Oe,T,F,He,Z,tt='The <a href="/docs/diffusers/main/en/api/models/unet-motion#diffusers.UNetMotionModel">UNetMotionModel</a> forward method.',Ae,U,B,ze,ee,ot=`Freeze the weights of just the UNet2DConditionModel, and leave the motion modules
unfrozen for fine tuning.`,Se,N,V,Ee,te,nt="Sets the attention processor to use to compute attention.",Fe,C,j,Be,oe,st="Disables custom attention processors and sets the default attention implementation.",ue,q,pe,M,R,Ve,ne,rt='The output of <a href="/docs/diffusers/main/en/api/models/unet3d-cond#diffusers.UNet3DConditionModel">UNet3DConditionModel</a>.',he,re,ge;return L=new je({props:{title:"UNetMotionModel",local:"unetmotionmodel",headingTag:"h1"}}),H=new je({props:{title:"UNetMotionModel",local:"diffusers.UNetMotionModel",headingTag:"h2"}}),A=new x({props:{name:"class diffusers.UNetMotionModel",anchor:"diffusers.UNetMotionModel",parameters:[{name:"sample_size",val:": Optional = None"},{name:"in_channels",val:": int = 4"},{name:"out_channels",val:": int = 4"},{name:"down_block_types",val:": Tuple = ('CrossAttnDownBlockMotion', 'CrossAttnDownBlockMotion', 'CrossAttnDownBlockMotion', 'DownBlockMotion')"},{name:"up_block_types",val:": Tuple = ('UpBlockMotion', 'CrossAttnUpBlockMotion', 'CrossAttnUpBlockMotion', 'CrossAttnUpBlockMotion')"},{name:"block_out_channels",val:": Tuple = (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:": int = 32"},{name:"norm_eps",val:": float = 1e-05"},{name:"cross_attention_dim",val:": int = 1280"},{name:"use_linear_projection",val:": bool = False"},{name:"num_attention_heads",val:": Union = 8"},{name:"motion_max_seq_length",val:": int = 32"},{name:"motion_num_attention_heads",val:": int = 8"},{name:"use_motion_mid_block",val:": int = True"},{name:"encoder_hid_dim",val:": Optional = None"},{name:"encoder_hid_dim_type",val:": Optional = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L176"}}),z=new x({props:{name:"disable_freeu",anchor:"diffusers.UNetMotionModel.disable_freeu",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L695"}}),S=new x({props:{name:"enable_forward_chunking",anchor:"diffusers.UNetMotionModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": Optional = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.UNetMotionModel.enable_forward_chunking.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The chunk size of the feed-forward layers. If not specified, will run feed-forward layer individually
over each tensor of dim=<code>dim</code>.`,name:"chunk_size"},{anchor:"diffusers.UNetMotionModel.enable_forward_chunking.dim",description:`<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
The dimension over which the feed-forward computation should be chunked. Choose between dim=0 (batch)
or dim=1 (sequence length).`,name:"dim"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L608"}}),E=new x({props:{name:"enable_freeu",anchor:"diffusers.UNetMotionModel.enable_freeu",parameters:[{name:"s1",val:": float"},{name:"s2",val:": float"},{name:"b1",val:": float"},{name:"b2",val:": float"}],parametersDescription:[{anchor:"diffusers.UNetMotionModel.enable_freeu.s1",description:`<strong>s1</strong> (<code>float</code>) &#x2014;
Scaling factor for stage 1 to attenuate the contributions of the skip features. This is done to
mitigate the &#x201C;oversmoothing effect&#x201D; in the enhanced denoising process.`,name:"s1"},{anchor:"diffusers.UNetMotionModel.enable_freeu.s2",description:`<strong>s2</strong> (<code>float</code>) &#x2014;
Scaling factor for stage 2 to attenuate the contributions of the skip features. This is done to
mitigate the &#x201C;oversmoothing effect&#x201D; in the enhanced denoising process.`,name:"s2"},{anchor:"diffusers.UNetMotionModel.enable_freeu.b1",description:"<strong>b1</strong> (<code>float</code>) &#x2014; Scaling factor for stage 1 to amplify the contributions of backbone features.",name:"b1"},{anchor:"diffusers.UNetMotionModel.enable_freeu.b2",description:"<strong>b2</strong> (<code>float</code>) &#x2014; Scaling factor for stage 2 to amplify the contributions of backbone features.",name:"b2"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L670"}}),F=new x({props:{name:"forward",anchor:"diffusers.UNetMotionModel.forward",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": Union"},{name:"encoder_hidden_states",val:": Tensor"},{name:"timestep_cond",val:": Optional = None"},{name:"attention_mask",val:": Optional = None"},{name:"cross_attention_kwargs",val:": Optional = None"},{name:"added_cond_kwargs",val:": Optional = None"},{name:"down_block_additional_residuals",val:": Optional = None"},{name:"mid_block_additional_residual",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.UNetMotionModel.forward.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The noisy input tensor with the following shape <code>(batch, num_frames, channel, height, width</code>.`,name:"sample"},{anchor:"diffusers.UNetMotionModel.forward.timestep",description:"<strong>timestep</strong> (<code>torch.FloatTensor</code> or <code>float</code> or <code>int</code>) &#x2014; The number of timesteps to denoise an input.",name:"timestep"},{anchor:"diffusers.UNetMotionModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code>) &#x2014;
The encoder hidden states with shape <code>(batch, sequence_length, feature_dim)</code>.
timestep_cond &#x2014; (<code>torch.Tensor</code>, <em>optional</em>, defaults to <code>None</code>):
Conditional embeddings for timestep. If provided, the embeddings will be summed with the samples passed
through the <code>self.time_embedding</code> layer to obtain the timestep embeddings.`,name:"encoder_hidden_states"},{anchor:"diffusers.UNetMotionModel.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.UNetMotionModel.forward.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.
down_block_additional_residuals &#x2014; (<code>tuple</code> of <code>torch.Tensor</code>, <em>optional</em>):
A tuple of tensors that if specified are added to the residuals of down unet blocks.
mid_block_additional_residual &#x2014; (<code>torch.Tensor</code>, <em>optional</em>):
A tensor that if specified is added to the residual of the middle unet block.`,name:"cross_attention_kwargs"},{anchor:"diffusers.UNetMotionModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~models.unet_3d_condition.UNet3DConditionOutput</code> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L703",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is True, an <code>~models.unet_3d_condition.UNet3DConditionOutput</code> is returned, otherwise
a <code>tuple</code> is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>~models.unet_3d_condition.UNet3DConditionOutput</code> or <code>tuple</code></p>
`}}),B=new x({props:{name:"freeze_unet2d_params",anchor:"diffusers.UNetMotionModel.freeze_unet2d_params",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L478"}}),V=new x({props:{name:"set_attn_processor",anchor:"diffusers.UNetMotionModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.UNetMotionModel.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/unets/unet_motion_model.py#L573"}}),j=new x({props:{name:"set_default_attn_processor",anchor:"diffusers.UNetMotionModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_motion_model.py#L650"}}),q=new je({props:{title:"UNet3DConditionOutput",local:"diffusers.models.unets.unet_3d_condition.UNet3DConditionOutput",headingTag:"h2"}}),R=new x({props:{name:"class diffusers.models.unets.unet_3d_condition.UNet3DConditionOutput",anchor:"diffusers.models.unets.unet_3d_condition.UNet3DConditionOutput",parameters:[{name:"sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.models.unets.unet_3d_condition.UNet3DConditionOutput.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, height, width)</code>) &#x2014;
The hidden states output conditioned on <code>encoder_hidden_states</code> input. Output of last layer of model.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/unets/unet_3d_condition.py#L51"}}),{c(){$=r("meta"),ae=n(),se=r("p"),ie=n(),u(L.$$.fragment),de=n(),P=r("p"),P.innerHTML=Re,le=n(),I=r("p"),I.textContent=We,ce=n(),O=r("p"),O.innerHTML=Ge,me=n(),u(H.$$.fragment),fe=n(),i=r("div"),u(A.$$.fragment),ke=n(),W=r("p"),W.textContent=Xe,ye=n(),G=r("p"),G.innerHTML=Je,Te=n(),k=r("div"),u(z.$$.fragment),Ue=n(),X=r("p"),X.textContent=Ke,Ne=n(),y=r("div"),u(S.$$.fragment),Ce=n(),J=r("p"),J.innerHTML=Qe,De=n(),f=r("div"),u(E.$$.fragment),Le=n(),K=r("p"),K.innerHTML=Ye,Pe=n(),Q=r("p"),Q.textContent=Ze,Ie=n(),Y=r("p"),Y.innerHTML=et,Oe=n(),T=r("div"),u(F.$$.fragment),He=n(),Z=r("p"),Z.innerHTML=tt,Ae=n(),U=r("div"),u(B.$$.fragment),ze=n(),ee=r("p"),ee.textContent=ot,Se=n(),N=r("div"),u(V.$$.fragment),Ee=n(),te=r("p"),te.textContent=nt,Fe=n(),C=r("div"),u(j.$$.fragment),Be=n(),oe=r("p"),oe.textContent=st,ue=n(),u(q.$$.fragment),pe=n(),M=r("div"),u(R.$$.fragment),Ve=n(),ne=r("p"),ne.innerHTML=rt,he=n(),re=r("p"),this.h()},l(e){const d=mt("svelte-u9bgzb",document.head);$=a(d,"META",{name:!0,content:!0}),d.forEach(o),ae=s(e),se=a(e,"P",{}),v(se).forEach(o),ie=s(e),p(L.$$.fragment,e),de=s(e),P=a(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-1gx5we1"&&(P.innerHTML=Re),le=s(e),I=a(e,"P",{"data-svelte-h":!0}),m(I)!=="svelte-1cwsb16"&&(I.textContent=We),ce=s(e),O=a(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-12epiox"&&(O.innerHTML=Ge),me=s(e),p(H.$$.fragment,e),fe=s(e),i=a(e,"DIV",{class:!0});var l=v(i);p(A.$$.fragment,l),ke=s(l),W=a(l,"P",{"data-svelte-h":!0}),m(W)!=="svelte-17nn7p8"&&(W.textContent=Xe),ye=s(l),G=a(l,"P",{"data-svelte-h":!0}),m(G)!=="svelte-1hyu2ru"&&(G.innerHTML=Je),Te=s(l),k=a(l,"DIV",{class:!0});var _e=v(k);p(z.$$.fragment,_e),Ue=s(_e),X=a(_e,"P",{"data-svelte-h":!0}),m(X)!=="svelte-1d0rkng"&&(X.textContent=Ke),_e.forEach(o),Ne=s(l),y=a(l,"DIV",{class:!0});var be=v(y);p(S.$$.fragment,be),Ce=s(be),J=a(be,"P",{"data-svelte-h":!0}),m(J)!=="svelte-2m23sy"&&(J.innerHTML=Qe),be.forEach(o),De=s(l),f=a(l,"DIV",{class:!0});var D=v(f);p(E.$$.fragment,D),Le=s(D),K=a(D,"P",{"data-svelte-h":!0}),m(K)!=="svelte-4p7kn0"&&(K.innerHTML=Ye),Pe=s(D),Q=a(D,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-1t9gjdi"&&(Q.textContent=Ze),Ie=s(D),Y=a(D,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-tw05zf"&&(Y.innerHTML=et),D.forEach(o),Oe=s(l),T=a(l,"DIV",{class:!0});var ve=v(T);p(F.$$.fragment,ve),He=s(ve),Z=a(ve,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-h4la7u"&&(Z.innerHTML=tt),ve.forEach(o),Ae=s(l),U=a(l,"DIV",{class:!0});var we=v(U);p(B.$$.fragment,we),ze=s(we),ee=a(we,"P",{"data-svelte-h":!0}),m(ee)!=="svelte-os6vgi"&&(ee.textContent=ot),we.forEach(o),Se=s(l),N=a(l,"DIV",{class:!0});var $e=v(N);p(V.$$.fragment,$e),Ee=s($e),te=a($e,"P",{"data-svelte-h":!0}),m(te)!=="svelte-1o77hl2"&&(te.textContent=nt),$e.forEach(o),Fe=s(l),C=a(l,"DIV",{class:!0});var Me=v(C);p(j.$$.fragment,Me),Be=s(Me),oe=a(Me,"P",{"data-svelte-h":!0}),m(oe)!=="svelte-1lxcwhv"&&(oe.textContent=st),Me.forEach(o),l.forEach(o),ue=s(e),p(q.$$.fragment,e),pe=s(e),M=a(e,"DIV",{class:!0});var xe=v(M);p(R.$$.fragment,xe),Ve=s(xe),ne=a(xe,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-njpr7n"&&(ne.innerHTML=rt),xe.forEach(o),he=s(e),re=a(e,"P",{}),v(re).forEach(o),this.h()},h(){w($,"name","hf:doc:metadata"),w($,"content",ut),w(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(M,"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,d){t(document.head,$),c(e,ae,d),c(e,se,d),c(e,ie,d),h(L,e,d),c(e,de,d),c(e,P,d),c(e,le,d),c(e,I,d),c(e,ce,d),c(e,O,d),c(e,me,d),h(H,e,d),c(e,fe,d),c(e,i,d),h(A,i,null),t(i,ke),t(i,W),t(i,ye),t(i,G),t(i,Te),t(i,k),h(z,k,null),t(k,Ue),t(k,X),t(i,Ne),t(i,y),h(S,y,null),t(y,Ce),t(y,J),t(i,De),t(i,f),h(E,f,null),t(f,Le),t(f,K),t(f,Pe),t(f,Q),t(f,Ie),t(f,Y),t(i,Oe),t(i,T),h(F,T,null),t(T,He),t(T,Z),t(i,Ae),t(i,U),h(B,U,null),t(U,ze),t(U,ee),t(i,Se),t(i,N),h(V,N,null),t(N,Ee),t(N,te),t(i,Fe),t(i,C),h(j,C,null),t(C,Be),t(C,oe),c(e,ue,d),h(q,e,d),c(e,pe,d),c(e,M,d),h(R,M,null),t(M,Ve),t(M,ne),c(e,he,d),c(e,re,d),ge=!0},p:it,i(e){ge||(g(L.$$.fragment,e),g(H.$$.fragment,e),g(A.$$.fragment,e),g(z.$$.fragment,e),g(S.$$.fragment,e),g(E.$$.fragment,e),g(F.$$.fragment,e),g(B.$$.fragment,e),g(V.$$.fragment,e),g(j.$$.fragment,e),g(q.$$.fragment,e),g(R.$$.fragment,e),ge=!0)},o(e){_(L.$$.fragment,e),_(H.$$.fragment,e),_(A.$$.fragment,e),_(z.$$.fragment,e),_(S.$$.fragment,e),_(E.$$.fragment,e),_(F.$$.fragment,e),_(B.$$.fragment,e),_(V.$$.fragment,e),_(j.$$.fragment,e),_(q.$$.fragment,e),_(R.$$.fragment,e),ge=!1},d(e){e&&(o(ae),o(se),o(ie),o(de),o(P),o(le),o(I),o(ce),o(O),o(me),o(fe),o(i),o(ue),o(pe),o(M),o(he),o(re)),o($),b(L,e),b(H,e),b(A),b(z),b(S),b(E),b(F),b(B),b(V),b(j),b(q,e),b(R)}}}const ut='{"title":"UNetMotionModel","local":"unetmotionmodel","sections":[{"title":"UNetMotionModel","local":"diffusers.UNetMotionModel","sections":[],"depth":2},{"title":"UNet3DConditionOutput","local":"diffusers.models.unets.unet_3d_condition.UNet3DConditionOutput","sections":[],"depth":2}],"depth":1}';function pt(qe){return dt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vt extends lt{constructor($){super(),ct(this,$,pt,ft,at,{})}}export{vt as component};
