Buckets:

download
raw
14.7 kB
import"../chunks/DsnmJJEf.js";import{i as A,h as q,C as k,H as g,c as _,a as I,D as w,E as J,s as W}from"../chunks/BtE7mKSK.js";import{p as z,o as E,s as e,f as Z,a as y,b as R,c as n,d as T,n as s,r as t}from"../chunks/jDjavuwI.js";const N='{"title":"AnyFlowTransformer3DModel","local":"anyflowtransformer3dmodel","sections":[{"title":"AnyFlowTransformer3DModel","local":"diffusers.AnyFlowTransformer3DModel","sections":[],"depth":2}],"depth":1}';var V=T('<meta name="hf:doc:metadata"/>'),j=T(`<p></p> <!> <!> <p>The bidirectional 3D Transformer used by <a href="../pipelines/anyflow#anyflowpipeline"><code>AnyFlowPipeline</code></a>. It is the
v0.35.1 Wan2.1 backbone with one structural change: the timestep embedder is replaced by <code>AnyFlowDualTimestepTextImageEmbedding</code>, so every forward call conditions on both the source timestep <code>t</code> and the target timestep <code>r</code>. This is the embedding required to learn the flow map <!> introduced in <a href="https://huggingface.co/papers/2605.13724" rel="nofollow">AnyFlow</a>. See the <a href="../pipelines/anyflow"><code>AnyFlowPipeline</code></a> page
for paper, authors, and released checkpoints.</p> <p>For chunk-wise autoregressive (FAR causal) generation, use <a href="anyflow_far_transformer3d"><code>AnyFlowFARTransformer3DModel</code></a> instead.</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>Bidirectional 3D Transformer for AnyFlow flow-map sampling.</p> <p>The architecture is the v0.35.1 Wan2.1 3D DiT backbone with one structural change: the timestep embedder is
replaced by <code>AnyFlowDualTimestepTextImageEmbedding</code> so that every forward call conditions on both the source
timestep <code>t</code> and the target timestep <code>r</code>. This is the embedding required to learn the flow map<!> introduced in <a href="https://huggingface.co/papers/2605.13724" rel="nofollow">AnyFlow</a>.</p> <p>For chunk-wise autoregressive (FAR causal) generation, use <code>AnyFlowFARTransformer3DModel</code> instead; that variant
adds the FAR causal block-mask and a compressed-frame patch embedding on top of the same backbone.</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>Bidirectional flow-map forward pass. <code>hidden_states</code> is laid out as <code>(B, F, C, H, W)</code> (per-frame latents).
The input is patchified with the standard <code>patch_embedding</code> (kernel = stride = <code>patch_size</code>) and denoised
with global bidirectional self-attention over the resulting flat token sequence.</p></div></div> <!> <p></p>`,1);function U(b,v){z(v,!1),E(()=>{new URLSearchParams(window.location.search).get("fw")}),A();var i=j();q("1fqvuq",f=>{var u=V();W(u,"content",N),y(f,u)});var m=e(Z(i),2);k(m,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var l=e(m,2);g(l,{title:"AnyFlowTransformer3DModel",local:"anyflowtransformer3dmodel",headingTag:"h1"});var a=e(l,2),x=e(n(a),9);_(x,()=>'<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">Φ</mi><mrow><mi>r</mi><mo>←</mo><mi>t</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\\Phi_{r\\leftarrow t}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord">Φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.0278em;">r</span><span class="mrel mtight">←</span><span class="mord mathnormal mtight">t</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>'),s(5),t(a);var d=e(a,4);I(d,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEFueUZsb3dUcmFuc2Zvcm1lcjNETW9kZWwlMEElMEElMjMlMjBCaWRpcmVjdGlvbmFsJTIwQW55RmxvdyUyMGNoZWNrcG9pbnQlMjAoVDJWKSUzQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQW55Rmxvd1RyYW5zZm9ybWVyM0RNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybnZpZGlhJTJGQW55Rmxvdy1XYW4yLjEtVDJWLTEuM0ItRGlmZnVzZXJzJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMEEp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowTransformer3DModel
<span class="hljs-comment"># Bidirectional AnyFlow checkpoint (T2V):</span>
transformer = AnyFlowTransformer3DModel.from_pretrained(
<span class="hljs-string">&quot;nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>
)`,lang:"python",wrap:!1});var p=e(d,2);g(p,{title:"AnyFlowTransformer3DModel",local:"diffusers.AnyFlowTransformer3DModel",headingTag:"h2"});var o=e(p,2),c=n(o);w(c,{name:"class diffusers.AnyFlowTransformer3DModel",anchor:"diffusers.AnyFlowTransformer3DModel",source:"https://github.com/huggingface/diffusers/blob/vr_14171/src/diffusers/models/transformers/transformer_anyflow.py#L507",parameters:[{name:"patch_size",val:": typing.Tuple[int] = (1, 2, 2)"},{name:"num_attention_heads",val:": int = 40"},{name:"attention_head_dim",val:": int = 128"},{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": int = 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:"eps",val:": float = 1e-06"},{name:"image_dim",val:": typing.Optional[int] = None"},{name:"rope_max_seq_len",val:": int = 1024"},{name:"gate_value",val:": float = 0.25"},{name:"deltatime_type",val:": str = 'r'"}],parametersDescription:[{anchor:"diffusers.AnyFlowTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<em>Tuple[int]</em>, defaults to <em>(1, 2, 2)</em>) &#x2014;
3D patch dimensions for video embedding (t_patch, h_patch, w_patch).`,name:"patch_size"},{anchor:"diffusers.AnyFlowTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<em>int</em>, defaults to <em>40</em>) &#x2014;
Number of attention heads.`,name:"num_attention_heads"},{anchor:"diffusers.AnyFlowTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<em>int</em>, defaults to <em>128</em>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.AnyFlowTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<em>int</em>, defaults to <em>16</em>) &#x2014;
The number of channels in the input latent.`,name:"in_channels"},{anchor:"diffusers.AnyFlowTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<em>int</em>, defaults to <em>16</em>) &#x2014;
The number of channels in the output latent.`,name:"out_channels"},{anchor:"diffusers.AnyFlowTransformer3DModel.text_dim",description:`<strong>text_dim</strong> (<em>int</em>, defaults to <em>4096</em>) &#x2014;
Input dimension for text embeddings (UMT5).`,name:"text_dim"},{anchor:"diffusers.AnyFlowTransformer3DModel.freq_dim",description:`<strong>freq_dim</strong> (<em>int</em>, defaults to <em>256</em>) &#x2014;
Dimension for sinusoidal time embeddings.`,name:"freq_dim"},{anchor:"diffusers.AnyFlowTransformer3DModel.ffn_dim",description:`<strong>ffn_dim</strong> (<em>int</em>, defaults to <em>13824</em>) &#x2014;
Intermediate dimension in feed-forward network.`,name:"ffn_dim"},{anchor:"diffusers.AnyFlowTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<em>int</em>, defaults to <em>40</em>) &#x2014;
Number of transformer blocks.`,name:"num_layers"},{anchor:"diffusers.AnyFlowTransformer3DModel.cross_attn_norm",description:`<strong>cross_attn_norm</strong> (<em>bool</em>, defaults to <em>True</em>) &#x2014;
Enable cross-attention normalization.`,name:"cross_attn_norm"},{anchor:"diffusers.AnyFlowTransformer3DModel.eps",description:`<strong>eps</strong> (<em>float</em>, defaults to <em>1e-6</em>) &#x2014;
Epsilon for normalization layers.`,name:"eps"},{anchor:"diffusers.AnyFlowTransformer3DModel.image_dim",description:`<strong>image_dim</strong> (<em>Optional[int]</em>, <em>optional</em>, defaults to <em>None</em>) &#x2014;
Image embedding dimension for I2V conditioning (<em>1280</em> for the original Wan2.1-I2V model).`,name:"image_dim"},{anchor:"diffusers.AnyFlowTransformer3DModel.rope_max_seq_len",description:`<strong>rope_max_seq_len</strong> (<em>int</em>, defaults to <em>1024</em>) &#x2014;
Maximum sequence length used to precompute rotary position frequencies.`,name:"rope_max_seq_len"},{anchor:"diffusers.AnyFlowTransformer3DModel.gate_value",description:`<strong>gate_value</strong> (<em>float</em>, defaults to <em>0.25</em>) &#x2014;
Mixing gate between source-timestep and delta-timestep embeddings (the AnyFlow paper&#x2019;s{@html &quot;<span class="\\&quot;katex\\&quot;"><span class="\\&quot;katex-mathml\\&quot;"><math xmlns="\\&quot;http://www.w3.org/1998/Math/MathML\\&quot;"><semantics><mrow><mi>g</mi></mrow><annotation encoding="\\&quot;application/x-tex\\&quot;">g</annotation></semantics></math></span><span class="\\&quot;katex-html\\&quot;" aria-hidden="\\&quot;true\\&quot;"><span class="\\&quot;base\\&quot;"><span class="\\&quot;strut\\&quot;" style="\\&quot;height:0.625em;vertical-align:-0.1944em;\\&quot;"></span><span class="\\&quot;mord" mathnormal\\" style="\\&quot;margin-right:0.0359em;\\&quot;">g</span></span></span></span>&quot;} parameter,
fixed at 0.25 in stage-1 distillation).`,name:"gate_value"},{anchor:"diffusers.AnyFlowTransformer3DModel.deltatime_type",description:`<strong>deltatime_type</strong> (<em>str</em>, defaults to <em>&#x2018;r&#x2019;</em>) &#x2014;
Either <code>&quot;r&quot;</code> (delta is the target timestep) or <code>&quot;t-r&quot;</code> (delta is the absolute interval).`,name:"deltatime_type"}]});var r=e(c,4),M=e(n(r),7);_(M,()=>'<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">Φ</mi><mrow><mi>r</mi><mo>←</mo><mi>t</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\\Phi_{r\\leftarrow t}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord">Φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.0278em;">r</span><span class="mrel mtight">←</span><span class="mord mathnormal mtight">t</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>'),s(3),t(r);var h=e(r,4),F=n(h);w(F,{name:"forward",anchor:"diffusers.AnyFlowTransformer3DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14171/src/diffusers/models/transformers/transformer_anyflow.py#L626",parameters:[{name:"hidden_states",val:": Tensor"},{name:"timestep",val:": Tensor"},{name:"r_timestep",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"encoder_hidden_states_image",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AnyFlowTransformer3DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<em>torch.Tensor</em> of shape <em>(batch_size, num_frames, num_channels, height, width)</em>) &#x2014;
Input video latents.`,name:"hidden_states"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.timestep",description:`<strong>timestep</strong> (<em>torch.Tensor</em>) &#x2014;
Source (noisier) flow-map timestep <em>t</em>.`,name:"timestep"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.r_timestep",description:`<strong>r_timestep</strong> (<em>torch.Tensor</em>) &#x2014;
Target (cleaner) flow-map timestep <em>r</em>; defines the destination of the flow-map step.`,name:"r_timestep"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<em>torch.Tensor</em> of shape <em>(batch_size, sequence_len, embed_dims)</em>) &#x2014;
Text-conditioning embeddings.`,name:"encoder_hidden_states"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.encoder_hidden_states_image",description:`<strong>encoder_hidden_states_image</strong> (<em>torch.Tensor</em>, <em>optional</em>) &#x2014;
Image-conditioning embeddings; concatenated before the text tokens when provided.`,name:"encoder_hidden_states_image"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<em>dict</em>, <em>optional</em>) &#x2014;
Kwargs forwarded to the <em>AttentionProcessor</em> as defined under <em>self.processor</em> 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"},{anchor:"diffusers.AnyFlowTransformer3DModel.forward.return_dict",description:`<strong>return_dict</strong> (<em>bool</em>, <em>optional</em>, defaults to <em>True</em>) &#x2014;
Whether to return a [<em>~models.transformer_2d.Transformer2DModelOutput</em>] instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>[<em>~models.transformer_2d.Transformer2DModelOutput</em>] if <em>return_dict</em> is True, otherwise a <em>tuple</em> whose
first element is the predicted velocity tensor.</p>
`}),s(2),t(h),t(o);var D=e(o,2);J(D,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/anyflow_transformer3d.md"}),s(2),y(b,i),R()}export{U as component};

Xet Storage Details

Size:
14.7 kB
·
Xet hash:
8c3aa4e632c7202ddd9cddf028d143f1bed7cc16fe841a09df598774d65e058a

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