Buckets:
| import"../chunks/DsnmJJEf.js";import{i as E,h as j,C as B,H as c,a as v,D as o,E as G,s as X}from"../chunks/BtE7mKSK.js";import{p as R,o as I,s as e,f as V,a as w,b as C,c as n,d as M,r as t,n as a}from"../chunks/jDjavuwI.js";const S='{"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}';var N=M('<meta name="hf:doc:metadata"/>'),D=M(`<p></p> <!> <!> <p>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/pr_14261/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> or <a href="/docs/diffusers/pr_14261/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline">StableDiffusionXLPipeline</a> almost instantly.</p> <p>To use with Stable Diffusion v-2.1:</p> <!> <p>To use with Stable Diffusion XL 1.0</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>A tiny distilled VAE model for encoding images into latents and decoding latent representations into images.</p> <p><a href="/docs/diffusers/pr_14261/en/api/models/autoencoder_tiny#diffusers.AutoencoderTiny">AutoencoderTiny</a> is a wrapper around the original implementation of <code>TAESD</code>.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14261/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).</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>raw latents -> [0, 1]</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>[0, 1] -> raw latents</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output of AutoencoderTiny encoding method.</p></div> <!> <p></p>`,1);function q(U,J){R(J,!1),I(()=>{new URLSearchParams(window.location.search).get("fw")}),E();var d=D();j("1vnq647",_=>{var T=N();X(T,"content",S),w(_,T)});var u=e(V(d),2);B(u,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var p=e(u,2);c(p,{title:"Tiny AutoEncoder",local:"tiny-autoencoder",headingTag:"h1"});var f=e(p,6);v(f,{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">"stabilityai/stable-diffusion-2-1-base"</span>, torch_dtype=torch.float16 | |
| ) | |
| pipe.vae = AutoencoderTiny.from_pretrained(<span class="hljs-string">"madebyollin/taesd"</span>, torch_dtype=torch.float16) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"slice of delicious New York-style berry cheesecake"</span> | |
| image = pipe(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>] | |
| image`,lang:"python",wrap:!1});var m=e(f,4);v(m,{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">"stabilityai/stable-diffusion-xl-base-1.0"</span>, torch_dtype=torch.float16 | |
| ) | |
| pipe.vae = AutoencoderTiny.from_pretrained(<span class="hljs-string">"madebyollin/taesdxl"</span>, torch_dtype=torch.float16) | |
| pipe = pipe.to(<span class="hljs-string">"cuda"</span>) | |
| prompt = <span class="hljs-string">"slice of delicious New York-style berry cheesecake"</span> | |
| image = pipe(prompt, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>] | |
| image`,lang:"python",wrap:!1});var h=e(m,2);c(h,{title:"AutoencoderTiny",local:"diffusers.AutoencoderTiny",headingTag:"h2"});var s=e(h,2),g=n(s);o(g,{name:"class diffusers.AutoencoderTiny",anchor:"diffusers.AutoencoderTiny",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_tiny.py#L40",parameters:[{name:"in_channels",val:": int = 3"},{name:"out_channels",val:": int = 3"},{name:"encoder_block_out_channels",val:": tuple = (64, 64, 64, 64)"},{name:"decoder_block_out_channels",val:": tuple = (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:": tuple = (1, 3, 3, 3)"},{name:"num_decoder_blocks",val:": tuple = (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) — 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) — 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>) — | |
| 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>) — | |
| 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>"relu"</code>) — | |
| 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) — | |
| 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) — | |
| 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>) — | |
| 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>) — | |
| 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) — | |
| 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) — | |
| 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) — | |
| 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>) — | |
| 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"}]});var r=e(g,8),Z=n(r);o(Z,{name:"forward",anchor:"diffusers.AutoencoderTiny.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_tiny.py#L291",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>) — 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>) — | |
| Whether or not to return a <code>DecoderOutput</code> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> 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> | |
| `}),t(r);var i=e(r,2),x=n(i);o(x,{name:"scale_latents",anchor:"diffusers.AutoencoderTiny.scale_latents",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_tiny.py#L156",parameters:[{name:"x",val:": Tensor"}]}),a(2),t(i);var b=e(i,2),k=n(b);o(k,{name:"unscale_latents",anchor:"diffusers.AutoencoderTiny.unscale_latents",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_tiny.py#L160",parameters:[{name:"x",val:": Tensor"}]}),a(2),t(b),t(s);var y=e(s,2);c(y,{title:"AutoencoderTinyOutput",local:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",headingTag:"h2"});var l=e(y,2),A=n(l);o(A,{name:"class diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",anchor:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_tiny.py#L28",parameters:[{name:"latents",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.models.autoencoders.autoencoder_tiny.AutoencoderTinyOutput.latents",description:"<strong>latents</strong> (<code>torch.Tensor</code>) — Encoded outputs of the <code>Encoder</code>.",name:"latents"}]}),a(2),t(l);var W=e(l,2);G(W,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoder_tiny.md"}),a(2),w(U,d),C()}export{q as component}; | |
Xet Storage Details
- Size:
- 14.8 kB
- Xet hash:
- 0a63ca8bf1dd83186c1e9001d52a6670026d577245af8c561c461ef6064c3547
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.