import{s as Be,n as Ve,o as Ge}from"../chunks/scheduler.53228c21.js";import{S as Ie,i as Xe,e as l,s as o,c as u,h as Re,a as c,d as n,b as s,f as G,g as f,j as _,k as I,l as i,m as a,n as p,t as m,o as h,p as g}from"../chunks/index.100fac89.js";import{C as Se}from"../chunks/CopyLLMTxtMenu.20a72e0e.js";import{D as F}from"../chunks/Docstring.49101787.js";import{C as je}from"../chunks/CodeBlock.d30a6509.js";import{H as ve,E as De}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.4d82655d.js";function Ne($e){let y,P,q,Q,v,H,$,O,M,Me='Tiny AutoEncoder for Stable Diffusion (TAESD) was introduced in <a href="https://github.com/madebyollin/taesd" rel="nofollow">madebyollin/taesd</a> by Ollin Boer Bohan. It is a tiny distilled version of Stable Diffusion’s VAE that can quickly decode the latents in a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> or <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline">StableDiffusionXLPipeline</a> almost instantly.',K,x,xe="To use with Stable Diffusion v-2.1:",ee,U,te,J,Ue="To use with Stable Diffusion XL 1.0",ne,Z,oe,k,se,r,C,pe,X,Je="A tiny distilled VAE model for encoding images into latents and decoding latent representations into images.",me,R,Ze='<a href="/docs/diffusers/main/en/api/models/autoencoder_tiny#diffusers.AutoencoderTiny">AutoencoderTiny</a> is a wrapper around the original implementation of <code>TAESD</code>.',he,S,ke=`This model inherits from <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin">ModelMixin</a>. Check the superclass documentation for its generic methods implemented for
all models (such as downloading or saving).`,ge,D,A,ye,T,E,be,N,Ce="raw latents -> [0, 1]",_e,w,W,Te,z,Ae="[0, 1] -> raw latents",ae,j,re,b,B,we,Y,Ee="Output of AutoencoderTiny encoding method.",ie,V,le,L,ce;return v=new Se({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new ve({props:{title:"Tiny AutoEncoder",local:"tiny-autoencoder",headingTag:"h1"}}),U=new je({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBBdXRvZW5jb2RlclRpbnklMEElMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi0yLTEtYmFzZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlLnZhZSUyMCUzRCUyMEF1dG9lbmNvZGVyVGlueS5mcm9tX3ByZXRyYWluZWQoJTIybWFkZWJ5b2xsaW4lMkZ0YWVzZCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMnNsaWNlJTIwb2YlMjBkZWxpY2lvdXMlMjBOZXclMjBZb3JrLXN0eWxlJTIwYmVycnklMjBjaGVlc2VjYWtlJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyNSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, AutoencoderTiny

pipe = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1-base&quot;</span>, torch_dtype=torch.float16
)
pipe.vae = AutoencoderTiny.from_pretrained(<span class="hljs-string">&quot;madebyollin/taesd&quot;</span>, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;slice of delicious New York-style berry cheesecake&quot;</span>
image = pipe(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),Z=new je({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBBdXRvZW5jb2RlclRpbnklMEElMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlLnZhZSUyMCUzRCUyMEF1dG9lbmNvZGVyVGlueS5mcm9tX3ByZXRyYWluZWQoJTIybWFkZWJ5b2xsaW4lMkZ0YWVzZHhsJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyc2xpY2UlMjBvZiUyMGRlbGljaW91cyUyME5ldyUyMFlvcmstc3R5bGUlMjBiZXJyeSUyMGNoZWVzZWNha2UlMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI1KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, AutoencoderTiny

pipe = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
)
pipe.vae = AutoencoderTiny.from_pretrained(<span class="hljs-string">&quot;madebyollin/taesdxl&quot;</span>, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;slice of delicious New York-style berry cheesecake&quot;</span>
image = pipe(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),k=new ve({props:{title:"AutoencoderTiny",local:"diffusers.AutoencoderTiny",headingTag:"h2"}}),C=new F({props:{name:"class diffusers.AutoencoderTiny",anchor:"diffusers.AutoencoderTiny",parameters:[{name:"in_channels",val:": int = 3"},{name:"out_channels",val:": int = 3"},{name:"encoder_block_out_channels",val:": typing.Tuple[int, ...] = (64, 64, 64, 64)"},{name:"decoder_block_out_channels",val:": typing.Tuple[int, ...] = (64, 64, 64, 64)"},{name:"act_fn",val:": str = 'relu'"},{name:"upsample_fn",val:": str = 'nearest'"},{name:"latent_channels",val:": int = 4"},{name:"upsampling_scaling_factor",val:": int = 2"},{name:"num_encoder_blocks",val:": typing.Tuple[int, ...] = (1, 3, 3, 3)"},{name:"num_decoder_blocks",val:": typing.Tuple[int, ...] = (3, 3, 3, 1)"},{name:"latent_magnitude",val:": int = 3"},{name:"latent_shift",val:": float = 0.5"},{name:"force_upcast",val:": bool = False"},{name:"scaling_factor",val:": float = 1.0"},{name:"shift_factor",val:": float = 0.0"}],parametersDescription:[{anchor:"diffusers.AutoencoderTiny.in_channels",description:"<strong>in_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014; Number of channels in the input image.",name:"in_channels"},{anchor:"diffusers.AutoencoderTiny.out_channels",description:"<strong>out_channels</strong> (<code>int</code>,  <em>optional</em>, defaults to 3) &#x2014; Number of channels in the output.",name:"out_channels"},{anchor:"diffusers.AutoencoderTiny.encoder_block_out_channels",description:`<strong>encoder_block_out_channels</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(64, 64, 64, 64)</code>) &#x2014;
Tuple of integers representing the number of output channels for each encoder block. The length of the
tuple should be equal to the number of encoder blocks.`,name:"encoder_block_out_channels"},{anchor:"diffusers.AutoencoderTiny.decoder_block_out_channels",description:`<strong>decoder_block_out_channels</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(64, 64, 64, 64)</code>) &#x2014;
Tuple of integers representing the number of output channels for each decoder block. The length of the
tuple should be equal to the number of decoder blocks.`,name:"decoder_block_out_channels"},{anchor:"diffusers.AutoencoderTiny.act_fn",description:`<strong>act_fn</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;relu&quot;</code>) &#x2014;
Activation function to be used throughout the model.`,name:"act_fn"},{anchor:"diffusers.AutoencoderTiny.latent_channels",description:`<strong>latent_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Number of channels in the latent representation. The latent space acts as a compressed representation of
the input image.`,name:"latent_channels"},{anchor:"diffusers.AutoencoderTiny.upsampling_scaling_factor",description:`<strong>upsampling_scaling_factor</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
Scaling factor for upsampling in the decoder. It determines the size of the output image during the
upsampling process.`,name:"upsampling_scaling_factor"},{anchor:"diffusers.AutoencoderTiny.num_encoder_blocks",description:`<strong>num_encoder_blocks</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(1, 3, 3, 3)</code>) &#x2014;
Tuple of integers representing the number of encoder blocks at each stage of the encoding process. The
length of the tuple should be equal to the number of stages in the encoder. Each stage has a different
number of encoder blocks.`,name:"num_encoder_blocks"},{anchor:"diffusers.AutoencoderTiny.num_decoder_blocks",description:`<strong>num_decoder_blocks</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>(3, 3, 3, 1)</code>) &#x2014;
Tuple of integers representing the number of decoder blocks at each stage of the decoding process. The
length of the tuple should be equal to the number of stages in the decoder. Each stage has a different
number of decoder blocks.`,name:"num_decoder_blocks"},{anchor:"diffusers.AutoencoderTiny.latent_magnitude",description:`<strong>latent_magnitude</strong> (<code>float</code>, <em>optional</em>, defaults to 3.0) &#x2014;
Magnitude of the latent representation. This parameter scales the latent representation values to control
the extent of information preservation.`,name:"latent_magnitude"},{anchor:"diffusers.AutoencoderTiny.latent_shift",description:`<strong>latent_shift</strong> (float, <em>optional</em>, defaults to 0.5) &#x2014;
Shift applied to the latent representation. This parameter controls the center of the latent space.`,name:"latent_shift"},{anchor:"diffusers.AutoencoderTiny.scaling_factor",description:`<strong>scaling_factor</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The component-wise standard deviation of the trained latent space computed using the first batch of the
training set. This is used to scale the latent space to have unit variance when training the diffusion
model. The latents are scaled with the formula <code>z = z * scaling_factor</code> before being passed to the
diffusion model. When decoding, the latents are scaled back to the original scale with the formula: <code>z = 1 / scaling_factor * z</code>. For more details, refer to sections 4.3.2 and D.1 of the <a href="https://huggingface.co/papers/2112.10752" rel="nofollow">High-Resolution Image
Synthesis with Latent Diffusion Models</a> paper. For this
Autoencoder, however, no such scaling factor was used, hence the value of 1.0 as the default.`,name:"scaling_factor"},{anchor:"diffusers.AutoencoderTiny.force_upcast",description:`<strong>force_upcast</strong> (<code>bool</code>, <em>optional</em>, default to <code>False</code>) &#x2014;
If enabled it will force the VAE to run in float32 for high image resolution pipelines, such as SD-XL. VAE
can be fine-tuned / trained to a lower range without losing too much precision, in which case
<code>force_upcast</code> can be set to <code>False</code> (see this fp16-friendly
<a href="https://huggingface.co/madebyollin/sdxl-vae-fp16-fix" rel="nofollow">AutoEncoder</a>).`,name:"force_upcast"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_tiny.py#L41"}}),A=new F({props:{name:"forward",anchor:"diffusers.AutoencoderTiny.forward",parameters:[{name:"sample",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderTiny.forward.sample",description:"<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014; Input sample.",name:"sample"},{anchor:"diffusers.AutoencoderTiny.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_tiny.py#L292"}}),E=new F({props:{name:"scale_latents",anchor:"diffusers.AutoencoderTiny.scale_latents",parameters:[{name:"x",val:": Tensor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_tiny.py#L157"}}),W=new F({props:{name:"unscale_latents",anchor:"diffusers.AutoencoderTiny.unscale_latents",parameters:[{name:"x",val:": Tensor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_tiny.py#L161"}}),j=new ve({props:{title:"AutoencoderTinyOutput",local:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",headingTag:"h2"}}),B=new F({props:{name:"class diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",anchor:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",parameters:[{name:"latents",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput.latents",description:"<strong>latents</strong> (<code>torch.Tensor</code>) &#x2014; Encoded outputs of the <code>Encoder</code>.",name:"latents"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_tiny.py#L29"}}),V=new De({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoder_tiny.md"}}),{c(){y=l("meta"),P=o(),q=l("p"),Q=o(),u(v.$$.fragment),H=o(),u($.$$.fragment),O=o(),M=l("p"),M.innerHTML=Me,K=o(),x=l("p"),x.textContent=xe,ee=o(),u(U.$$.fragment),te=o(),J=l("p"),J.textContent=Ue,ne=o(),u(Z.$$.fragment),oe=o(),u(k.$$.fragment),se=o(),r=l("div"),u(C.$$.fragment),pe=o(),X=l("p"),X.textContent=Je,me=o(),R=l("p"),R.innerHTML=Ze,he=o(),S=l("p"),S.innerHTML=ke,ge=o(),D=l("div"),u(A.$$.fragment),ye=o(),T=l("div"),u(E.$$.fragment),be=o(),N=l("p"),N.textContent=Ce,_e=o(),w=l("div"),u(W.$$.fragment),Te=o(),z=l("p"),z.textContent=Ae,ae=o(),u(j.$$.fragment),re=o(),b=l("div"),u(B.$$.fragment),we=o(),Y=l("p"),Y.textContent=Ee,ie=o(),u(V.$$.fragment),le=o(),L=l("p"),this.h()},l(e){const t=Re("svelte-u9bgzb",document.head);y=c(t,"META",{name:!0,content:!0}),t.forEach(n),P=s(e),q=c(e,"P",{}),G(q).forEach(n),Q=s(e),f(v.$$.fragment,e),H=s(e),f($.$$.fragment,e),O=s(e),M=c(e,"P",{"data-svelte-h":!0}),_(M)!=="svelte-176znfq"&&(M.innerHTML=Me),K=s(e),x=c(e,"P",{"data-svelte-h":!0}),_(x)!=="svelte-1j0g63g"&&(x.textContent=xe),ee=s(e),f(U.$$.fragment,e),te=s(e),J=c(e,"P",{"data-svelte-h":!0}),_(J)!=="svelte-dyqzt3"&&(J.textContent=Ue),ne=s(e),f(Z.$$.fragment,e),oe=s(e),f(k.$$.fragment,e),se=s(e),r=c(e,"DIV",{class:!0});var d=G(r);f(C.$$.fragment,d),pe=s(d),X=c(d,"P",{"data-svelte-h":!0}),_(X)!=="svelte-pqpiv3"&&(X.textContent=Je),me=s(d),R=c(d,"P",{"data-svelte-h":!0}),_(R)!=="svelte-1otkjue"&&(R.innerHTML=Ze),he=s(d),S=c(d,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1j6sdev"&&(S.innerHTML=ke),ge=s(d),D=c(d,"DIV",{class:!0});var We=G(D);f(A.$$.fragment,We),We.forEach(n),ye=s(d),T=c(d,"DIV",{class:!0});var de=G(T);f(E.$$.fragment,de),be=s(de),N=c(de,"P",{"data-svelte-h":!0}),_(N)!=="svelte-1jovd99"&&(N.textContent=Ce),de.forEach(n),_e=s(d),w=c(d,"DIV",{class:!0});var ue=G(w);f(W.$$.fragment,ue),Te=s(ue),z=c(ue,"P",{"data-svelte-h":!0}),_(z)!=="svelte-hggkbx"&&(z.textContent=Ae),ue.forEach(n),d.forEach(n),ae=s(e),f(j.$$.fragment,e),re=s(e),b=c(e,"DIV",{class:!0});var fe=G(b);f(B.$$.fragment,fe),we=s(fe),Y=c(fe,"P",{"data-svelte-h":!0}),_(Y)!=="svelte-11to6kt"&&(Y.textContent=Ee),fe.forEach(n),ie=s(e),f(V.$$.fragment,e),le=s(e),L=c(e,"P",{}),G(L).forEach(n),this.h()},h(){I(y,"name","hf:doc:metadata"),I(y,"content",ze),I(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(b,"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){i(document.head,y),a(e,P,t),a(e,q,t),a(e,Q,t),p(v,e,t),a(e,H,t),p($,e,t),a(e,O,t),a(e,M,t),a(e,K,t),a(e,x,t),a(e,ee,t),p(U,e,t),a(e,te,t),a(e,J,t),a(e,ne,t),p(Z,e,t),a(e,oe,t),p(k,e,t),a(e,se,t),a(e,r,t),p(C,r,null),i(r,pe),i(r,X),i(r,me),i(r,R),i(r,he),i(r,S),i(r,ge),i(r,D),p(A,D,null),i(r,ye),i(r,T),p(E,T,null),i(T,be),i(T,N),i(r,_e),i(r,w),p(W,w,null),i(w,Te),i(w,z),a(e,ae,t),p(j,e,t),a(e,re,t),a(e,b,t),p(B,b,null),i(b,we),i(b,Y),a(e,ie,t),p(V,e,t),a(e,le,t),a(e,L,t),ce=!0},p:Ve,i(e){ce||(m(v.$$.fragment,e),m($.$$.fragment,e),m(U.$$.fragment,e),m(Z.$$.fragment,e),m(k.$$.fragment,e),m(C.$$.fragment,e),m(A.$$.fragment,e),m(E.$$.fragment,e),m(W.$$.fragment,e),m(j.$$.fragment,e),m(B.$$.fragment,e),m(V.$$.fragment,e),ce=!0)},o(e){h(v.$$.fragment,e),h($.$$.fragment,e),h(U.$$.fragment,e),h(Z.$$.fragment,e),h(k.$$.fragment,e),h(C.$$.fragment,e),h(A.$$.fragment,e),h(E.$$.fragment,e),h(W.$$.fragment,e),h(j.$$.fragment,e),h(B.$$.fragment,e),h(V.$$.fragment,e),ce=!1},d(e){e&&(n(P),n(q),n(Q),n(H),n(O),n(M),n(K),n(x),n(ee),n(te),n(J),n(ne),n(oe),n(se),n(r),n(ae),n(re),n(b),n(ie),n(le),n(L)),n(y),g(v,e),g($,e),g(U,e),g(Z,e),g(k,e),g(C),g(A),g(E),g(W),g(j,e),g(B),g(V,e)}}}const ze='{"title":"Tiny AutoEncoder","local":"tiny-autoencoder","sections":[{"title":"AutoencoderTiny","local":"diffusers.AutoencoderTiny","sections":[],"depth":2},{"title":"AutoencoderTinyOutput","local":"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput","sections":[],"depth":2}],"depth":1}';function Ye($e){return Ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Oe extends Ie{constructor(y){super(),Xe(this,y,Ye,Ne,Be,{})}}export{Oe as component};
