Buckets:
| import{s as Be,o as ze,n as Je}from"../chunks/scheduler.53228c21.js";import{S as Re,i as Ie,e as c,s,c as h,h as Ge,a as l,d as t,b as r,f as A,g,j as D,k as E,l as o,m as d,n as _,t as b,o as v,p as y}from"../chunks/index.cac5d66a.js";import{C as Ne}from"../chunks/CopyLLMTxtMenu.d3355f38.js";import{D as Q}from"../chunks/Docstring.41979c71.js";import{C as Pe}from"../chunks/CodeBlock.606cbaf4.js";import{E as He}from"../chunks/ExampleCodeBlock.cbf08b0e.js";import{H as We,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e4b76f09.js";function Ye(ee){let m,j="Examples:",x,u,f;return u=new Pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBDb25zaXN0ZW5jeURlY29kZXJWQUUlMEElMEF2YWUlMjAlM0QlMjBDb25zaXN0ZW5jeURlY29kZXJWQUUuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5haSUyRmNvbnNpc3RlbmN5LWRlY29kZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB2YWUlM0R2YWUlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKCUyMmhvcnNlJTIyJTJDJTIwZ2VuZXJhdG9yJTNEdG9yY2gubWFudWFsX3NlZWQoMCkpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, ConsistencyDecoderVAE | |
| <span class="hljs-meta">>>> </span>vae = ConsistencyDecoderVAE.from_pretrained(<span class="hljs-string">"openai/consistency-decoder"</span>, torch_dtype=torch.float16) | |
| <span class="hljs-meta">>>> </span>pipe = StableDiffusionPipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"stable-diffusion-v1-5/stable-diffusion-v1-5"</span>, vae=vae, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>image = pipe(<span class="hljs-string">"horse"</span>, generator=torch.manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image`,lang:"py",wrap:!1}}),{c(){m=c("p"),m.textContent=j,x=s(),h(u.$$.fragment)},l(i){m=l(i,"P",{"data-svelte-h":!0}),D(m)!=="svelte-kvfsh7"&&(m.textContent=j),x=r(i),g(u.$$.fragment,i)},m(i,$){d(i,m,$),d(i,x,$),_(u,i,$),f=!0},p:Je,i(i){f||(b(u.$$.fragment,i),f=!0)},o(i){v(u.$$.fragment,i),f=!1},d(i){i&&(t(m),t(x)),y(u,i)}}}function qe(ee){let m,j,x,u,f,i,$,te,U,Ee='Consistency decoder can be used to decode the latents from the denoising UNet in the <a href="/docs/diffusers/pr_13803/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>.',ne,L,we='The original codebase can be found at <a href="https://github.com/openai/consistencydecoder" rel="nofollow">openai/consistencydecoder</a>.',oe,w,Te="<p>Inference is only supported for 2 iterations as of now.</p>",se,Z,Me='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>.',re,W,ae,a,B,ue,P,Ve="The consistency decoder used with DALL-E 3.",fe,T,he,M,z,ge,H,ke="Decodes the input latent vector <code>z</code> using the consistency decoder VAE model.",_e,V,J,be,F,Ae="Encode a batch of images into latents.",ve,Y,R,ye,k,I,$e,q,je="Disables custom attention processors and sets the default attention implementation.",De,C,G,xe,O,Ue="Encode a batch of images using a tiled encoder.",Ce,S,Le=`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.`,ce,N,le,K,de;return f=new Ne({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new We({props:{title:"Consistency Decoder",local:"consistency-decoder",headingTag:"h1"}}),W=new We({props:{title:"ConsistencyDecoderVAE",local:"diffusers.ConsistencyDecoderVAE",headingTag:"h2"}}),B=new Q({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:": tuple = (128, 256, 512, 512)"},{name:"encoder_double_z",val:": bool = True"},{name:"encoder_down_block_types",val:": tuple = ('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:": tuple = (320, 640, 1024, 1024)"},{name:"decoder_down_block_types",val:": tuple = ('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:": tuple = ('ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D', 'ResnetUpsampleBlock2D')"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L51"}}),T=new He({props:{anchor:"diffusers.ConsistencyDecoderVAE.example",$$slots:{default:[Ye]},$$scope:{ctx:ee}}}),z=new Q({props:{name:"decode",anchor:"diffusers.ConsistencyDecoderVAE.decode",parameters:[{name:"z",val:": Tensor"},{name:"generator",val:": torch._C.Generator | None = None"},{name:"return_dict",val:": bool = True"},{name:"num_inference_steps",val:": int = 2"}],parametersDescription:[{anchor:"diffusers.ConsistencyDecoderVAE.decode.z",description:"<strong>z</strong> (torch.Tensor) — The input latent vector.",name:"z"},{anchor:"diffusers.ConsistencyDecoderVAE.decode.generator",description:"<strong>generator</strong> (torch.Generator | None) — The random number generator. Default is None.",name:"generator"},{anchor:"diffusers.ConsistencyDecoderVAE.decode.return_dict",description:"<strong>return_dict</strong> (bool) — Whether to return the output as a dictionary. Default is True.",name:"return_dict"},{anchor:"diffusers.ConsistencyDecoderVAE.decode.num_inference_steps",description:"<strong>num_inference_steps</strong> (int) — The number of inference steps. Default is 2.",name:"num_inference_steps"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L220",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The decoded output.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>DecoderOutput | tuple[torch.Tensor]</p> | |
| `}}),J=new Q({props:{name:"encode",anchor:"diffusers.ConsistencyDecoderVAE.encode",parameters:[{name:"x",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.ConsistencyDecoderVAE.encode.x",description:"<strong>x</strong> (<code>torch.Tensor</code>) — Input batch of images.",name:"x"},{anchor:"diffusers.ConsistencyDecoderVAE.encode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to return a <code>ConsistencyDecoderVAEOutput</code> | |
| instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L185",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The latent representations of the encoded images. If <code>return_dict</code> is True, a | |
| <code>ConsistencyDecoderVAEOutput</code> is returned, otherwise a | |
| plain <code>tuple</code> is returned.</p> | |
| `}}),R=new Q({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:": torch._C.Generator | None = None"}],parametersDescription:[{anchor:"diffusers.ConsistencyDecoderVAE.forward.sample",description:"<strong>sample</strong> (<code>torch.Tensor</code>) — 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>) — | |
| 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>) — | |
| 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>) — | |
| Generator to use for sampling.`,name:"generator"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L336",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> | |
| `}}),I=new Q({props:{name:"set_default_attn_processor",anchor:"diffusers.ConsistencyDecoderVAE.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L170"}}),G=new Q({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>) — 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>) — | |
| Whether or not to return a <code>ConsistencyDecoderVAEOutput</code> | |
| instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/consistency_decoder_vae.py#L281",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> | |
| `}}),N=new Fe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/consistency_decoder_vae.md"}}),{c(){m=c("meta"),j=s(),x=c("p"),u=s(),h(f.$$.fragment),i=s(),h($.$$.fragment),te=s(),U=c("p"),U.innerHTML=Ee,ne=s(),L=c("p"),L.innerHTML=we,oe=s(),w=c("blockquote"),w.innerHTML=Te,se=s(),Z=c("p"),Z.innerHTML=Me,re=s(),h(W.$$.fragment),ae=s(),a=c("div"),h(B.$$.fragment),ue=s(),P=c("p"),P.textContent=Ve,fe=s(),h(T.$$.fragment),he=s(),M=c("div"),h(z.$$.fragment),ge=s(),H=c("p"),H.innerHTML=ke,_e=s(),V=c("div"),h(J.$$.fragment),be=s(),F=c("p"),F.textContent=Ae,ve=s(),Y=c("div"),h(R.$$.fragment),ye=s(),k=c("div"),h(I.$$.fragment),$e=s(),q=c("p"),q.textContent=je,De=s(),C=c("div"),h(G.$$.fragment),xe=s(),O=c("p"),O.textContent=Ue,Ce=s(),S=c("p"),S.textContent=Le,ce=s(),h(N.$$.fragment),le=s(),K=c("p"),this.h()},l(e){const n=Ge("svelte-u9bgzb",document.head);m=l(n,"META",{name:!0,content:!0}),n.forEach(t),j=r(e),x=l(e,"P",{}),A(x).forEach(t),u=r(e),g(f.$$.fragment,e),i=r(e),g($.$$.fragment,e),te=r(e),U=l(e,"P",{"data-svelte-h":!0}),D(U)!=="svelte-1e9m1d0"&&(U.innerHTML=Ee),ne=r(e),L=l(e,"P",{"data-svelte-h":!0}),D(L)!=="svelte-uyyo7l"&&(L.innerHTML=we),oe=r(e),w=l(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),D(w)!=="svelte-1mg82lp"&&(w.innerHTML=Te),se=r(e),Z=l(e,"P",{"data-svelte-h":!0}),D(Z)!=="svelte-1ln42ze"&&(Z.innerHTML=Me),re=r(e),g(W.$$.fragment,e),ae=r(e),a=l(e,"DIV",{class:!0});var p=A(a);g(B.$$.fragment,p),ue=r(p),P=l(p,"P",{"data-svelte-h":!0}),D(P)!=="svelte-1fvfwaa"&&(P.textContent=Ve),fe=r(p),g(T.$$.fragment,p),he=r(p),M=l(p,"DIV",{class:!0});var ie=A(M);g(z.$$.fragment,ie),ge=r(ie),H=l(ie,"P",{"data-svelte-h":!0}),D(H)!=="svelte-102xafe"&&(H.innerHTML=ke),ie.forEach(t),_e=r(p),V=l(p,"DIV",{class:!0});var pe=A(V);g(J.$$.fragment,pe),be=r(pe),F=l(pe,"P",{"data-svelte-h":!0}),D(F)!=="svelte-h5bpgz"&&(F.textContent=Ae),pe.forEach(t),ve=r(p),Y=l(p,"DIV",{class:!0});var Ze=A(Y);g(R.$$.fragment,Ze),Ze.forEach(t),ye=r(p),k=l(p,"DIV",{class:!0});var me=A(k);g(I.$$.fragment,me),$e=r(me),q=l(me,"P",{"data-svelte-h":!0}),D(q)!=="svelte-1lxcwhv"&&(q.textContent=je),me.forEach(t),De=r(p),C=l(p,"DIV",{class:!0});var X=A(C);g(G.$$.fragment,X),xe=r(X),O=l(X,"P",{"data-svelte-h":!0}),D(O)!=="svelte-1un5fcn"&&(O.textContent=Ue),Ce=r(X),S=l(X,"P",{"data-svelte-h":!0}),D(S)!=="svelte-lbfkqr"&&(S.textContent=Le),X.forEach(t),p.forEach(t),ce=r(e),g(N.$$.fragment,e),le=r(e),K=l(e,"P",{}),A(K).forEach(t),this.h()},h(){E(m,"name","hf:doc:metadata"),E(m,"content",Oe),E(w,"class","warning"),E(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(a,"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){o(document.head,m),d(e,j,n),d(e,x,n),d(e,u,n),_(f,e,n),d(e,i,n),_($,e,n),d(e,te,n),d(e,U,n),d(e,ne,n),d(e,L,n),d(e,oe,n),d(e,w,n),d(e,se,n),d(e,Z,n),d(e,re,n),_(W,e,n),d(e,ae,n),d(e,a,n),_(B,a,null),o(a,ue),o(a,P),o(a,fe),_(T,a,null),o(a,he),o(a,M),_(z,M,null),o(M,ge),o(M,H),o(a,_e),o(a,V),_(J,V,null),o(V,be),o(V,F),o(a,ve),o(a,Y),_(R,Y,null),o(a,ye),o(a,k),_(I,k,null),o(k,$e),o(k,q),o(a,De),o(a,C),_(G,C,null),o(C,xe),o(C,O),o(C,Ce),o(C,S),d(e,ce,n),_(N,e,n),d(e,le,n),d(e,K,n),de=!0},p(e,[n]){const p={};n&2&&(p.$$scope={dirty:n,ctx:e}),T.$set(p)},i(e){de||(b(f.$$.fragment,e),b($.$$.fragment,e),b(W.$$.fragment,e),b(B.$$.fragment,e),b(T.$$.fragment,e),b(z.$$.fragment,e),b(J.$$.fragment,e),b(R.$$.fragment,e),b(I.$$.fragment,e),b(G.$$.fragment,e),b(N.$$.fragment,e),de=!0)},o(e){v(f.$$.fragment,e),v($.$$.fragment,e),v(W.$$.fragment,e),v(B.$$.fragment,e),v(T.$$.fragment,e),v(z.$$.fragment,e),v(J.$$.fragment,e),v(R.$$.fragment,e),v(I.$$.fragment,e),v(G.$$.fragment,e),v(N.$$.fragment,e),de=!1},d(e){e&&(t(j),t(x),t(u),t(i),t(te),t(U),t(ne),t(L),t(oe),t(w),t(se),t(Z),t(re),t(ae),t(a),t(ce),t(le),t(K)),t(m),y(f,e),y($,e),y(W,e),y(B),y(T),y(z),y(J),y(R),y(I),y(G),y(N,e)}}}const Oe='{"title":"Consistency Decoder","local":"consistency-decoder","sections":[{"title":"ConsistencyDecoderVAE","local":"diffusers.ConsistencyDecoderVAE","sections":[],"depth":2}],"depth":1}';function Se(ee){return ze(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class st extends Re{constructor(m){super(),Ie(this,m,Se,qe,Be,{})}}export{st as component}; | |
Xet Storage Details
- Size:
- 17.1 kB
- Xet hash:
- 5868de9b85f5f72baaa2b9af8bd575e000ecedef58829fae4e9d4e2858043056
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.