Buckets:

download
raw
13.5 kB
import"../chunks/DsnmJJEf.js";import{i as w,h as y,C as A,H as t,a as k,D as a,E as z,s as N}from"../chunks/BtE7mKSK.js";import{p as j,o as q,s as e,f as O,a as T,b as C,c as r,d as v,n as s,r as d}from"../chunks/jDjavuwI.js";const E='{"title":"WanAnimateTransformer3DModel","local":"wananimatetransformer3dmodel","sections":[{"title":"WanAnimateTransformer3DModel","local":"diffusers.WanAnimateTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';var F=v('<meta name="hf:doc:metadata"/>'),U=v('<p></p> <!> <!> <p>A Diffusion Transformer model for 3D video-like data was introduced in <a href="https://github.com/Wan-Video/Wan2.2" rel="nofollow">Wan Animate</a> by the Alibaba Wan Team.</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 Transformer model for video-like data used in the WanAnimate model.</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>Forward pass of Wan2.2-Animate transformer model.</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>The output of <a href="/docs/diffusers/pr_14164/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.</p></div> <!> <p></p>',1);function L(b,M){j(M,!1),q(()=>{new URLSearchParams(window.location.search).get("fw")}),w();var i=U();y("1gn2d0b",_=>{var g=F();N(g,"content",E),T(_,g)});var c=e(O(i),2);A(c,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var m=e(c,2);t(m,{title:"WanAnimateTransformer3DModel",local:"wananimatetransformer3dmodel",headingTag:"h1"});var l=e(m,6);k(l,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFdhbkFuaW1hdGVUcmFuc2Zvcm1lcjNETW9kZWwlMEElMEF0cmFuc2Zvcm1lciUyMCUzRCUyMFdhbkFuaW1hdGVUcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMldhbi1BSSUyRldhbjIuMi1BbmltYXRlLTE0Qi1EaWZmdXNlcnMlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> WanAnimateTransformer3DModel
transformer = WanAnimateTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;Wan-AI/Wan2.2-Animate-14B-Diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, dtype=torch.bfloat16)`,lang:"python",wrap:!1});var f=e(l,2);t(f,{title:"WanAnimateTransformer3DModel",local:"diffusers.WanAnimateTransformer3DModel",headingTag:"h2"});var n=e(f,2),u=r(n);a(u,{name:"class diffusers.WanAnimateTransformer3DModel",anchor:"diffusers.WanAnimateTransformer3DModel",source:"https://github.com/huggingface/diffusers/blob/vr_14164/src/diffusers/models/transformers/transformer_wan_animate.py#L986",parameters:[{name:"patch_size",val:": tuple = (1, 2, 2)"},{name:"num_attention_heads",val:": int = 40"},{name:"attention_head_dim",val:": int = 128"},{name:"in_channels",val:": int | None = 36"},{name:"latent_channels",val:": int | None = 16"},{name:"out_channels",val:": int | None = 16"},{name:"text_dim",val:": int = 4096"},{name:"freq_dim",val:": int = 256"},{name:"ffn_dim",val:": int = 13824"},{name:"num_layers",val:": int = 40"},{name:"cross_attn_norm",val:": bool = True"},{name:"qk_norm",val:": str | None = 'rms_norm_across_heads'"},{name:"eps",val:": float = 1e-06"},{name:"image_dim",val:": int | None = 1280"},{name:"added_kv_proj_dim",val:": int | None = None"},{name:"rope_max_seq_len",val:": int = 1024"},{name:"pos_embed_seq_len",val:": int | None = None"},{name:"motion_encoder_channel_sizes",val:": dict[str, int] | None = None"},{name:"motion_encoder_size",val:": int = 512"},{name:"motion_style_dim",val:": int = 512"},{name:"motion_dim",val:": int = 20"},{name:"motion_encoder_dim",val:": int = 512"},{name:"face_encoder_hidden_dim",val:": int = 1024"},{name:"face_encoder_num_heads",val:": int = 4"},{name:"inject_face_latents_blocks",val:": int = 5"},{name:"motion_encoder_batch_size",val:": int = 8"}],parametersDescription:[{anchor:"diffusers.WanAnimateTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>tuple[int]</code>, defaults to <code>(1, 2, 2)</code>) &#x2014;
3D patch dimensions for video embedding (t_patch, h_patch, w_patch).`,name:"patch_size"},{anchor:"diffusers.WanAnimateTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
Fixed length for text embeddings.`,name:"num_attention_heads"},{anchor:"diffusers.WanAnimateTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.WanAnimateTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.WanAnimateTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.WanAnimateTransformer3DModel.text_dim",description:`<strong>text_dim</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
Input dimension for text embeddings.`,name:"text_dim"},{anchor:"diffusers.WanAnimateTransformer3DModel.freq_dim",description:`<strong>freq_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
Dimension for sinusoidal time embeddings.`,name:"freq_dim"},{anchor:"diffusers.WanAnimateTransformer3DModel.ffn_dim",description:`<strong>ffn_dim</strong> (<code>int</code>, defaults to <code>13824</code>) &#x2014;
Intermediate dimension in feed-forward network.`,name:"ffn_dim"},{anchor:"diffusers.WanAnimateTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
The number of layers of transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.WanAnimateTransformer3DModel.window_size",description:`<strong>window_size</strong> (<code>tuple[int]</code>, defaults to <code>(-1, -1)</code>) &#x2014;
Window size for local attention (-1 indicates global attention).`,name:"window_size"},{anchor:"diffusers.WanAnimateTransformer3DModel.cross_attn_norm",description:`<strong>cross_attn_norm</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Enable cross-attention normalization.`,name:"cross_attn_norm"},{anchor:"diffusers.WanAnimateTransformer3DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Enable query/key normalization.`,name:"qk_norm"},{anchor:"diffusers.WanAnimateTransformer3DModel.eps",description:`<strong>eps</strong> (<code>float</code>, defaults to <code>1e-6</code>) &#x2014;
Epsilon value for normalization layers.`,name:"eps"},{anchor:"diffusers.WanAnimateTransformer3DModel.image_dim",description:`<strong>image_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1280</code>) &#x2014;
The number of channels to use for the image embedding. If <code>None</code>, no projection is used.`,name:"image_dim"},{anchor:"diffusers.WanAnimateTransformer3DModel.added_kv_proj_dim",description:`<strong>added_kv_proj_dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>5120</code>) &#x2014;
The number of channels to use for the added key and value projections. If <code>None</code>, no projection is used.`,name:"added_kv_proj_dim"}]});var h=e(u,4),W=r(h);a(W,{name:"forward",anchor:"diffusers.WanAnimateTransformer3DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14164/src/diffusers/models/transformers/transformer_wan_animate.py#L1154",parameters:[{name:"hidden_states",val:": Tensor"},{name:"timestep",val:": LongTensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"encoder_hidden_states_image",val:": typing.Optional[torch.Tensor] = None"},{name:"pose_hidden_states",val:": typing.Optional[torch.Tensor] = None"},{name:"face_pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"motion_encode_batch_size",val:": int | None = None"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"}],parametersDescription:[{anchor:"diffusers.WanAnimateTransformer3DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(B, 2C + 4, T + 1, H, W)</code>) &#x2014;
Input noisy video latents of shape <code>(B, 2C + 4, T + 1, H, W)</code>, where B is the batch size, C is the
number of latent channels (16 for Wan VAE), T is the number of latent frames in an inference segment, H
is the latent height, and W is the latent width.`,name:"hidden_states"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.timestep",description:`<strong>timestep</strong> &#x2014; (<code>torch.LongTensor</code>):
The current timestep in the denoising loop.`,name:"timestep"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Text embeddings from the text encoder (umT5 for Wan Animate).`,name:"encoder_hidden_states"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.encoder_hidden_states_image",description:`<strong>encoder_hidden_states_image</strong> (<code>torch.Tensor</code>) &#x2014;
CLIP visual features of the reference (character) image.`,name:"encoder_hidden_states_image"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.pose_hidden_states",description:`<strong>pose_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(B, C, T, H, W)</code>) &#x2014;
Pose video latents. TODO: description`,name:"pose_hidden_states"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.face_pixel_values",description:`<strong>face_pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(B, C&apos;, S, H&apos;, W&apos;)</code>) &#x2014;
Face video in pixel space (not latent space). Typically C&#x2019; = 3 and H&#x2019; and W&#x2019; are the height/width of
the face video in pixels. Here S is the inference segment length, usually set to 77.`,name:"face_pixel_values"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.motion_encode_batch_size",description:`<strong>motion_encode_batch_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The batch size for batched encoding of the face video via the motion encoder. Will default to
<code>self.config.motion_encoder_batch_size</code> if not set.`,name:"motion_encode_batch_size"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return the output as a dict or tuple.`,name:"return_dict"},{anchor:"diffusers.WanAnimateTransformer3DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"attention_kwargs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is True, a <code>~models.transformer_2d.Transformer2DModelOutput</code> whose <code>sample</code> is the
denoised video latent is returned, otherwise a plain <code>tuple</code> whose first element is that tensor is
returned.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~models.transformer_2d.Transformer2DModelOutput</code> or <code>tuple</code></p>
`}),s(2),d(h),d(n);var p=e(n,2);t(p,{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"});var o=e(p,2),x=r(o);a(x,{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14164/src/diffusers/models/modeling_outputs.py#L21",parameters:[{name:"sample",val:": torch.Tensor"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>(batch size, num_vector_embeds - 1, num_latent_pixels)</code> if <a href="/docs/diffusers/pr_14164/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input. If discrete, returns probability
distributions for the unnoised latent pixels.`,name:"sample"}]}),s(2),d(o);var D=e(o,2);z(D,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/wan_animate_transformer_3d.md"}),s(2),T(b,i),C()}export{L as component};

Xet Storage Details

Size:
13.5 kB
·
Xet hash:
666931eb1397a3b3c30ae352c559e766abc71275dfa268f8f09bad56f22ecc3e

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