Buckets:
| import"../chunks/DsnmJJEf.js";import{i as G,h as q,C as Z,H as d,a as W,D as o,E as B,s as I}from"../chunks/BtE7mKSK.js";import{p as S,o as F,s as e,f as H,a as L,b as R,c as t,d as T,n as r,r as n}from"../chunks/jDjavuwI.js";const j='{"title":"AutoencoderKLCogVideoX","local":"autoencoderklcogvideox","sections":[{"title":"AutoencoderKLCogVideoX","local":"diffusers.AutoencoderKLCogVideoX","sections":[],"depth":2},{"title":"AutoencoderKLOutput","local":"diffusers.models.modeling_outputs.AutoencoderKLOutput","sections":[],"depth":2},{"title":"DecoderOutput","local":"diffusers.models.autoencoders.vae.DecoderOutput","sections":[],"depth":2}],"depth":1}';var Y=T('<meta name="hf:doc:metadata"/>'),J=T(`<p></p> <!> <!> <p>The 3D variational autoencoder (VAE) model with KL loss used in <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a> was introduced in <a href="https://github.com/THUDM/CogVideo/blob/main/resources/CogVideoX.pdf" rel="nofollow">CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer</a> by Tsinghua University & ZhipuAI.</p> <p>The model can be loaded with the following code snippet.</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 VAE model with KL loss for encoding images into latents and decoding latent representations into images. Used in <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a>.</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 it’s 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"><!> <p>Decode a batch of images.</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>Encode a batch of images into latents.</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>Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to | |
| compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow | |
| processing larger images.</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"><!></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>Decode a batch of images using a tiled decoder.</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>Encode a batch of images using a tiled encoder.</p> <p>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.</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 AutoencoderKL encoding method.</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>Output of decoding method.</p></div> <!> <p></p>`,1);function ee(C,A){S(A,!1),F(()=>{new URLSearchParams(window.location.search).get("fw")}),G();var f=J();q("qsttr8",V=>{var D=Y();I(D,"content",j),L(V,D)});var h=e(H(f),2);Z(h,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var g=e(h,2);d(g,{title:"AutoencoderKLCogVideoX",local:"autoencoderklcogvideox",headingTag:"h1"});var _=e(g,6);W(_,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9lbmNvZGVyS0xDb2dWaWRlb1glMEElMEF2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMQ29nVmlkZW9YLmZyb21fcHJldHJhaW5lZCglMjJUSFVETSUyRkNvZ1ZpZGVvWC0yYiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnZhZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLCogVideoX | |
| vae = AutoencoderKLCogVideoX.from_pretrained(<span class="hljs-string">"THUDM/CogVideoX-2b"</span>, subfolder=<span class="hljs-string">"vae"</span>, torch_dtype=torch.float16).to(<span class="hljs-string">"cuda"</span>)`,lang:"python",wrap:!1});var v=e(_,2);d(v,{title:"AutoencoderKLCogVideoX",local:"diffusers.AutoencoderKLCogVideoX",headingTag:"h2"});var s=e(v,2),b=t(s);o(b,{name:"class diffusers.AutoencoderKLCogVideoX",anchor:"diffusers.AutoencoderKLCogVideoX",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L956",parameters:[{name:"in_channels",val:": int = 3"},{name:"out_channels",val:": int = 3"},{name:"down_block_types",val:": tuple = ('CogVideoXDownBlock3D', 'CogVideoXDownBlock3D', 'CogVideoXDownBlock3D', 'CogVideoXDownBlock3D')"},{name:"up_block_types",val:": tuple = ('CogVideoXUpBlock3D', 'CogVideoXUpBlock3D', 'CogVideoXUpBlock3D', 'CogVideoXUpBlock3D')"},{name:"block_out_channels",val:": tuple = (128, 256, 256, 512)"},{name:"latent_channels",val:": int = 16"},{name:"layers_per_block",val:": int = 3"},{name:"act_fn",val:": str = 'silu'"},{name:"norm_eps",val:": float = 1e-06"},{name:"norm_num_groups",val:": int = 32"},{name:"temporal_compression_ratio",val:": float = 4"},{name:"sample_height",val:": int = 480"},{name:"sample_width",val:": int = 720"},{name:"scaling_factor",val:": float = 1.15258426"},{name:"shift_factor",val:": float | None = None"},{name:"latents_mean",val:": tuple[float] | None = None"},{name:"latents_std",val:": tuple[float] | None = None"},{name:"force_upcast",val:": float = True"},{name:"use_quant_conv",val:": bool = False"},{name:"use_post_quant_conv",val:": bool = False"},{name:"invert_scale_latents",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.in_channels",description:"<strong>in_channels</strong> (int, <em>optional</em>, defaults to 3) — Number of channels in the input image.",name:"in_channels"},{anchor:"diffusers.AutoencoderKLCogVideoX.out_channels",description:"<strong>out_channels</strong> (int, <em>optional</em>, defaults to 3) — Number of channels in the output.",name:"out_channels"},{anchor:"diffusers.AutoencoderKLCogVideoX.down_block_types",description:`<strong>down_block_types</strong> (<code>tuple[str]</code>, <em>optional</em>, defaults to <code>("DownEncoderBlock2D",)</code>) — | |
| tuple of downsample block types.`,name:"down_block_types"},{anchor:"diffusers.AutoencoderKLCogVideoX.up_block_types",description:`<strong>up_block_types</strong> (<code>tuple[str]</code>, <em>optional</em>, defaults to <code>("UpDecoderBlock2D",)</code>) — | |
| tuple of upsample block types.`,name:"up_block_types"},{anchor:"diffusers.AutoencoderKLCogVideoX.block_out_channels",description:`<strong>block_out_channels</strong> (<code>tuple[int]</code>, <em>optional</em>, defaults to <code>(64,)</code>) — | |
| tuple of block output channels.`,name:"block_out_channels"},{anchor:"diffusers.AutoencoderKLCogVideoX.act_fn",description:"<strong>act_fn</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"silu"</code>) — The activation function to use.",name:"act_fn"},{anchor:"diffusers.AutoencoderKLCogVideoX.sample_size",description:"<strong>sample_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>32</code>) — Sample input size.",name:"sample_size"},{anchor:"diffusers.AutoencoderKLCogVideoX.scaling_factor",description:`<strong>scaling_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1.15258426</code>) — | |
| 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.`,name:"scaling_factor"},{anchor:"diffusers.AutoencoderKLCogVideoX.force_upcast",description:`<strong>force_upcast</strong> (<code>bool</code>, <em>optional</em>, default to <code>True</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: <a href="https://huggingface.co/madebyollin/sdxl-vae-fp16-fix" rel="nofollow">https://huggingface.co/madebyollin/sdxl-vae-fp16-fix</a>`,name:"force_upcast"}]});var a=e(b,6),X=t(a);o(X,{name:"decode",anchor:"diffusers.AutoencoderKLCogVideoX.decode",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1207",parameters:[{name:"z",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.decode.z",description:"<strong>z</strong> (<code>torch.Tensor</code>) — Input batch of latent vectors.",name:"z"},{anchor:"diffusers.AutoencoderKLCogVideoX.decode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to return a <code>~models.vae.DecoderOutput</code> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If return_dict is True, a <code>~models.vae.DecoderOutput</code> is returned, otherwise a plain <code>tuple</code> is | |
| returned.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~models.vae.DecoderOutput</code> or <code>tuple</code></p> | |
| `}),r(2),n(a);var i=e(a,2),K=t(i);o(K,{name:"encode",anchor:"diffusers.AutoencoderKLCogVideoX.encode",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1151",parameters:[{name:"x",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.encode.x",description:"<strong>x</strong> (<code>torch.Tensor</code>) — Input batch of images.",name:"x"},{anchor:"diffusers.AutoencoderKLCogVideoX.encode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to return a <code>~models.autoencoder_kl.AutoencoderKLOutput</code> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The latent representations of the encoded videos. If <code>return_dict</code> is True, a | |
| <code>~models.autoencoder_kl.AutoencoderKLOutput</code> is returned, otherwise a plain <code>tuple</code> is returned.</p> | |
| `}),r(2),n(i);var c=e(i,2),k=t(c);o(k,{name:"enable_tiling",anchor:"diffusers.AutoencoderKLCogVideoX.enable_tiling",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1089",parameters:[{name:"tile_sample_min_height",val:": int | None = None"},{name:"tile_sample_min_width",val:": int | None = None"},{name:"tile_overlap_factor_height",val:": float | None = None"},{name:"tile_overlap_factor_width",val:": float | None = None"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.enable_tiling.tile_sample_min_height",description:`<strong>tile_sample_min_height</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum height required for a sample to be separated into tiles across the height dimension.`,name:"tile_sample_min_height"},{anchor:"diffusers.AutoencoderKLCogVideoX.enable_tiling.tile_sample_min_width",description:`<strong>tile_sample_min_width</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum width required for a sample to be separated into tiles across the width dimension.`,name:"tile_sample_min_width"},{anchor:"diffusers.AutoencoderKLCogVideoX.enable_tiling.tile_overlap_factor_height",description:`<strong>tile_overlap_factor_height</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum amount of overlap between two consecutive vertical tiles. This is to ensure that there are | |
| no tiling artifacts produced across the height dimension. Must be between 0 and 1. Setting a higher | |
| value might cause more tiles to be processed leading to slow down of the decoding process.`,name:"tile_overlap_factor_height"},{anchor:"diffusers.AutoencoderKLCogVideoX.enable_tiling.tile_overlap_factor_width",description:`<strong>tile_overlap_factor_width</strong> (<code>int</code>, <em>optional</em>) — | |
| The minimum amount of overlap between two consecutive horizontal tiles. This is to ensure that there | |
| are no tiling artifacts produced across the width dimension. Must be between 0 and 1. Setting a higher | |
| value might cause more tiles to be processed leading to slow down of the decoding process.`,name:"tile_overlap_factor_width"}]}),r(2),n(c);var l=e(c,2),M=t(l);o(M,{name:"forward",anchor:"diffusers.AutoencoderKLCogVideoX.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1405",parameters:[{name:"sample",val:": Tensor"},{name:"sample_posterior",val:": bool = False"},{name:"return_dict",val:": bool = True"},{name:"generator",val:": typing.Optional[torch.Generator] = None"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.forward.sample",description:"<strong>sample</strong> (<code>torch.Tensor</code>) — Input sample.",name:"sample"},{anchor:"diffusers.AutoencoderKLCogVideoX.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.AutoencoderKLCogVideoX.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.AutoencoderKLCogVideoX.forward.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) — | |
| A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make sampling | |
| deterministic.`,name:"generator"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is True, a <code>~models.vae.DecoderOutput</code> is returned, otherwise a plain <code>tuple</code> is | |
| returned.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~models.vae.DecoderOutput</code> or <code>tuple</code></p> | |
| `}),n(l);var u=e(l,2),O=t(u);o(O,{name:"tiled_decode",anchor:"diffusers.AutoencoderKLCogVideoX.tiled_decode",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1322",parameters:[{name:"z",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.tiled_decode.z",description:"<strong>z</strong> (<code>torch.Tensor</code>) — Input batch of latent vectors.",name:"z"},{anchor:"diffusers.AutoencoderKLCogVideoX.tiled_decode.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>~models.vae.DecoderOutput</code> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If return_dict is True, a <code>~models.vae.DecoderOutput</code> is returned, otherwise a plain <code>tuple</code> is | |
| returned.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>~models.vae.DecoderOutput</code> or <code>tuple</code></p> | |
| `}),r(2),n(u);var x=e(u,2),U=t(x);o(U,{name:"tiled_encode",anchor:"diffusers.AutoencoderKLCogVideoX.tiled_encode",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py#L1248",parameters:[{name:"x",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLCogVideoX.tiled_encode.x",description:"<strong>x</strong> (<code>torch.Tensor</code>) — Input batch of videos.",name:"x"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The latent representation of the encoded videos.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>torch.Tensor</code></p> | |
| `}),r(4),n(x),n(s);var w=e(s,2);d(w,{title:"AutoencoderKLOutput",local:"diffusers.models.modeling_outputs.AutoencoderKLOutput",headingTag:"h2"});var p=e(w,2),N=t(p);o(N,{name:"class diffusers.models.modeling_outputs.AutoencoderKLOutput",anchor:"diffusers.models.modeling_outputs.AutoencoderKLOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/modeling_outputs.py#L7",parameters:[{name:"latent_dist",val:": DiagonalGaussianDistribution"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.AutoencoderKLOutput.latent_dist",description:`<strong>latent_dist</strong> (<code>DiagonalGaussianDistribution</code>) — | |
| Encoded outputs of <code>Encoder</code> represented as the mean and logvar of <code>DiagonalGaussianDistribution</code>. | |
| <code>DiagonalGaussianDistribution</code> allows for sampling latents from the distribution.`,name:"latent_dist"}]}),r(2),n(p);var y=e(p,2);d(y,{title:"DecoderOutput",local:"diffusers.models.autoencoders.vae.DecoderOutput",headingTag:"h2"});var m=e(y,2),z=t(m);o(z,{name:"class diffusers.models.autoencoders.vae.DecoderOutput",anchor:"diffusers.models.autoencoders.vae.DecoderOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14261/src/diffusers/models/autoencoders/vae.py#L46",parameters:[{name:"sample",val:": Tensor"},{name:"commit_loss",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"diffusers.models.autoencoders.vae.DecoderOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) — | |
| The decoded output sample from the last layer of the model.`,name:"sample"}]}),r(2),n(m);var E=e(m,2);B(E,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoderkl_cogvideox.md"}),r(2),L(C,f),R()}export{ee as component}; | |
Xet Storage Details
- Size:
- 19.5 kB
- Xet hash:
- f0d654958f5ee57d76f616096448c89b9f6f940eb778a1fbaa15a3bba53731a3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.