Buckets:

HuggingFaceDocBuilder's picture
download
raw
18.4 kB
import{s as Ee,n as ze,o as Ie}from"../chunks/scheduler.53228c21.js";import{S as Ve,i as Fe,e as d,s as n,c as i,h as Ue,a as c,d as t,b as r,f as w,g as u,j as x,k,l,m as s,n as p,t as m,o as f,p as g}from"../chunks/index.cac5d66a.js";import{C as Ge}from"../chunks/CopyLLMTxtMenu.d3355f38.js";import{D as Z}from"../chunks/Docstring.41979c71.js";import{C as Pe}from"../chunks/CodeBlock.606cbaf4.js";import{H as ge,E as je}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e4b76f09.js";function Je(Le){let _,W,S,X,L,Q,D,Y,y,De='The 3D variational autoencoder (VAE) model with KL loss used in <a href="https://github.com/rhymes-ai/Allegro" rel="nofollow">Allegro</a> was introduced in <a href="https://huggingface.co/papers/2410.15458" rel="nofollow">Allegro: Open the Black Box of Commercial-Level Video Generation Model</a> by RhymesAI.',ee,T,ye="The model can be loaded with the following code snippet.",oe,K,te,M,ne,a,C,he,U,Te=`A VAE model with KL loss for encoding videos into latents and decoding latent representations into videos. Used in
<a href="https://github.com/rhymes-ai/Allegro" rel="nofollow">Allegro</a>.`,_e,G,Ke=`This model inherits from <a href="/docs/diffusers/pr_13803/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).`,be,A,q,ve,P,Me="Decode a batch of videos.",Ae,$,B,$e,j,Ce="Encode a batch of videos into latents.",we,J,O,re,E,se,b,z,xe,N,qe="Output of AutoencoderKL encoding method.",le,I,ae,v,V,ke,H,Be="Output of decoding method.",de,F,ce,R,ie;return L=new Ge({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),D=new ge({props:{title:"AutoencoderKLAllegro",local:"autoencoderklallegro",headingTag:"h1"}}),K=new Pe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9lbmNvZGVyS0xBbGxlZ3JvJTBBJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTEFsbGVncm8uZnJvbV9wcmV0cmFpbmVkKCUyMnJoeW1lcy1haSUyRkFsbGVncm8lMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ2YWUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MzIpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLAllegro
vae = AutoencoderKLAllegro.from_pretrained(<span class="hljs-string">&quot;rhymes-ai/Allegro&quot;</span>, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1}}),M=new ge({props:{title:"AutoencoderKLAllegro",local:"diffusers.AutoencoderKLAllegro",headingTag:"h2"}}),C=new Z({props:{name:"class diffusers.AutoencoderKLAllegro",anchor:"diffusers.AutoencoderKLAllegro",parameters:[{name:"in_channels",val:": int = 3"},{name:"out_channels",val:": int = 3"},{name:"down_block_types",val:": tuple = ('AllegroDownBlock3D', 'AllegroDownBlock3D', 'AllegroDownBlock3D', 'AllegroDownBlock3D')"},{name:"up_block_types",val:": tuple = ('AllegroUpBlock3D', 'AllegroUpBlock3D', 'AllegroUpBlock3D', 'AllegroUpBlock3D')"},{name:"block_out_channels",val:": tuple = (128, 256, 512, 512)"},{name:"temporal_downsample_blocks",val:": tuple = (True, True, False, False)"},{name:"temporal_upsample_blocks",val:": tuple = (False, True, True, False)"},{name:"latent_channels",val:": int = 4"},{name:"layers_per_block",val:": int = 2"},{name:"act_fn",val:": str = 'silu'"},{name:"norm_num_groups",val:": int = 32"},{name:"temporal_compression_ratio",val:": float = 4"},{name:"sample_size",val:": int = 320"},{name:"scaling_factor",val:": float = 0.13"},{name:"force_upcast",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLAllegro.in_channels",description:`<strong>in_channels</strong> (int, defaults to <code>3</code>) &#x2014;
Number of channels in the input image.`,name:"in_channels"},{anchor:"diffusers.AutoencoderKLAllegro.out_channels",description:`<strong>out_channels</strong> (int, defaults to <code>3</code>) &#x2014;
Number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.AutoencoderKLAllegro.down_block_types",description:`<strong>down_block_types</strong> (<code>tuple[str, ...]</code>, defaults to <code>(&quot;AllegroDownBlock3D&quot;, &quot;AllegroDownBlock3D&quot;, &quot;AllegroDownBlock3D&quot;, &quot;AllegroDownBlock3D&quot;)</code>) &#x2014;
tuple of strings denoting which types of down blocks to use.`,name:"down_block_types"},{anchor:"diffusers.AutoencoderKLAllegro.up_block_types",description:`<strong>up_block_types</strong> (<code>tuple[str, ...]</code>, defaults to <code>(&quot;AllegroUpBlock3D&quot;, &quot;AllegroUpBlock3D&quot;, &quot;AllegroUpBlock3D&quot;, &quot;AllegroUpBlock3D&quot;)</code>) &#x2014;
tuple of strings denoting which types of up blocks to use.`,name:"up_block_types"},{anchor:"diffusers.AutoencoderKLAllegro.block_out_channels",description:`<strong>block_out_channels</strong> (<code>tuple[int, ...]</code>, defaults to <code>(128, 256, 512, 512)</code>) &#x2014;
tuple of integers denoting number of output channels in each block.`,name:"block_out_channels"},{anchor:"diffusers.AutoencoderKLAllegro.temporal_downsample_blocks",description:`<strong>temporal_downsample_blocks</strong> (<code>tuple[bool, ...]</code>, defaults to <code>(True, True, False, False)</code>) &#x2014;
tuple of booleans denoting which blocks to enable temporal downsampling in.`,name:"temporal_downsample_blocks"},{anchor:"diffusers.AutoencoderKLAllegro.latent_channels",description:`<strong>latent_channels</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
Number of channels in latents.`,name:"latent_channels"},{anchor:"diffusers.AutoencoderKLAllegro.layers_per_block",description:`<strong>layers_per_block</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
Number of resnet or attention or temporal convolution layers per down/up block.`,name:"layers_per_block"},{anchor:"diffusers.AutoencoderKLAllegro.act_fn",description:`<strong>act_fn</strong> (<code>str</code>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
The activation function to use.`,name:"act_fn"},{anchor:"diffusers.AutoencoderKLAllegro.norm_num_groups",description:`<strong>norm_num_groups</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
Number of groups to use in normalization layers.`,name:"norm_num_groups"},{anchor:"diffusers.AutoencoderKLAllegro.temporal_compression_ratio",description:`<strong>temporal_compression_ratio</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
Ratio by which temporal dimension of samples are compressed.`,name:"temporal_compression_ratio"},{anchor:"diffusers.AutoencoderKLAllegro.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>320</code>) &#x2014;
Default latent size.`,name:"sample_size"},{anchor:"diffusers.AutoencoderKLAllegro.scaling_factor",description:`<strong>scaling_factor</strong> (<code>float</code>, defaults to <code>0.13235</code>) &#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.`,name:"scaling_factor"},{anchor:"diffusers.AutoencoderKLAllegro.force_upcast",description:`<strong>force_upcast</strong> (<code>bool</code>, default to <code>True</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: <a href="https://huggingface.co/madebyollin/sdxl-vae-fp16-fix" rel="nofollow">https://huggingface.co/madebyollin/sdxl-vae-fp16-fix</a>`,name:"force_upcast"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/autoencoder_kl_allegro.py#L676"}}),q=new Z({props:{name:"decode",anchor:"diffusers.AutoencoderKLAllegro.decode",parameters:[{name:"z",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLAllegro.decode.z",description:`<strong>z</strong> (<code>torch.Tensor</code>) &#x2014;
Input batch of latent vectors.`,name:"z"},{anchor:"diffusers.AutoencoderKLAllegro.decode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to return a <code>~models.vae.DecoderOutput</code> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/autoencoder_kl_allegro.py#L843",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>
`}}),B=new Z({props:{name:"encode",anchor:"diffusers.AutoencoderKLAllegro.encode",parameters:[{name:"x",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AutoencoderKLAllegro.encode.x",description:`<strong>x</strong> (<code>torch.Tensor</code>) &#x2014;
Input batch of videos.`,name:"x"},{anchor:"diffusers.AutoencoderKLAllegro.encode.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to return a <code>~models.autoencoder_kl.AutoencoderKLOutput</code> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/autoencoder_kl_allegro.py#L806",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>
`}}),O=new Z({props:{name:"forward",anchor:"diffusers.AutoencoderKLAllegro.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.AutoencoderKLAllegro.forward.sample",description:"<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014; Input sample.",name:"sample"},{anchor:"diffusers.AutoencoderKLAllegro.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.AutoencoderKLAllegro.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.AutoencoderKLAllegro.forward.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
PyTorch random number generator.`,name:"generator"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/autoencoder_kl_allegro.py#L1041"}}),E=new ge({props:{title:"AutoencoderKLOutput",local:"diffusers.models.modeling_outputs.AutoencoderKLOutput",headingTag:"h2"}}),z=new Z({props:{name:"class diffusers.models.modeling_outputs.AutoencoderKLOutput",anchor:"diffusers.models.modeling_outputs.AutoencoderKLOutput",parameters:[{name:"latent_dist",val:": DiagonalGaussianDistribution"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.AutoencoderKLOutput.latent_dist",description:`<strong>latent_dist</strong> (<code>DiagonalGaussianDistribution</code>) &#x2014;
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"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/modeling_outputs.py#L7"}}),I=new ge({props:{title:"DecoderOutput",local:"diffusers.models.autoencoders.vae.DecoderOutput",headingTag:"h2"}}),V=new Z({props:{name:"class diffusers.models.autoencoders.vae.DecoderOutput",anchor:"diffusers.models.autoencoders.vae.DecoderOutput",parameters:[{name:"sample",val:": Tensor"},{name:"commit_loss",val:": torch.FloatTensor | None = 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>) &#x2014;
The decoded output sample from the last layer of the model.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/vr_13803/src/diffusers/models/autoencoders/vae.py#L46"}}),F=new je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/autoencoderkl_allegro.md"}}),{c(){_=d("meta"),W=n(),S=d("p"),X=n(),i(L.$$.fragment),Q=n(),i(D.$$.fragment),Y=n(),y=d("p"),y.innerHTML=De,ee=n(),T=d("p"),T.textContent=ye,oe=n(),i(K.$$.fragment),te=n(),i(M.$$.fragment),ne=n(),a=d("div"),i(C.$$.fragment),he=n(),U=d("p"),U.innerHTML=Te,_e=n(),G=d("p"),G.innerHTML=Ke,be=n(),A=d("div"),i(q.$$.fragment),ve=n(),P=d("p"),P.textContent=Me,Ae=n(),$=d("div"),i(B.$$.fragment),$e=n(),j=d("p"),j.textContent=Ce,we=n(),J=d("div"),i(O.$$.fragment),re=n(),i(E.$$.fragment),se=n(),b=d("div"),i(z.$$.fragment),xe=n(),N=d("p"),N.textContent=qe,le=n(),i(I.$$.fragment),ae=n(),v=d("div"),i(V.$$.fragment),ke=n(),H=d("p"),H.textContent=Be,de=n(),i(F.$$.fragment),ce=n(),R=d("p"),this.h()},l(e){const o=Ue("svelte-u9bgzb",document.head);_=c(o,"META",{name:!0,content:!0}),o.forEach(t),W=r(e),S=c(e,"P",{}),w(S).forEach(t),X=r(e),u(L.$$.fragment,e),Q=r(e),u(D.$$.fragment,e),Y=r(e),y=c(e,"P",{"data-svelte-h":!0}),x(y)!=="svelte-1pr3axq"&&(y.innerHTML=De),ee=r(e),T=c(e,"P",{"data-svelte-h":!0}),x(T)!=="svelte-1vuni30"&&(T.textContent=ye),oe=r(e),u(K.$$.fragment,e),te=r(e),u(M.$$.fragment,e),ne=r(e),a=c(e,"DIV",{class:!0});var h=w(a);u(C.$$.fragment,h),he=r(h),U=c(h,"P",{"data-svelte-h":!0}),x(U)!=="svelte-1inj1b4"&&(U.innerHTML=Te),_e=r(h),G=c(h,"P",{"data-svelte-h":!0}),x(G)!=="svelte-13nky0p"&&(G.innerHTML=Ke),be=r(h),A=c(h,"DIV",{class:!0});var ue=w(A);u(q.$$.fragment,ue),ve=r(ue),P=c(ue,"P",{"data-svelte-h":!0}),x(P)!=="svelte-2sss9k"&&(P.textContent=Me),ue.forEach(t),Ae=r(h),$=c(h,"DIV",{class:!0});var pe=w($);u(B.$$.fragment,pe),$e=r(pe),j=c(pe,"P",{"data-svelte-h":!0}),x(j)!=="svelte-zfzp95"&&(j.textContent=Ce),pe.forEach(t),we=r(h),J=c(h,"DIV",{class:!0});var Oe=w(J);u(O.$$.fragment,Oe),Oe.forEach(t),h.forEach(t),re=r(e),u(E.$$.fragment,e),se=r(e),b=c(e,"DIV",{class:!0});var me=w(b);u(z.$$.fragment,me),xe=r(me),N=c(me,"P",{"data-svelte-h":!0}),x(N)!=="svelte-1vsc7ag"&&(N.textContent=qe),me.forEach(t),le=r(e),u(I.$$.fragment,e),ae=r(e),v=c(e,"DIV",{class:!0});var fe=w(v);u(V.$$.fragment,fe),ke=r(fe),H=c(fe,"P",{"data-svelte-h":!0}),x(H)!=="svelte-18u8upa"&&(H.textContent=Be),fe.forEach(t),de=r(e),u(F.$$.fragment,e),ce=r(e),R=c(e,"P",{}),w(R).forEach(t),this.h()},h(){k(_,"name","hf:doc:metadata"),k(_,"content",Ne),k(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(v,"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,o){l(document.head,_),s(e,W,o),s(e,S,o),s(e,X,o),p(L,e,o),s(e,Q,o),p(D,e,o),s(e,Y,o),s(e,y,o),s(e,ee,o),s(e,T,o),s(e,oe,o),p(K,e,o),s(e,te,o),p(M,e,o),s(e,ne,o),s(e,a,o),p(C,a,null),l(a,he),l(a,U),l(a,_e),l(a,G),l(a,be),l(a,A),p(q,A,null),l(A,ve),l(A,P),l(a,Ae),l(a,$),p(B,$,null),l($,$e),l($,j),l(a,we),l(a,J),p(O,J,null),s(e,re,o),p(E,e,o),s(e,se,o),s(e,b,o),p(z,b,null),l(b,xe),l(b,N),s(e,le,o),p(I,e,o),s(e,ae,o),s(e,v,o),p(V,v,null),l(v,ke),l(v,H),s(e,de,o),p(F,e,o),s(e,ce,o),s(e,R,o),ie=!0},p:ze,i(e){ie||(m(L.$$.fragment,e),m(D.$$.fragment,e),m(K.$$.fragment,e),m(M.$$.fragment,e),m(C.$$.fragment,e),m(q.$$.fragment,e),m(B.$$.fragment,e),m(O.$$.fragment,e),m(E.$$.fragment,e),m(z.$$.fragment,e),m(I.$$.fragment,e),m(V.$$.fragment,e),m(F.$$.fragment,e),ie=!0)},o(e){f(L.$$.fragment,e),f(D.$$.fragment,e),f(K.$$.fragment,e),f(M.$$.fragment,e),f(C.$$.fragment,e),f(q.$$.fragment,e),f(B.$$.fragment,e),f(O.$$.fragment,e),f(E.$$.fragment,e),f(z.$$.fragment,e),f(I.$$.fragment,e),f(V.$$.fragment,e),f(F.$$.fragment,e),ie=!1},d(e){e&&(t(W),t(S),t(X),t(Q),t(Y),t(y),t(ee),t(T),t(oe),t(te),t(ne),t(a),t(re),t(se),t(b),t(le),t(ae),t(v),t(de),t(ce),t(R)),t(_),g(L,e),g(D,e),g(K,e),g(M,e),g(C),g(q),g(B),g(O),g(E,e),g(z),g(I,e),g(V),g(F,e)}}}const Ne='{"title":"AutoencoderKLAllegro","local":"autoencoderklallegro","sections":[{"title":"AutoencoderKLAllegro","local":"diffusers.AutoencoderKLAllegro","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}';function He(Le){return Ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ye extends Ve{constructor(_){super(),Fe(this,_,He,Je,Ee,{})}}export{Ye as component};

Xet Storage Details

Size:
18.4 kB
·
Xet hash:
a63049fab747717813384450a965ba326127e55d9a0e54ab3c6d8d470c19d6d8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.