Buckets:

download
raw
69.6 kB
import"../chunks/DsnmJJEf.js";import{i as ae,h as ie,C as le,H as i,a as p,b as re,D as o,c as X,E as pe,s as ce}from"../chunks/BtE7mKSK.js";import{p as de,o as me,s as e,f as u,a as m,b as ue,c as n,d as h,n as l,r as s}from"../chunks/jDjavuwI.js";import{E as S}from"../chunks/SrSJA0zO.js";import{H as T}from"../chunks/BoRAdXUU.js";const he='{"title":"AnyFlow","local":"anyflow","sections":[{"title":"Generation with AnyFlow (Bidirectional T2V)","local":"generation-with-anyflow-bidirectional-t2v","sections":[],"depth":3},{"title":"Generation with AnyFlow (FAR Causal)","local":"generation-with-anyflow-far-causal","sections":[],"depth":3},{"title":"Notes","local":"notes","sections":[],"depth":2},{"title":"AnyFlowPipeline","local":"diffusers.AnyFlowPipeline","sections":[],"depth":2},{"title":"AnyFlowFARPipeline","local":"diffusers.AnyFlowFARPipeline","sections":[],"depth":2},{"title":"AnyFlowPipelineOutput","local":"diffusers.pipelines.anyflow.pipeline_output.AnyFlowPipelineOutput","sections":[],"depth":2}],"depth":1}';var ye=h('<meta name="hf:doc:metadata"/>'),ge=h("<!> <!> <!>",1),q=h("<p>Examples:</p> <!>",1),fe=h(`<p></p> <!> <div style="float: right;"><div class="flex flex-wrap space-x-1"><a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/lora_pipeline.py"><img alt="LoRA" src="https://img.shields.io/badge/LoRA-supported-green"/></a></div></div> <!> <p><a href="https://huggingface.co/papers/2605.13724" rel="nofollow">AnyFlow: Any-Step Video Diffusion Model with On-Policy Flow Map Distillation</a> from NVIDIA, National University of Singapore, and Massachusetts Institute of Technology, by Yuchao Gu, Guian Fang, Yuxin Jiang, Weijia Mao, Song Han, Han Cai, Mike Zheng Shou.</p> <blockquote><p><strong>TL;DR:</strong> AnyFlow is the first any-step video diffusion framework built on flow maps, which enables a single model (bidirectional or causal) to adapt to arbitrary inference budgets.</p></blockquote> <p><em>Few-step video generation has been significantly advanced by consistency models. However, their performance often degrades in any-step video diffusion models due to the fixed-point formulation. To address this limitation, we present AnyFlow, the first any-step video diffusion distillation framework built on flow maps. Instead of learning only the mapping z_t → z_0, AnyFlow learns transitions z_t → z_r over arbitrary time intervals, enabling a single model to adapt to different inference budgets. We design an improved forward flow map training recipe that fine-tunes pretrained video diffusion models into flow map models, and introduce Flow Map Backward Simulation to enable on-policy distillation for flow map models. Extensive experiments across both bidirectional and causal architectures, at scales ranging from 1.3B to 14B, on text-to-video and image-to-video tasks demonstrate that AnyFlow outperforms consistency-based baselines while preserving high fidelity and flexible sampling under varying step budgets.</em></p> <p>The AnyFlow pipelines were contributed by the AnyFlow Team. The original code is available on <a href="https://github.com/NVlabs/AnyFlow" rel="nofollow">GitHub</a>, the project page is at <a href="https://nvlabs.github.io/AnyFlow" rel="nofollow">nvlabs.github.io/AnyFlow</a>, and pretrained models can be found in the <a href="https://huggingface.co/collections/nvidia/anyflow" rel="nofollow">nvidia/anyflow</a> collection on Hugging Face.</p> <p>Available Models:</p> <table><thead><tr><th>Checkpoint</th><th>Backbone</th><th>Description</th></tr></thead><tbody><tr><td><a href="https://huggingface.co/nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers" rel="nofollow"><code>nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers</code></a></td><td>Wan2.1 1.3B</td><td>Bidirectional T2V</td></tr><tr><td><a href="https://huggingface.co/nvidia/AnyFlow-Wan2.1-T2V-14B-Diffusers" rel="nofollow"><code>nvidia/AnyFlow-Wan2.1-T2V-14B-Diffusers</code></a></td><td>Wan2.1 14B</td><td>Bidirectional T2V</td></tr><tr><td><a href="https://huggingface.co/nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers" rel="nofollow"><code>nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers</code></a></td><td>FAR + Wan2.1 1.3B</td><td>Causal T2V / I2V / V2V</td></tr><tr><td><a href="https://huggingface.co/nvidia/AnyFlow-FAR-Wan2.1-14B-Diffusers" rel="nofollow"><code>nvidia/AnyFlow-FAR-Wan2.1-14B-Diffusers</code></a></td><td>FAR + Wan2.1 14B</td><td>Causal T2V / I2V / V2V</td></tr></tbody></table> <blockquote class="tip"><p><code>AnyFlowPipeline</code> is designed for bidirectional diffusion models in text-to-video (T2V) generation. <code>AnyFlowFARPipeline</code> is a chunk-wise causal diffusion model that supports text-to-video (T2V) generation, image-to-video (I2V) generation, and video continuation (V2V).</p></blockquote> <!> <!> <!> <p>The causal pipeline selects between T2V / I2V / V2V via the <code>video</code> (or <code>video_latents</code>) argument:
omit both for plain text-to-video, or pass <code>video=&lt;tensor&gt;</code> of shape <code>(B, T, C, H, W)</code> in <code>[0, 1]</code> with <code>T = 4n + 1</code> to condition on existing frames. Use a single conditioning frame for I2V and a longer
clip for V2V continuation. If you already have pre-encoded latents in the model layout, pass them via <code>video_latents=&lt;tensor&gt;</code> to skip VAE encoding. <code>video</code> and <code>video_latents</code> are mutually exclusive.</p> <blockquote class="important"><p>The released checkpoints bake <code>chunk_partition=[1, 3, 3, 3, 3, 3, 3, 2]</code> (sum 21) into the transformer
config, matched to the canonical 81 raw frames (21 latent frames at the VAE temporal stride of 4). When
you change <code>num_frames</code>, pass a matching <code>chunk_partition</code> summing to <code>(num_frames - 1) // 4 + 1</code>,
otherwise the pipeline raises a <code>ValueError</code>.</p></blockquote> <!> <!> <ul><li>Classifier-free guidance is fused into the released checkpoints, so inference does not run a second guided forward pass. Keep the default <code>guidance_scale=1.0</code> unless your own checkpoint requires otherwise.</li> <li><code>FlowMapEulerDiscreteScheduler</code> is general-purpose. You can attach it to any flow-map-distilled checkpoint via <code>from_pretrained(..., scheduler=FlowMapEulerDiscreteScheduler.from_config(...))</code>.</li> <li><code>AnyFlowPipeline</code> uses <a href="../models/anyflow_transformer3d"><code>AnyFlowTransformer3DModel</code></a> (bidirectional). <code>AnyFlowFARPipeline</code> uses <a href="../models/anyflow_far_transformer3d"><code>AnyFlowFARTransformer3DModel</code></a>, which adds a compressed-frame patch embedding and the FAR causal block-mask.</li> <li>LoRA loading is supported via <code>WanLoraLoaderMixin</code>, the same mixin used by the upstream Wan pipelines.</li> <li>For training recipes (forward flow-map training and on-policy distillation), refer to the original AnyFlow training framework at <a href="https://github.com/NVlabs/AnyFlow" rel="nofollow"><code>NVlabs/AnyFlow</code></a>; training is out of scope for diffusers.</li></ul> <!> <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 text-to-video generation pipeline for AnyFlow flow-map-distilled checkpoints, introduced in <a href="https://huggingface.co/papers/2605.13724" rel="nofollow">AnyFlow</a>.</p> <p>AnyFlow learns arbitrary-interval transitions<!> rather than the fixed<!> mapping
of consistency models, so a single distilled checkpoint can be evaluated at 1, 2, 4, 8, 16… NFE without
retraining. This pipeline operates over the full video tensor in one bidirectional pass; for chunk-wise
autoregressive (causal) generation use <code>AnyFlowFARPipeline</code>.</p> <p>Sampling is plain Euler in mean-velocity form (<code>z_r = z_t - (t - r) * u</code>) with no re-noising. The released NVIDIA
checkpoints fold classifier-free guidance into the model weights, so the default <code>guidance_scale=1.0</code> is the
recommended setting.</p> <p>This model inherits from [<em>DiffusionPipeline</em>]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).</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>The call function to the pipeline for generation.</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>Encodes the prompt into text encoder hidden states.</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 pixel-space video into AnyFlow’s latent layout.</p> <p>Mirrors the single-helper convention of other diffusers pipelines (cf. <code>WanImageToVideoPipeline.encode_image</code>): wraps preprocessing, VAE encoding, and latent normalization into one
call. Output layout is <code>(B, T_latent, C, H, W)</code>, which is what the AnyFlow transformer expects for
conditioning frames.</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>Causal (FAR-based) text-to-video / image-to-video / video-to-video pipeline for AnyFlow checkpoints, introduced in <a href="https://huggingface.co/papers/2605.13724" rel="nofollow">AnyFlow</a>.</p> <p>The pipeline drives a chunk-wise autoregressive sampling loop: each chunk is denoised with flow-map steps while
attending only to past chunks via block-sparse causal attention, and intermediate KV cache is reused across chunks.</p> <p>The task mode (T2V / I2V / V2V) is selected by which conditioning argument is passed to <code>__call__</code>:</p> <ul><li>both <code>video=None</code> and <code>video_latents=None</code> — pure text-to-video.</li> <li><code>video=&lt;tensor of shape (B, T, C, H, W) in [0, 1] with T = 4n + 1&gt;</code> — pre-VAE conditioning frames; the pipeline
VAE-encodes them. Pass a single-frame video for I2V or a multi-frame clip for V2V.</li> <li><code>video_latents=&lt;latent tensor of shape (B, T_latent, C, H_latent, W_latent)&gt;</code> — already-encoded latents in the
FAR layout (skips the VAE encode step).</li></ul> <p>The FAR backbone is the causal Wan2.1 variant introduced by <a href="https://huggingface.co/papers/2503.19325" rel="nofollow">FAR</a>.
Inference is plain Euler in mean-velocity form per chunk with no re-noising. Joint T2V / I2V / V2V is supported by
a single distilled model.</p> <p>This model inherits from [<em>DiffusionPipeline</em>]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).</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>The call function to the pipeline for generation.</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>Encodes the prompt into text encoder hidden states.</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 pixel-space video into AnyFlow’s latent layout.</p> <p>Mirrors the single-helper convention of other diffusers pipelines (cf. <code>WanImageToVideoPipeline.encode_image</code>): wraps preprocessing, VAE encoding, and latent normalization into one
call. Output layout is <code>(B, T_latent, C, H, W)</code>, which is what the AnyFlow transformer expects for
conditioning frames.</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 class for AnyFlow pipelines.</p></div> <!> <p></p>`,1);function Te(Y,D){de(D,!1),me(()=>{new URLSearchParams(window.location.search).get("fw")}),ae();var U=fe();ie("m43j5y",t=>{var c=ye();ce(c,"content",he),m(t,c)});var J=e(u(U),2);le(J,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var F=e(J,4);i(F,{title:"AnyFlow",local:"anyflow",headingTag:"h1"});var j=e(F,16);i(j,{title:"Generation with AnyFlow (Bidirectional T2V)",local:"generation-with-anyflow-bidirectional-t2v",headingTag:"h3"});var A=e(j,2);p(A,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUwQSUwQXBpcGUlMjAlM0QlMjBBbnlGbG93UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMm52aWRpYSUyRkFueUZsb3ctV2FuMi4xLVQyVi0xLjNCLURpZmZ1c2VycyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkFuJTIwYXN0cm9uYXV0JTIwcnVucyUyMHNtb290aGx5JTIwYW5kJTIwYXBwZWFycyUyMGFsbW9zdCUyMHdlaWdodGxlc3MlMjBvbiUyMHRoZSUyMGx1bmFyJTIwc3VyZmFjZSUyQyUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmFzJTIwc2VlbiUyMGZyb20lMjBhJTIwbG93LWFuZ2xlJTIwc2hvdCUyMHRoYXQlMjBoaWdobGlnaHRzJTIwdGhlJTIwdmFzdCUyQyUyMGRlc29sYXRlJTIwYmFja2dyb3VuZCUyMG9mJTIwdGhlJTIwbW9vbi4lMjAlMjIlMEElMjAlMjAlMjAlMjAlMjJUaGUlMjBtb29uJ3MlMjBjcmF0ZXJzJTIwYW5kJTIwcm9ja3klMjB0ZXJyYWluJTIwYXJlJTIwY2xlYXJseSUyMHZpc2libGUlMkMlMjBjcmVhdGluZyUyMGElMjBzdGFyayUyMGNvbnRyYXN0JTIwYWdhaW5zdCUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMnRoZSUyMHJ1bm5pbmclMjBhc3Ryb25hdXQlMjB3aG8lMjBtb3ZlcyUyMHdpdGglMjBncmFjZWZ1bCUyQyUyMGZsdWlkJTIwbW90aW9ucy4lMjIlMEEpJTBBdmlkZW8lMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q0JTJDJTIwbnVtX2ZyYW1lcyUzRDgxKS5mcmFtZXMlNUIwJTVEJTBBZXhwb3J0X3RvX3ZpZGVvKHZpZGVvJTJDJTIwJTIyYW55Zmxvd190MnYubXA0JTIyJTJDJTIwZnBzJTNEMTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video
pipe = AnyFlowPipeline.from_pretrained(
<span class="hljs-string">&quot;nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = (
<span class="hljs-string">&quot;An astronaut runs smoothly and appears almost weightless on the lunar surface, &quot;</span>
<span class="hljs-string">&quot;as seen from a low-angle shot that highlights the vast, desolate background of the moon. &quot;</span>
<span class="hljs-string">&quot;The moon&#x27;s craters and rocky terrain are clearly visible, creating a stark contrast against &quot;</span>
<span class="hljs-string">&quot;the running astronaut who moves with graceful, fluid motions.&quot;</span>
)
video = pipe(prompt, num_inference_steps=<span class="hljs-number">4</span>, num_frames=<span class="hljs-number">81</span>).frames[<span class="hljs-number">0</span>]
export_to_video(video, <span class="hljs-string">&quot;anyflow_t2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"py",wrap:!1});var k=e(A,2);i(k,{title:"Generation with AnyFlow (FAR Causal)",local:"generation-with-anyflow-far-causal",headingTag:"h3"});var x=e(k,6);re(x,{id:"anyflow-far",options:["t2v","i2v","v2v"],children:(t,c)=>{var a=ge(),r=u(a);T(r,{id:"anyflow-far",option:"t2v",children:(d,z)=>{p(d,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd0ZBUlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUwQSUwQXBpcGUlMjAlM0QlMjBBbnlGbG93RkFSUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMm52aWRpYSUyRkFueUZsb3ctRkFSLVdhbjIuMS0xLjNCLURpZmZ1c2VycyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkFuJTIwYXN0cm9uYXV0JTIwcnVucyUyMHNtb290aGx5JTIwYW5kJTIwYXBwZWFycyUyMGFsbW9zdCUyMHdlaWdodGxlc3MlMjBvbiUyMHRoZSUyMGx1bmFyJTIwc3VyZmFjZSUyQyUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmFzJTIwc2VlbiUyMGZyb20lMjBhJTIwbG93LWFuZ2xlJTIwc2hvdCUyMHRoYXQlMjBoaWdobGlnaHRzJTIwdGhlJTIwdmFzdCUyQyUyMGRlc29sYXRlJTIwYmFja2dyb3VuZCUyMG9mJTIwdGhlJTIwbW9vbi4lMjIlMEEpJTBBdmlkZW8lMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q0JTJDJTIwbnVtX2ZyYW1lcyUzRDgxKS5mcmFtZXMlNUIwJTVEJTBBZXhwb3J0X3RvX3ZpZGVvKHZpZGVvJTJDJTIwJTIyYW55Zmxvd19mYXJfdDJ2Lm1wNCUyMiUyQyUyMGZwcyUzRDE2KQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowFARPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video
pipe = AnyFlowFARPipeline.from_pretrained(
<span class="hljs-string">&quot;nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = (
<span class="hljs-string">&quot;An astronaut runs smoothly and appears almost weightless on the lunar surface, &quot;</span>
<span class="hljs-string">&quot;as seen from a low-angle shot that highlights the vast, desolate background of the moon.&quot;</span>
)
video = pipe(prompt, num_inference_steps=<span class="hljs-number">4</span>, num_frames=<span class="hljs-number">81</span>).frames[<span class="hljs-number">0</span>]
export_to_video(video, <span class="hljs-string">&quot;anyflow_far_t2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"py",wrap:!1})},$$slots:{default:!0}});var Q=e(r,2);T(Q,{id:"anyflow-far",option:"i2v",children:(d,z)=>{p(d,{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd0ZBUlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUyQyUyMGxvYWRfaW1hZ2UlMEElMEFwaXBlJTIwJTNEJTIwQW55Rmxvd0ZBUlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJudmlkaWElMkZBbnlGbG93LUZBUi1XYW4yLjEtMS4zQi1EaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMEV4YW1wbGUlMjBjb25kaXRpb25pbmclMjBpbWFnZSUyMGZyb20lMjB0aGUlMjBBbnlGbG93JTIwcmVwby4lMEFmaXJzdF9mcmFtZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGTlZsYWJzJTJGQW55RmxvdyUyRm1haW4lMkZhc3NldHMlMkZldmFsdWF0aW9uJTJGZXhhbXBsZSUyRmltYWdlcyUyRjEuanBnJTIyJTBBKS5yZXNpemUoKDgzMiUyQyUyMDQ4MCkpJTBBYXJyJTIwJTNEJTIwbnAuYXNhcnJheShmaXJzdF9mcmFtZSkuYXN0eXBlKCUyMmZsb2F0MzIlMjIpJTIwJTJGJTIwMjU1LjAlMjAlMjAlMjMlMjAoNDgwJTJDJTIwODMyJTJDJTIwMyklMEFjb250ZXh0X3RlbnNvciUyMCUzRCUyMHRvcmNoLmZyb21fbnVtcHkoYXJyKS5wZXJtdXRlKDIlMkMlMjAwJTJDJTIwMSkudW5zcXVlZXplKDApLnVuc3F1ZWV6ZSgxKS50byglMjJjdWRhJTIyKSUyMCUyMCUyMyUyMCgxJTJDJTIwMSUyQyUyMDMlMkMlMjA0ODAlMkMlMjA4MzIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMkElMjB0b3dlcmluZyUyQyUyMGJhdHRsZS1zY2FycmVkJTIwaHVtYW5vaWQlMjByb2JvdCUyQyUyMHJlbWluaXNjZW50JTIwb2YlMjBhJTIwVHJhbnNmb3JtZXIlMjB3aXRoJTIwcG93ZXJmdWwlMkMlMjBzZWdtZW50ZWQlMjBhcm1vciUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmFuZCUyMGdsb3dpbmclMjByZWQlMjBvcHRpY3MlMkMlMjB3YWxraW5nJTIwdGhyb3VnaCUyMHRoZSUyMHNrZWxldGFsJTIwcmVtYWlucyUyMG9mJTIwYSUyMGNpdHklMjBydWluLiUyMFR3aXN0ZWQlMjBtZXRhbCUyMGFuZCUyMHNoYXR0ZXJlZCUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMmNvbmNyZXRlJTIwY3J1bmNoJTIwdW5kZXIlMjBpdHMlMjBoZWF2eSUyMHN0ZXBzJTJDJTIwYXMlMjB0aGUlMjByb2JvdCUyMHNjYW5zJTIwdGhlJTIwZGVzb2xhdGUlMkMlMjBkdXN0LWNob2tlZCUyMHNreWxpbmUlMjB1bmRlciUyMGFuJTIwZGFyayUyMHNreS4lMjIlMEEpJTBBdmlkZW8lMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMHZpZGVvJTNEY29udGV4dF90ZW5zb3IlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENCUyQyUwQSUyMCUyMCUyMCUyMG51bV9mcmFtZXMlM0Q4MSUyQyUwQSkuZnJhbWVzJTVCMCU1RCUwQWV4cG9ydF90b192aWRlbyh2aWRlbyUyQyUyMCUyMmFueWZsb3dfZmFyX2kydi5tcDQlMjIlMkMlMjBmcHMlM0QxNik=",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowFARPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
pipe = AnyFlowFARPipeline.from_pretrained(
<span class="hljs-string">&quot;nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># Example conditioning image from the AnyFlow repo.</span>
first_frame = load_image(
<span class="hljs-string">&quot;https://raw.githubusercontent.com/NVlabs/AnyFlow/main/assets/evaluation/example/images/1.jpg&quot;</span>
).resize((<span class="hljs-number">832</span>, <span class="hljs-number">480</span>))
arr = np.asarray(first_frame).astype(<span class="hljs-string">&quot;float32&quot;</span>) / <span class="hljs-number">255.0</span> <span class="hljs-comment"># (480, 832, 3)</span>
context_tensor = torch.from_numpy(arr).permute(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>).unsqueeze(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">1</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-comment"># (1, 1, 3, 480, 832)</span>
prompt = (
<span class="hljs-string">&quot;A towering, battle-scarred humanoid robot, reminiscent of a Transformer with powerful, segmented armor &quot;</span>
<span class="hljs-string">&quot;and glowing red optics, walking through the skeletal remains of a city ruin. Twisted metal and shattered &quot;</span>
<span class="hljs-string">&quot;concrete crunch under its heavy steps, as the robot scans the desolate, dust-choked skyline under an dark sky.&quot;</span>
)
video = pipe(
prompt=prompt,
video=context_tensor,
num_inference_steps=<span class="hljs-number">4</span>,
num_frames=<span class="hljs-number">81</span>,
).frames[<span class="hljs-number">0</span>]
export_to_video(video, <span class="hljs-string">&quot;anyflow_far_i2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"py",wrap:!1})},$$slots:{default:!0}});var te=e(Q,2);T(te,{id:"anyflow-far",option:"v2v",children:(d,z)=>{p(d,{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd0ZBUlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUyQyUyMGxvYWRfdmlkZW8lMEElMEFwaXBlJTIwJTNEJTIwQW55Rmxvd0ZBUlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJudmlkaWElMkZBbnlGbG93LUZBUi1XYW4yLjEtMS4zQi1EaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMEV4YW1wbGUlMjBjb25kaXRpb25pbmclMjBjbGlwJTIwZnJvbSUyMHRoZSUyMEFueUZsb3clMjByZXBvJTIwJUUyJTgwJTk0JTIwdGFrZSUyMHRoZSUyMGZpcnN0JTIwOSUyMGZyYW1lcyUyMCgzJTIwbGF0ZW50JTIwZnJhbWVzJTIwYXQlMjBWQUUlMjB0ZW1wb3JhbCUyMHN0cmlkZSUyMDQpLiUwQWNvbnRleHRfZnJhbWVzJTIwJTNEJTIwbG9hZF92aWRlbyglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZOVmxhYnMlMkZBbnlGbG93JTJGbWFpbiUyRmFzc2V0cyUyRmV2YWx1YXRpb24lMkZleGFtcGxlJTJGdmlkZW9zJTJGMi5tcDQlMjIlMEEpJTVCJTNBOSU1RCUwQWFyciUyMCUzRCUyMG5wLnN0YWNrKCU1Qm5wLmFzYXJyYXkoZi5yZXNpemUoKDgzMiUyQyUyMDQ4MCkpKSUyMGZvciUyMGYlMjBpbiUyMGNvbnRleHRfZnJhbWVzJTVEKS5hc3R5cGUoJTIyZmxvYXQzMiUyMiklMjAlMkYlMjAyNTUuMCUwQWNvbnRleHRfdGVuc29yJTIwJTNEJTIwdG9yY2guZnJvbV9udW1weShhcnIpLnBlcm11dGUoMCUyQyUyMDMlMkMlMjAxJTJDJTIwMikudW5zcXVlZXplKDApLnRvKCUyMmN1ZGElMjIpJTIwJTIwJTIzJTIwKDElMkMlMjA5JTJDJTIwMyUyQyUyMDQ4MCUyQyUyMDgzMiklMEElMEFwcm9tcHQlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwJTIyQSUyMGZvY3VzZWQlMjB0cmFpbCUyMHJ1bm5lcidzJTIwcG93ZXJmdWwlMjBzdHJpZGVzJTIwdGhyb3VnaCUyMGElMjBkZW5zZSUyQyUyMHN1bi1kYXBwbGVkJTIwZm9yZXN0LiUyMCUyMiUwQSUyMCUyMCUyMCUyMCUyMlRoZSUyMGNhbWVyYSUyMHRyYWNrcyUyMGFsb25nc2lkZSUyQyUyMGhpZ2hsaWdodGluZyUyMG11c2N1bGFyJTIwZXhlcnRpb24lMkMlMjBzd2VhdCUyQyUyMGFuZCUyMGRldGVybWluZWQlMjBmYWNpYWwlMjBleHByZXNzaW9uLiUyMiUwQSklMEF2aWRlbyUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwdmlkZW8lM0Rjb250ZXh0X3RlbnNvciUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwbnVtX2ZyYW1lcyUzRDgxJTJDJTBBJTIwJTIwJTIwJTIwJTIzJTIwT3ZlcnJpZGUlMjBjaHVua19wYXJ0aXRpb24lMjBzbyUyMHRoZSUyMGZpcnN0JTIwY2h1bmslMjBjb3ZlcnMlMjBleGFjdGx5JTIwdGhlJTIwMyUyMGxhdGVudCUyMGNvbnRleHQlMjBmcmFtZXMuJTBBJTIwJTIwJTIwJTIwY2h1bmtfcGFydGl0aW9uJTNEJTVCMyUyQyUyMDMlMkMlMjAzJTJDJTIwMyUyQyUyMDMlMkMlMjAzJTJDJTIwMyU1RCUyQyUwQSkuZnJhbWVzJTVCMCU1RCUwQWV4cG9ydF90b192aWRlbyh2aWRlbyUyQyUyMCUyMmFueWZsb3dfZmFyX3Yydi5tcDQlMjIlMkMlMjBmcHMlM0QxNik=",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowFARPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_video
pipe = AnyFlowFARPipeline.from_pretrained(
<span class="hljs-string">&quot;nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># Example conditioning clip from the AnyFlow repo — take the first 9 frames (3 latent frames at VAE temporal stride 4).</span>
context_frames = load_video(
<span class="hljs-string">&quot;https://raw.githubusercontent.com/NVlabs/AnyFlow/main/assets/evaluation/example/videos/2.mp4&quot;</span>
)[:<span class="hljs-number">9</span>]
arr = np.stack([np.asarray(f.resize((<span class="hljs-number">832</span>, <span class="hljs-number">480</span>))) <span class="hljs-keyword">for</span> f <span class="hljs-keyword">in</span> context_frames]).astype(<span class="hljs-string">&quot;float32&quot;</span>) / <span class="hljs-number">255.0</span>
context_tensor = torch.from_numpy(arr).permute(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>).unsqueeze(<span class="hljs-number">0</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-comment"># (1, 9, 3, 480, 832)</span>
prompt = (
<span class="hljs-string">&quot;A focused trail runner&#x27;s powerful strides through a dense, sun-dappled forest. &quot;</span>
<span class="hljs-string">&quot;The camera tracks alongside, highlighting muscular exertion, sweat, and determined facial expression.&quot;</span>
)
video = pipe(
prompt=prompt,
video=context_tensor,
num_inference_steps=<span class="hljs-number">4</span>,
num_frames=<span class="hljs-number">81</span>,
<span class="hljs-comment"># Override chunk_partition so the first chunk covers exactly the 3 latent context frames.</span>
chunk_partition=[<span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>],
).frames[<span class="hljs-number">0</span>]
export_to_video(video, <span class="hljs-string">&quot;anyflow_far_v2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"py",wrap:!1})},$$slots:{default:!0}}),m(t,a)},$$slots:{default:!0}});var Z=e(x,2);i(Z,{title:"Notes",local:"notes",headingTag:"h2"});var I=e(Z,4);i(I,{title:"AnyFlowPipeline",local:"diffusers.AnyFlowPipeline",headingTag:"h2"});var y=e(I,2),G=n(y);o(G,{name:"class diffusers.AnyFlowPipeline",anchor:"diffusers.AnyFlowPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow.py#L80",parameters:[{name:"tokenizer",val:": AutoTokenizer"},{name:"text_encoder",val:": UMT5EncoderModel"},{name:"transformer",val:": AnyFlowTransformer3DModel"},{name:"vae",val:": AutoencoderKLWan"},{name:"scheduler",val:": FlowMapEulerDiscreteScheduler"}],parametersDescription:[{anchor:"diffusers.AnyFlowPipeline.tokenizer",description:`<strong>tokenizer</strong> ([<em>AutoTokenizer</em>]) &#x2014;
Tokenizer from <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a>.`,name:"tokenizer"},{anchor:"diffusers.AnyFlowPipeline.text_encoder",description:`<strong>text_encoder</strong> ([<em>UMT5EncoderModel</em>]) &#x2014;
<a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> text encoder.`,name:"text_encoder"},{anchor:"diffusers.AnyFlowPipeline.transformer",description:`<strong>transformer</strong> ([<em>AnyFlowTransformer3DModel</em>]) &#x2014;
Bidirectional flow-map 3D Transformer.`,name:"transformer"},{anchor:"diffusers.AnyFlowPipeline.vae",description:`<strong>vae</strong> ([<em>AutoencoderKLWan</em>]) &#x2014;
VAE that encodes/decodes videos to and from latent representations.`,name:"vae"},{anchor:"diffusers.AnyFlowPipeline.scheduler",description:`<strong>scheduler</strong> ([<em>FlowMapEulerDiscreteScheduler</em>]) &#x2014;
Flow-map sampler. The pipeline drives <code>scheduler.step(..., timestep, sample, r_timestep)</code> per inference
step.`,name:"scheduler"}]});var g=e(G,4),B=e(n(g));X(B,()=>'<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>z</mi><mi>t</mi></msub><mo>→</mo><msub><mi>z</mi><mi>r</mi></msub></mrow><annotation encoding="application/x-tex">z_t \\to z_r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.044em;">z</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:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</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 class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.0278em;">r</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>');var H=e(B,2);X(H,()=>'<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>z</mi><mi>t</mi></msub><mo>→</mo><msub><mi>z</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">z_t \\to z_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.044em;">z</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:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</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 class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</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>'),l(3),s(g);var f=e(g,6),W=n(f);o(W,{name:"__call__",anchor:"diffusers.AnyFlowPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow.py#L379",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"video",val:": typing.Optional[torch.Tensor] = None"},{name:"video_latents",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": int = 480"},{name:"width",val:": int = 832"},{name:"num_frames",val:": int = 81"},{name:"num_inference_steps",val:": int = 50"},{name:"sigmas",val:": typing.Optional[typing.List[float]] = None"},{name:"timesteps",val:": typing.Optional[typing.List[float]] = None"},{name:"guidance_scale",val:": float = 1.0"},{name:"num_videos_per_prompt",val:": typing.Optional[int] = 1"},{name:"generator",val:": typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'np'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"callback_on_step_end",val:": typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None"},{name:"callback_on_step_end_tensor_inputs",val:": typing.List[str] = ['latents']"},{name:"max_sequence_length",val:": int = 512"},{name:"use_mean_velocity",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.AnyFlowPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the video generation. If not defined, pass <code>prompt_embeds</code> instead.`,name:"prompt"},{anchor:"diffusers.AnyFlowPipeline.__call__.video",description:`<strong>video</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-VAE conditioning frames of shape <code>(B, T, C, H, W)</code> in <code>[0, 1]</code>. When provided, the pipeline
VAE-encodes them and keeps the corresponding latent prefix fixed during sampling. Mutually exclusive
with <code>video_latents</code>.`,name:"video"},{anchor:"diffusers.AnyFlowPipeline.__call__.video_latents",description:`<strong>video_latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-encoded VAE latents in the AnyFlow layout <code>(B, T_latent, C, H_latent, W_latent)</code>. Skips VAE
encoding on the pipeline side. Mutually exclusive with <code>video</code>.`,name:"video_latents"},{anchor:"diffusers.AnyFlowPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to avoid during video generation. Ignored when not using guidance
(<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.AnyFlowPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, defaults to <code>480</code>) &#x2014;
The height in pixels of the generated video.`,name:"height"},{anchor:"diffusers.AnyFlowPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, defaults to <code>832</code>) &#x2014;
The width in pixels of the generated video.`,name:"width"},{anchor:"diffusers.AnyFlowPipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, defaults to <code>81</code>) &#x2014;
The number of frames in the generated video. Must satisfy <code>(num_frames - 1) % vae_scale_factor_temporal == 0</code>.`,name:"num_frames"},{anchor:"diffusers.AnyFlowPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, defaults to <code>50</code>) &#x2014;
The number of denoising steps. Distilled AnyFlow checkpoints support any-step sampling, so values as
low as <code>1</code>, <code>2</code>, <code>4</code>, or <code>8</code> are typical. Ignored when <code>sigmas</code> or <code>timesteps</code> is provided.`,name:"num_inference_steps"},{anchor:"diffusers.AnyFlowPipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom sigma schedule for any-step sampling, in <code>[0, 1]</code> and ordered from noisy to clean. Length
determines the effective <code>num_inference_steps</code>; the scheduler appends the terminal <code>0</code> sigma.`,name:"sigmas"},{anchor:"diffusers.AnyFlowPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom timestep schedule for any-step sampling, in the same units as <code>self.scheduler.timesteps</code> (i.e.
scaled by <code>num_train_timesteps</code>). Mutually exclusive with <code>sigmas</code>.`,name:"timesteps"},{anchor:"diffusers.AnyFlowPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
Classifier-free guidance scale. The released AnyFlow checkpoints fuse CFG into the weights during
training; keep at <code>1.0</code> unless you know your checkpoint expects otherwise.`,name:"guidance_scale"},{anchor:"diffusers.AnyFlowPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
The number of videos to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.AnyFlowPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.AnyFlowPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents to use as inputs. If not provided, latents are sampled from the supplied
<code>generator</code>.`,name:"latents"},{anchor:"diffusers.AnyFlowPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to tweak text inputs (e.g., prompt weighting). If not
provided, embeddings are generated from <code>prompt</code>.`,name:"prompt_embeds"},{anchor:"diffusers.AnyFlowPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings.`,name:"negative_prompt_embeds"},{anchor:"diffusers.AnyFlowPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;np&quot;</code>) &#x2014;
The output format. One of <code>&quot;pil&quot;</code>, <code>&quot;np&quot;</code>, <code>&quot;pt&quot;</code>, or <code>&quot;latent&quot;</code>.`,name:"output_type"},{anchor:"diffusers.AnyFlowPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return an <code>AnyFlowPipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.AnyFlowPipeline.__call__.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"},{anchor:"diffusers.AnyFlowPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function or <code>PipelineCallback</code> called at the end of each inference step. See
<a href="../callbacks"><code>callbacks</code></a> for details.`,name:"callback_on_step_end"},{anchor:"diffusers.AnyFlowPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List[str]</code>, <em>optional</em>, defaults to <code>[&quot;latents&quot;]</code>) &#x2014;
The tensor inputs forwarded to the callback. Must be a subset of <code>self._callback_tensor_inputs</code>.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.AnyFlowPipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
The maximum text-encoder sequence length. Longer prompts are truncated.`,name:"max_sequence_length"},{anchor:"diffusers.AnyFlowPipeline.__call__.use_mean_velocity",description:`<strong>use_mean_velocity</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
When <code>True</code>, the flow-map model is conditioned on both the source timestep <code>t</code> and the target timestep
<code>r</code> to predict a mean velocity, matching the training-time behavior. Disable to mirror raw Euler
stepping (<code>r = t</code>).`,name:"use_mean_velocity"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, <code>AnyFlowPipelineOutput</code> is returned, otherwise a <code>tuple</code> whose first
element is the generated video.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~AnyFlowPipelineOutput</code> or <code>tuple</code></p>
`});var L=e(W,4);S(L,{anchor:"diffusers.AnyFlowPipeline.__call__.example",children:(t,c)=>{var a=q(),r=e(u(a),2);p(r,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUwQSUwQXBpcGUlMjAlM0QlMjBBbnlGbG93UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMm52aWRpYSUyRkFueUZsb3ctV2FuMi4xLVQyVi0xNEItRGlmZnVzZXJzJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwcmVkJTIwcGFuZGElMjBlYXRpbmclMjBiYW1ib28lMjBpbiUyMGElMjBmb3Jlc3QlMkMlMjBjaW5lbWF0aWMlMjBsaWdodGluZyUyMiUwQXZpZGVvJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENCUyQyUyMG51bV9mcmFtZXMlM0QzMykuZnJhbWVzJTVCMCU1RCUwQWV4cG9ydF90b192aWRlbyh2aWRlbyUyQyUyMCUyMmFueWZsb3dfdDJ2Lm1wNCUyMiUyQyUyMGZwcyUzRDE2KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = AnyFlowPipeline.from_pretrained(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;nvidia/AnyFlow-Wan2.1-T2V-14B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A red panda eating bamboo in a forest, cinematic lighting&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>video = pipe(prompt, num_inference_steps=<span class="hljs-number">4</span>, num_frames=<span class="hljs-number">33</span>).frames[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>export_to_video(video, <span class="hljs-string">&quot;anyflow_t2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"python",wrap:!1}),m(t,a)},$$slots:{default:!0}}),s(f);var _=e(f,2),O=n(_);o(O,{name:"encode_prompt",anchor:"diffusers.AnyFlowPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow.py#L179",parameters:[{name:"prompt",val:": str | list[str]"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 226"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"}],parametersDescription:[{anchor:"diffusers.AnyFlowPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use classifier free guidance or not.`,name:"do_classifier_free_guidance"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of videos that should be generated per prompt. torch device to place the resulting embeddings on`,name:"num_videos_per_prompt"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.AnyFlowPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}]}),l(2),s(_);var R=e(_,2),K=n(R);o(K,{name:"encode_video",anchor:"diffusers.AnyFlowPipeline.encode_video",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow.py#L359",parameters:[{name:"video",val:": Tensor"},{name:"height",val:": int"},{name:"width",val:": int"}]}),l(4),s(R),s(y);var C=e(y,2);i(C,{title:"AnyFlowFARPipeline",local:"diffusers.AnyFlowFARPipeline",headingTag:"h2"});var w=e(C,2),V=n(w);o(V,{name:"class diffusers.AnyFlowFARPipeline",anchor:"diffusers.AnyFlowFARPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow_far.py#L92",parameters:[{name:"tokenizer",val:": AutoTokenizer"},{name:"text_encoder",val:": UMT5EncoderModel"},{name:"transformer",val:": AnyFlowFARTransformer3DModel"},{name:"vae",val:": AutoencoderKLWan"},{name:"scheduler",val:": FlowMapEulerDiscreteScheduler"}],parametersDescription:[{anchor:"diffusers.AnyFlowFARPipeline.tokenizer",description:`<strong>tokenizer</strong> ([<em>AutoTokenizer</em>]) &#x2014;
Tokenizer from <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a>.`,name:"tokenizer"},{anchor:"diffusers.AnyFlowFARPipeline.text_encoder",description:`<strong>text_encoder</strong> ([<em>UMT5EncoderModel</em>]) &#x2014;
<a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> text encoder.`,name:"text_encoder"},{anchor:"diffusers.AnyFlowFARPipeline.transformer",description:`<strong>transformer</strong> ([<em>AnyFlowFARTransformer3DModel</em>]) &#x2014;
FAR causal flow-map 3D Transformer.`,name:"transformer"},{anchor:"diffusers.AnyFlowFARPipeline.vae",description:`<strong>vae</strong> ([<em>AutoencoderKLWan</em>]) &#x2014;
VAE that encodes/decodes videos to and from latent representations.`,name:"vae"},{anchor:"diffusers.AnyFlowFARPipeline.scheduler",description:`<strong>scheduler</strong> ([<em>FlowMapEulerDiscreteScheduler</em>]) &#x2014;
Flow-map sampler.`,name:"scheduler"}]});var M=e(V,14),N=n(M);o(N,{name:"__call__",anchor:"diffusers.AnyFlowFARPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow_far.py#L447",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"video",val:": typing.Optional[torch.Tensor] = None"},{name:"video_latents",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": int = 480"},{name:"width",val:": int = 832"},{name:"num_frames",val:": int = 81"},{name:"num_inference_steps",val:": int = 50"},{name:"sigmas",val:": typing.Optional[typing.List[float]] = None"},{name:"timesteps",val:": typing.Optional[typing.List[float]] = None"},{name:"guidance_scale",val:": float = 1.0"},{name:"num_videos_per_prompt",val:": typing.Optional[int] = 1"},{name:"generator",val:": typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'np'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"callback_on_step_end",val:": typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None"},{name:"callback_on_step_end_tensor_inputs",val:": typing.List[str] = ['latents']"},{name:"max_sequence_length",val:": int = 512"},{name:"use_mean_velocity",val:": bool = True"},{name:"use_kv_cache",val:": bool = True"},{name:"chunk_partition",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"diffusers.AnyFlowFARPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the video generation. If not defined, pass <code>prompt_embeds</code> instead.`,name:"prompt"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.video",description:`<strong>video</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-VAE conditioning frames of shape <code>(B, T, C, H, W)</code> in <code>[0, 1]</code> (<code>T = 4n + 1</code>). When provided, the
pipeline VAE-encodes them and keeps the corresponding latent prefix fixed during sampling. Mutually
exclusive with <code>video_latents</code>.`,name:"video"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.video_latents",description:`<strong>video_latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-encoded VAE latents in the FAR layout <code>(B, T_latent, C, H_latent, W_latent)</code>. Skips VAE encoding on
the pipeline side. Mutually exclusive with <code>video</code>.`,name:"video_latents"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to avoid during video generation. Ignored when not using guidance
(<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, defaults to <code>480</code>) &#x2014;
The height in pixels of the generated video.`,name:"height"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, defaults to <code>832</code>) &#x2014;
The width in pixels of the generated video.`,name:"width"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, defaults to <code>81</code>) &#x2014;
The number of frames in the generated video. Must satisfy <code>(num_frames - 1) % vae_scale_factor_temporal == 0</code>.`,name:"num_frames"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, defaults to <code>50</code>) &#x2014;
The number of denoising steps per chunk. Distilled AnyFlow-FAR checkpoints support any-step sampling
(1, 2, 4, 8, &#x2026;). Ignored when <code>sigmas</code> or <code>timesteps</code> is provided.`,name:"num_inference_steps"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.sigmas",description:`<strong>sigmas</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom sigma schedule for any-step sampling, in <code>[0, 1]</code> and ordered from noisy to clean. Length
determines the effective <code>num_inference_steps</code>; the scheduler appends the terminal <code>0</code> sigma.`,name:"sigmas"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>List[float]</code>, <em>optional</em>) &#x2014;
Custom timestep schedule for any-step sampling, in the same units as <code>self.scheduler.timesteps</code> (i.e.
scaled by <code>num_train_timesteps</code>). Mutually exclusive with <code>sigmas</code>.`,name:"timesteps"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
Classifier-free guidance scale. The released AnyFlow checkpoints fuse CFG into the weights during
training; keep at <code>1.0</code> unless the checkpoint requires otherwise.`,name:"guidance_scale"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
The number of videos to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
Generator used to seed sampling.`,name:"generator"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents. If not provided, latents are sampled from the supplied <code>generator</code>.`,name:"latents"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. If not provided, embeddings are generated from <code>prompt</code>.`,name:"prompt_embeds"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings.`,name:"negative_prompt_embeds"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;np&quot;</code>) &#x2014;
Output format. One of <code>&quot;pil&quot;</code>, <code>&quot;np&quot;</code>, <code>&quot;pt&quot;</code>, or <code>&quot;latent&quot;</code>.`,name:"output_type"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return an <code>AnyFlowPipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.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"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function or <code>PipelineCallback</code> called at the end of each inference step.`,name:"callback_on_step_end"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List[str]</code>, <em>optional</em>, defaults to <code>[&quot;latents&quot;]</code>) &#x2014;
Tensor inputs forwarded to the callback. Must be a subset of <code>self._callback_tensor_inputs</code>.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
The maximum text-encoder sequence length.`,name:"max_sequence_length"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.use_mean_velocity",description:`<strong>use_mean_velocity</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
When <code>True</code>, condition the flow-map model on both the source timestep <code>t</code> and the target timestep <code>r</code>
to predict a mean velocity. Disable to mirror raw Euler stepping.`,name:"use_mean_velocity"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.use_kv_cache",description:`<strong>use_kv_cache</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Reuse the FAR attention KV cache across causal chunks. Disable only for debugging.`,name:"use_kv_cache"},{anchor:"diffusers.AnyFlowFARPipeline.__call__.chunk_partition",description:`<strong>chunk_partition</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Per-chunk frame counts. Defaults to <code>self.transformer.config.chunk_partition</code> (matched to the released
81-frame checkpoints). When you change <code>num_frames</code>, supply a <code>chunk_partition</code> that sums to
<code>(num_frames - 1) // vae_scale_factor_temporal + 1</code>.`,name:"chunk_partition"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, an <code>AnyFlowPipelineOutput</code> is returned, otherwise a <code>tuple</code> whose first
element is the generated video.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~AnyFlowPipelineOutput</code> or <code>tuple</code></p>
`});var $=e(N,4);S($,{anchor:"diffusers.AnyFlowFARPipeline.__call__.example",children:(t,c)=>{var a=q(),r=e(u(a),2);p(r,{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW55Rmxvd0ZBUlBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUyQyUyMGxvYWRfaW1hZ2UlMEElMEFwaXBlJTIwJTNEJTIwQW55Rmxvd0ZBUlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJudmlkaWElMkZBbnlGbG93LUZBUi1XYW4yLjEtMS4zQi1EaWZmdXNlcnMlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMFNpbmdsZS1mcmFtZSUyMEkyViUzQSUyMHdyYXAlMjB0aGUlMjBjb25kaXRpb25pbmclMjBpbWFnZSUyMGFzJTIwYSUyMCgxJTJDJTIwMSUyQyUyMDMlMkMlMjBIJTJDJTIwVyklMjB0ZW5zb3IlMjBpbiUyMCU1QjAlMkMlMjAxJTVELiUwQWZpcnN0X2ZyYW1lJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJwYXRoJTJGdG8lMkZmaXJzdF9mcmFtZS5wbmclMjIpLnJlc2l6ZSgoODMyJTJDJTIwNDgwKSklMEFhcnIlMjAlM0QlMjBucC5hc2FycmF5KGZpcnN0X2ZyYW1lKS5hc3R5cGUoJTIyZmxvYXQzMiUyMiklMjAlMkYlMjAyNTUuMCUwQWNvbnRleHQlMjAlM0QlMjB0b3JjaC5mcm9tX251bXB5KGFycikucGVybXV0ZSgyJTJDJTIwMCUyQyUyMDEpLnVuc3F1ZWV6ZSgwKS51bnNxdWVlemUoMSkudG8oJTIyY3VkYSUyMiklMEElMEF2aWRlbyUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyYSUyMGNhdCUyMHdhbGtzJTIwYWNyb3NzJTIwYSUyMHN1bmxpdCUyMGxhd24lMjIlMkMlMEElMjAlMjAlMjAlMjB2aWRlbyUzRGNvbnRleHQlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENCUyQyUwQSUyMCUyMCUyMCUyMG51bV9mcmFtZXMlM0Q4MSUyQyUwQSkuZnJhbWVzJTVCMCU1RCUwQWV4cG9ydF90b192aWRlbyh2aWRlbyUyQyUyMCUyMmFueWZsb3dfZmFyLm1wNCUyMiUyQyUyMGZwcyUzRDE2KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnyFlowFARPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = AnyFlowFARPipeline.from_pretrained(
<span class="hljs-meta">... </span> <span class="hljs-string">&quot;nvidia/AnyFlow-FAR-Wan2.1-1.3B-Diffusers&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Single-frame I2V: wrap the conditioning image as a (1, 1, 3, H, W) tensor in [0, 1].</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>first_frame = load_image(<span class="hljs-string">&quot;path/to/first_frame.png&quot;</span>).resize((<span class="hljs-number">832</span>, <span class="hljs-number">480</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>arr = np.asarray(first_frame).astype(<span class="hljs-string">&quot;float32&quot;</span>) / <span class="hljs-number">255.0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>context = torch.from_numpy(arr).permute(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>).unsqueeze(<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">1</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = pipe(
<span class="hljs-meta">... </span> prompt=<span class="hljs-string">&quot;a cat walks across a sunlit lawn&quot;</span>,
<span class="hljs-meta">... </span> video=context,
<span class="hljs-meta">... </span> num_inference_steps=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span> num_frames=<span class="hljs-number">81</span>,
<span class="hljs-meta">... </span>).frames[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>export_to_video(video, <span class="hljs-string">&quot;anyflow_far.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,lang:"python",wrap:!1}),m(t,a)},$$slots:{default:!0}}),s(M);var b=e(M,2),ee=n(b);o(ee,{name:"encode_prompt",anchor:"diffusers.AnyFlowFARPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow_far.py#L196",parameters:[{name:"prompt",val:": str | list[str]"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"num_videos_per_prompt",val:": int = 1"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"max_sequence_length",val:": int = 226"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"dtype",val:": typing.Optional[torch.dtype] = None"}],parametersDescription:[{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use classifier free guidance or not.`,name:"do_classifier_free_guidance"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of videos that should be generated per prompt. torch device to place the resulting embeddings on`,name:"num_videos_per_prompt"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.AnyFlowFARPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}]}),l(2),s(b);var P=e(b,2),ne=n(P);o(ne,{name:"encode_video",anchor:"diffusers.AnyFlowFARPipeline.encode_video",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_anyflow_far.py#L379",parameters:[{name:"video",val:": Tensor"},{name:"height",val:": int"},{name:"width",val:": int"}]}),l(4),s(P),s(w);var E=e(w,2);i(E,{title:"AnyFlowPipelineOutput",local:"diffusers.pipelines.anyflow.pipeline_output.AnyFlowPipelineOutput",headingTag:"h2"});var v=e(E,2),se=n(v);o(se,{name:"class diffusers.pipelines.anyflow.pipeline_output.AnyFlowPipelineOutput",anchor:"diffusers.pipelines.anyflow.pipeline_output.AnyFlowPipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14217/src/diffusers/pipelines/anyflow/pipeline_output.py#L23",parameters:[{name:"frames",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.pipelines.anyflow.pipeline_output.AnyFlowPipelineOutput.frames",description:`<strong>frames</strong> (<code>torch.Tensor</code>, <code>np.ndarray</code>, or list[list[PIL.Image.Image]]) &#x2014;
list of video outputs - It can be a nested list of length <code>batch_size,</code> with each sub-list containing
denoised PIL image sequences of length <code>num_frames.</code> It can also be a NumPy array or Torch tensor of shape
<code>(batch_size, num_frames, channels, height, width)</code>.`,name:"frames"}]}),l(2),s(v);var oe=e(v,2);pe(oe,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/anyflow.md"}),l(2),m(Y,U),ue()}export{Te as component};

Xet Storage Details

Size:
69.6 kB
·
Xet hash:
6661e42ae325dc302a782acc0c19b19ace5eb840c05fd27cdbe2dc757f6fafdf

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