import{s as Me,o as Te,n as ke}from"../chunks/scheduler.53228c21.js";import{S as je,i as Ve,e as p,s,c as h,h as Ue,a as m,d as t,b as o,f as I,g as _,j as x,k as T,l as i,m as r,n as b,t as v,o as $,p as y}from"../chunks/index.100fac89.js";import{C as Ae}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as S}from"../chunks/Docstring.49101787.js";import{C as Ze}from"../chunks/CodeBlock.d30a6509.js";import{E as Le}from"../chunks/ExampleCodeBlock.4a9effb9.js";import{H as Ee,E as Be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function We(X){let c,k="Examples:",D,u,f;return u=new Ze({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBDb25zaXN0ZW5jeURlY29kZXJWQUUlMEElMEF2YWUlMjAlM0QlMjBDb25zaXN0ZW5jeURlY29kZXJWQUUuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haSUyRmNvbnNpc3RlbmN5LWRlY29kZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB2YWUlM0R2YWUlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKCUyMmhvcnNlJTIyJTJDJTIwZ2VuZXJhdG9yJTNEdG9yY2gubWFudWFsX3NlZWQoMCkpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, ConsistencyDecoderVAE

<span class="hljs-meta">&gt;&gt;&gt; </span>vae = ConsistencyDecoderVAE.from_pretrained(<span class="hljs-string">&quot;openai/consistency-decoder&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, vae=vae, torch_dtype=torch.float16
<span class="hljs-meta">... </span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(<span class="hljs-string">&quot;horse&quot;</span>, generator=torch.manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image`,wrap:!1}}),{c(){c=p("p"),c.textContent=k,D=s(),h(u.$$.fragment)},l(a){c=m(a,"P",{"data-svelte-h":!0}),x(c)!=="svelte-kvfsh7"&&(c.textContent=k),D=o(a),_(u.$$.fragment,a)},m(a,g){r(a,c,g),r(a,D,g),b(u,a,g),f=!0},p:ke,i(a){f||(v(u.$$.fragment,a),f=!0)},o(a){$(u.$$.fragment,a),f=!1},d(a){a&&(t(c),t(D)),y(u,a)}}}function Je(X){let c,k,D,u,f,a,g,O,j,he='Consistency decoder can be used to decode the latents from the denoising UNet in the <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a>. This decoder was introduced in the <a href="https://openai.com/dall-e-3" rel="nofollow">DALL-E 3 technical report</a>.',Q,V,_e='The original codebase can be found at <a href="https://github.com/openai/consistencydecoder" rel="nofollow">openai/consistencydecoder</a>.',K,C,be="<p>Inference is only supported for 2 iterations as of now.</p>",ee,U,ve='The pipeline could not have been contributed without the help of <a href="https://github.com/madebyollin" rel="nofollow">madebyollin</a> and <a href="https://github.com/mrsteyk" rel="nofollow">mrsteyk</a> from <a href="https://github.com/openai/consistencydecoder/issues/1" rel="nofollow">this issue</a>.',te,A,ne,l,Z,le,z,$e="The consistency decoder used with DALL-E 3.",ie,E,ce,G,L,de,P,B,pe,M,W,me,F,ye="Disables custom attention processors and sets the default attention implementation.",ue,w,J,fe,H,De="Encode a batch of images using a tiled encoder.",ge,N,we=`When this option is enabled, the VAE will split the input tensor into tiles to compute encoding in several
steps. This is useful to keep memory use constant regardless of image size. The end result of tiled encoding is
different from non-tiled encoding because each tile uses a different encoder. To avoid tiling artifacts, the
tiles overlap and are blended together to form a smooth output. You may still see tile-sized changes in the
output, but they should be much less noticeable.`,se,R,oe,q,re;return f=new Ae({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),g=new Ee({props:{title:"Consistency Decoder",local:"consistency-decoder",headingTag:"h1"}}),A=new Ee({props:{title:"ConsistencyDecoderVAE",local:"diffusers.ConsistencyDecoderVAE",headingTag:"h2"}}),Z=new S({props:{name:"class diffusers.ConsistencyDecoderVAE",anchor:"diffusers.ConsistencyDecoderVAE",parameters:[{name:"scaling_factor",val:": float = 0.18215"},{name:"latent_channels",val:": int = 4"},{name:"sample_size",val:": int = 32"},{name:"encoder_act_fn",val:": str = 'silu'"},{name:"encoder_block_out_channels",val:": typing.Tuple[int, ...] = (128, 256, 512, 512)"},{name:"encoder_double_z",val:": bool = True"},{name:"encoder_down_block_types",val:": typing.Tuple[str, ...] = ('DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D', 'DownEncoderBlock2D')"},{name:"encoder_in_channels",val:": int = 3"},{name:"encoder_layers_per_block",val:": int = 2"},{name:"encoder_norm_num_groups",val:": int = 32"},{name:"encoder_out_channels",val:": int = 4"},{name:"decoder_add_attention",val:": bool = False"},{name:"decoder_block_out_channels",val:": typing.Tuple[int, ...] = (320, 640, 1024, 1024)"},{name:"decoder_down_block_types",val:": typing.Tuple[str, ...] = ('ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D', 'ResnetDownsampleBlock2D')"},{name:"decoder_downsample_padding",val:": int = 1"},{name:"decoder_in_channels",val:": int = 7"},{name:"decoder_layers_per_block",val:": int = 3"},{name:"decoder_norm_eps",val:": float = 1e-05"},{name:"decoder_norm_num_groups",val:": int = 32"},{name:"decoder_num_train_timesteps",val:": int = 1024"},{name:"decoder_out_channels",val:": int = 6"},{name:"decoder_resnet_time_scale_shift",val:": str = 'scale_shift'"},{name:"decoder_time_embedding_type",val:": str = 'learned'"},{name:"decoder_up_block_types",val:": typing.Tuple[str, ...] = ('ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D')"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L52"}}),E=new Le({props:{anchor:"diffusers.ConsistencyDecoderVAE.example",$$slots:{default:[We]},$$scope:{ctx:X}}}),L=new S({props:{name:"wrapper",anchor:"diffusers.ConsistencyDecoderVAE.decode",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/accelerate_utils.py#L43"}}),B=new S({props:{name:"forward",anchor:"diffusers.ConsistencyDecoderVAE.forward",parameters:[{name:"sample",val:": Tensor"},{name:"sample_posterior",val:": bool = False"},{name:"return_dict",val:": bool = True"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"}],parametersDescription:[{anchor:"diffusers.ConsistencyDecoderVAE.forward.sample",description:"<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014; Input sample.",name:"sample"},{anchor:"diffusers.ConsistencyDecoderVAE.forward.sample_posterior",description:`<strong>sample_posterior</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to sample from the posterior.`,name:"sample_posterior"},{anchor:"diffusers.ConsistencyDecoderVAE.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>DecoderOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.ConsistencyDecoderVAE.forward.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Generator to use for sampling.`,name:"generator"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L337",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is True, a <code>DecoderOutput</code> is returned, otherwise a plain <code>tuple</code> is returned.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>DecoderOutput</code> or <code>tuple</code></p>
`}}),W=new S({props:{name:"set_default_attn_processor",anchor:"diffusers.ConsistencyDecoderVAE.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L171"}}),J=new S({props:{name:"tiled_encode",anchor:"diffusers.ConsistencyDecoderVAE.tiled_encode",parameters:[{name:"x",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.ConsistencyDecoderVAE.tiled_encode.x",description:"<strong>x</strong> (<code>torch.Tensor</code>) &#x2014; Input batch of images.",name:"x"},{anchor:"diffusers.ConsistencyDecoderVAE.tiled_encode.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>ConsistencyDecoderVAEOutput</code>
instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L282",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is True, a <code>ConsistencyDecoderVAEOutput</code>
is returned, otherwise a plain <code>tuple</code> is returned.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ConsistencyDecoderVAEOutput</code> or <code>tuple</code></p>
`}}),R=new Be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/consistency_decoder_vae.md"}}),{c(){c=p("meta"),k=s(),D=p("p"),u=s(),h(f.$$.fragment),a=s(),h(g.$$.fragment),O=s(),j=p("p"),j.innerHTML=he,Q=s(),V=p("p"),V.innerHTML=_e,K=s(),C=p("blockquote"),C.innerHTML=be,ee=s(),U=p("p"),U.innerHTML=ve,te=s(),h(A.$$.fragment),ne=s(),l=p("div"),h(Z.$$.fragment),le=s(),z=p("p"),z.textContent=$e,ie=s(),h(E.$$.fragment),ce=s(),G=p("div"),h(L.$$.fragment),de=s(),P=p("div"),h(B.$$.fragment),pe=s(),M=p("div"),h(W.$$.fragment),me=s(),F=p("p"),F.textContent=ye,ue=s(),w=p("div"),h(J.$$.fragment),fe=s(),H=p("p"),H.textContent=De,ge=s(),N=p("p"),N.textContent=we,se=s(),h(R.$$.fragment),oe=s(),q=p("p"),this.h()},l(e){const n=Ue("svelte-u9bgzb",document.head);c=m(n,"META",{name:!0,content:!0}),n.forEach(t),k=o(e),D=m(e,"P",{}),I(D).forEach(t),u=o(e),_(f.$$.fragment,e),a=o(e),_(g.$$.fragment,e),O=o(e),j=m(e,"P",{"data-svelte-h":!0}),x(j)!=="svelte-1ttox57"&&(j.innerHTML=he),Q=o(e),V=m(e,"P",{"data-svelte-h":!0}),x(V)!=="svelte-uyyo7l"&&(V.innerHTML=_e),K=o(e),C=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),x(C)!=="svelte-1mg82lp"&&(C.innerHTML=be),ee=o(e),U=m(e,"P",{"data-svelte-h":!0}),x(U)!=="svelte-1ln42ze"&&(U.innerHTML=ve),te=o(e),_(A.$$.fragment,e),ne=o(e),l=m(e,"DIV",{class:!0});var d=I(l);_(Z.$$.fragment,d),le=o(d),z=m(d,"P",{"data-svelte-h":!0}),x(z)!=="svelte-1fvfwaa"&&(z.textContent=$e),ie=o(d),_(E.$$.fragment,d),ce=o(d),G=m(d,"DIV",{class:!0});var xe=I(G);_(L.$$.fragment,xe),xe.forEach(t),de=o(d),P=m(d,"DIV",{class:!0});var Ce=I(P);_(B.$$.fragment,Ce),Ce.forEach(t),pe=o(d),M=m(d,"DIV",{class:!0});var ae=I(M);_(W.$$.fragment,ae),me=o(ae),F=m(ae,"P",{"data-svelte-h":!0}),x(F)!=="svelte-1lxcwhv"&&(F.textContent=ye),ae.forEach(t),ue=o(d),w=m(d,"DIV",{class:!0});var Y=I(w);_(J.$$.fragment,Y),fe=o(Y),H=m(Y,"P",{"data-svelte-h":!0}),x(H)!=="svelte-1un5fcn"&&(H.textContent=De),ge=o(Y),N=m(Y,"P",{"data-svelte-h":!0}),x(N)!=="svelte-lbfkqr"&&(N.textContent=we),Y.forEach(t),d.forEach(t),se=o(e),_(R.$$.fragment,e),oe=o(e),q=m(e,"P",{}),I(q).forEach(t),this.h()},h(){T(c,"name","hf:doc:metadata"),T(c,"content",Re),T(C,"class","warning"),T(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(l,"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,n){i(document.head,c),r(e,k,n),r(e,D,n),r(e,u,n),b(f,e,n),r(e,a,n),b(g,e,n),r(e,O,n),r(e,j,n),r(e,Q,n),r(e,V,n),r(e,K,n),r(e,C,n),r(e,ee,n),r(e,U,n),r(e,te,n),b(A,e,n),r(e,ne,n),r(e,l,n),b(Z,l,null),i(l,le),i(l,z),i(l,ie),b(E,l,null),i(l,ce),i(l,G),b(L,G,null),i(l,de),i(l,P),b(B,P,null),i(l,pe),i(l,M),b(W,M,null),i(M,me),i(M,F),i(l,ue),i(l,w),b(J,w,null),i(w,fe),i(w,H),i(w,ge),i(w,N),r(e,se,n),b(R,e,n),r(e,oe,n),r(e,q,n),re=!0},p(e,[n]){const d={};n&2&&(d.$$scope={dirty:n,ctx:e}),E.$set(d)},i(e){re||(v(f.$$.fragment,e),v(g.$$.fragment,e),v(A.$$.fragment,e),v(Z.$$.fragment,e),v(E.$$.fragment,e),v(L.$$.fragment,e),v(B.$$.fragment,e),v(W.$$.fragment,e),v(J.$$.fragment,e),v(R.$$.fragment,e),re=!0)},o(e){$(f.$$.fragment,e),$(g.$$.fragment,e),$(A.$$.fragment,e),$(Z.$$.fragment,e),$(E.$$.fragment,e),$(L.$$.fragment,e),$(B.$$.fragment,e),$(W.$$.fragment,e),$(J.$$.fragment,e),$(R.$$.fragment,e),re=!1},d(e){e&&(t(k),t(D),t(u),t(a),t(O),t(j),t(Q),t(V),t(K),t(C),t(ee),t(U),t(te),t(ne),t(l),t(se),t(oe),t(q)),t(c),y(f,e),y(g,e),y(A,e),y(Z),y(E),y(L),y(B),y(W),y(J),y(R,e)}}}const Re='{"title":"Consistency Decoder","local":"consistency-decoder","sections":[{"title":"ConsistencyDecoderVAE","local":"diffusers.ConsistencyDecoderVAE","sections":[],"depth":2}],"depth":1}';function Ie(X){return Te(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends je{constructor(c){super(),Ve(this,c,Ie,Je,Me,{})}}export{qe as component};
