import{s as Na,o as xa,n as Ea}from"../chunks/scheduler.8c3d61f6.js";import{S as Ha,i as za,g as m,s as n,r as o,A as Sa,h as M,f as a,c as s,j as R,u as i,x as J,k,y as u,a as t,v as r,d,t as p,w as c,m as Aa,n as $a}from"../chunks/index.da70eac4.js";import{T as Da}from"../chunks/Tip.1d9b8c37.js";import{D as Ee}from"../chunks/Docstring.932cdff3.js";import{C as _}from"../chunks/CodeBlock.a9c4becf.js";import{E as Qa}from"../chunks/ExampleCodeBlock.c0461b09.js";import{H as U,E as La}from"../chunks/index.ef90fe87.js";function qa(X){let h;return{c(){h=Aa("You can improve the quality of the generated video by running the decoding step in full precision.")},l(w){h=$a(w,"You can improve the quality of the generated video by running the decoding step in full precision.")},m(w,g){t(w,h,g)},d(w){w&&a(h)}}}function Pa(X){let h,w="Examples:",g,f,b;return f=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9lbmNvZGVyS0xXYW4lMkMlMjBXYW5QaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMuc2NoZWR1bGVycy5zY2hlZHVsaW5nX3VuaXBjX211bHRpc3RlcCUyMGltcG9ydCUyMFVuaVBDTXVsdGlzdGVwU2NoZWR1bGVyJTBBJTBBJTIzJTIwQXZhaWxhYmxlJTIwbW9kZWxzJTNBJTIwV2FuLUFJJTJGV2FuMi4xLVQyVi0xNEItRGlmZnVzZXJzJTJDJTIwV2FuLUFJJTJGV2FuMi4xLVQyVi0xLjNCLURpZmZ1c2VycyUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyV2FuLUFJJTJGV2FuMi4xLVQyVi0xNEItRGlmZnVzZXJzJTIyJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTFdhbi5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQl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TIyJTJDJTIwZnBzJTNEMTYp",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.utils <span class="hljs-keyword">import</span> export_to_video
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.schedulers.scheduling_unipc_multistep <span class="hljs-keyword">import</span> UniPCMultistepScheduler

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-14B-Diffusers&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>flow_shift = <span class="hljs-number">5.0</span>  <span class="hljs-comment"># 5.0 for 720P, 3.0 for 480P</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>output = pipe(
<span class="hljs-meta">... </span>    prompt=prompt,
<span class="hljs-meta">... </span>    negative_prompt=negative_prompt,
<span class="hljs-meta">... </span>    height=<span class="hljs-number">720</span>,
<span class="hljs-meta">... </span>    width=<span class="hljs-number">1280</span>,
<span class="hljs-meta">... </span>    num_frames=<span class="hljs-number">81</span>,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">5.0</span>,
<span class="hljs-meta">... </span>).frames[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>export_to_video(output, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),{c(){h=m("p"),h.textContent=w,g=n(),o(f.$$.fragment)},l(y){h=M(y,"P",{"data-svelte-h":!0}),J(h)!=="svelte-kvfsh7"&&(h.textContent=w),g=s(y),i(f.$$.fragment,y)},m(y,T){t(y,h,T),t(y,g,T),r(f,y,T),b=!0},p:Ea,i(y){b||(d(f.$$.fragment,y),b=!0)},o(y){p(f.$$.fragment,y),b=!1},d(y){y&&(a(h),a(g)),c(f,y)}}}function Ka(X){let h,w="Examples:",g,f,b;return f=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b2VuY29kZXJLTFdhbiUyQyUyMFdhbkltYWdlVG9WaWRlb1BpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUyQyUyMGxvYWRf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0aXZlX3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMGhlaWdodCUzRGhlaWdodCUyQyUwQSUyMCUyMCUyMCUyMHdpZHRoJTNEd2lkdGglMkMlMEElMjAlMjAlMjAlMjBudW1fZnJhbWVzJTNEODElMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDUuMCUyQyUwQSkuZnJhbWVzJTVCMCU1RCUwQWV4cG9ydF90b192aWRlbyhvdXRwdXQlMkMlMjAlMjJvdXRwdXQubXA0JTIyJTJDJTIwZnBzJTNEMTYp",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">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanImageToVideoPipeline
<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><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPVisionModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-I2V-14B-480P-Diffusers&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image_encoder = CLIPVisionModel.from_pretrained(
<span class="hljs-meta">... </span>    model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = WanImageToVideoPipeline.from_pretrained(
<span class="hljs-meta">... </span>    model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>image = load_image(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>max_area = <span class="hljs-number">480</span> * <span class="hljs-number">832</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>aspect_ratio = image.height / image.width
<span class="hljs-meta">&gt;&gt;&gt; </span>mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
<span class="hljs-meta">&gt;&gt;&gt; </span>width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
<span class="hljs-meta">&gt;&gt;&gt; </span>image = image.resize((width, height))
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = (
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in &quot;</span>
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>output = pipe(
<span class="hljs-meta">... </span>    image=image,
<span class="hljs-meta">... </span>    prompt=prompt,
<span class="hljs-meta">... </span>    negative_prompt=negative_prompt,
<span class="hljs-meta">... </span>    height=height,
<span class="hljs-meta">... </span>    width=width,
<span class="hljs-meta">... </span>    num_frames=<span class="hljs-number">81</span>,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">5.0</span>,
<span class="hljs-meta">... </span>).frames[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>export_to_video(output, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),{c(){h=m("p"),h.textContent=w,g=n(),o(f.$$.fragment)},l(y){h=M(y,"P",{"data-svelte-h":!0}),J(h)!=="svelte-kvfsh7"&&(h.textContent=w),g=s(y),i(f.$$.fragment,y)},m(y,T){t(y,h,T),t(y,g,T),r(f,y,T),b=!0},p:Ea,i(y){b||(d(f.$$.fragment,y),b=!0)},o(y){p(f.$$.fragment,y),b=!1},d(y){y&&(a(h),a(g)),c(f,y)}}}function Oa(X){let h,w,g,f,b,y,T,ma='<img alt="LoRA" src="https://img.shields.io/badge/LoRA-d8b4fe?style=flat"/>',Ke,N,Ma='<a href="https://github.com/Wan-Video/Wan2.1" rel="nofollow">Wan 2.1</a> by the Alibaba Wan Team.',Oe,x,el,H,ya="We will first need to install some additional dependencies.",ll,z,al,S,tl,A,ha=`The following example requires 11GB VRAM to run and uses the smaller <code>Wan-AI/Wan2.1-T2V-1.3B-Diffusers</code> model. You can switch it out
for the larger <code>Wan2.1-I2V-14B-720P-Diffusers</code> or <code>Wan-AI/Wan2.1-I2V-14B-480P-Diffusers</code> if you have at least 35GB VRAM available.`,nl,$,sl,C,ol,D,il,L,rl,q,ua=`The Image to Video pipeline requires loading the <code>AutoencoderKLWan</code> and the <code>CLIPVisionModel</code> components in full precision. The following example will need at least
35GB of VRAM to run.`,dl,P,pl,K,cl,O,ml,ee,Ml,le,yl,ae,hl,te,Ja="Base inference with the large 14B Wan 2.1 models can take up to 35GB of VRAM when generating videos at 720p resolution. We’ll outline a few memory optimizations we can apply to reduce the VRAM required to run the model.",ul,ne,fa="We’ll use <code>Wan-AI/Wan2.1-I2V-14B-720P-Diffusers</code> model in these examples to demonstrate the memory savings, but the techniques are applicable to all model checkpoints.",Jl,se,fl,oe,ga='Find more information about group offloading <a href="../optimization/memory.md">here</a>',gl,ie,bl,re,ba="We can reduce our VRAM requirements by applying group offloading to the larger model components of the pipeline; the <code>WanTransformer3DModel</code> and <code>UMT5EncoderModel</code>. Group offloading will break up the individual modules of a model and offload/onload them onto your GPU as needed during inference. In this example, we’ll apply <code>block_level</code> offloading, which will group the modules in a model into blocks of size <code>num_blocks_per_group</code> and offload/onload them to GPU. Moving to between CPU and GPU does add latency to the inference process. You can trade off between latency and memory savings by increasing or decreasing the <code>num_blocks_per_group</code>.",Ul,de,Ua="The following example will now only require 14GB of VRAM to run, but will take approximately 30 minutes to generate a video.",wl,pe,Tl,ce,Zl,me,wa='We can speed up group offloading inference, by enabling the use of <a href="https://pytorch.org/docs/stable/generated/torch.cuda.Stream.html" rel="nofollow">CUDA streams</a>. However, using CUDA streams requires moving the model parameters into pinned memory. This allocation is handled by Pytorch under the hood, and can result in a significant spike in CPU RAM usage. Please consider this option if your CPU RAM is atleast 2X the size of the model you are group offloading.',jl,Me,Ta="In the following example we will use CUDA streams when group offloading the <code>WanTransformer3DModel</code>. When testing on an A100, this example will require 14GB of VRAM, 52GB of CPU RAM, but will generate a video in approximately 9 minutes.",Wl,ye,_l,he,Bl,ue,Za='Find more information about layerwise casting <a href="../optimization/memory.md">here</a>',Gl,Je,ja="In this example, we will model offloading with layerwise casting. Layerwise casting will downcast each layer’s weights to <code>torch.float8_e4m3fn</code>, temporarily upcast to <code>torch.bfloat16</code> during the forward pass of the layer, then revert to <code>torch.float8_e4m3fn</code> afterward. This approach reduces memory requirements by approximately 50% while introducing a minor quality reduction in the generated video due to the precision trade-off.",Il,fe,Wa="This example will require 20GB of VRAM.",kl,ge,vl,be,Vl,Ue,_a="Wan can be used with many different schedulers, each with their own benefits regarding speed and generation quality. By default, Wan uses the <code>UniPCMultistepScheduler(prediction_type=&quot;flow_prediction&quot;, use_flow_sigmas=True, flow_shift=3.0)</code> scheduler. You can use a different scheduler as follows:",Rl,we,Xl,Te,Cl,Ze,Ba=`The <code>WanTransformer3DModel</code> and <code>AutoencoderKLWan</code> models support loading checkpoints in their original format via the <code>from_single_file</code> loading
method.`,Fl,je,Yl,We,Ql,_e,Ga='<li>Keep <code>AutencoderKLWan</code> in <code>torch.float32</code> for better decoding quality.</li> <li><code>num_frames</code> should satisfy the following constraint: <code>(num_frames - 1) % 4 == 0</code></li> <li>For smaller resolution videos, try lower values of <code>shift</code> (between <code>2.0</code> to <code>5.0</code>) in the <a href="https://huggingface.co/docs/diffusers/main/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler.shift" rel="nofollow">Scheduler</a>. For larger resolution videos, try higher values (between <code>7.0</code> and <code>12.0</code>). The default value is <code>3.0</code> for Wan.</li>',El,Be,Nl,Z,Ge,Pl,Ne,Ia="Pipeline for text-to-video generation using Wan.",Kl,xe,ka=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,Ol,B,Ie,ea,He,va="The call function to the pipeline for generation.",la,F,aa,Y,ke,ta,ze,Va="Encodes the prompt into text encoder hidden states.",xl,ve,Hl,j,Ve,na,Se,Ra="Pipeline for image-to-video generation using Wan.",sa,Ae,Xa=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,oa,G,Re,ia,$e,Ca="The call function to the pipeline for generation.",ra,Q,da,E,Xe,pa,De,Fa="Encodes the prompt into text encoder hidden states.",zl,Ce,Sl,v,Fe,ca,Le,Ya="Output class for Wan pipelines.",Al,Ye,$l,Pe,Dl;return b=new U({props:{title:"Wan",local:"wan",headingTag:"h1"}}),x=new U({props:{title:"Generating Videos with Wan 2.1",local:"generating-videos-with-wan-21",headingTag:"h2"}}),z=new _({props:{code:"cGlwJTIwaW5zdGFsbCUyMC11JTIwZnRmeSUyMGltYWdlaW8tZmZtcGVnJTIwaW1hZ2Vpbw==",highlighted:"pip install -u ftfy imageio-ffmpeg imageio",wrap:!1}}),S=new U({props:{title:"Text to Video Generation",local:"text-to-video-generation",headingTag:"h3"}}),$=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFdhblBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b192aWRlbyUwQSUwQSUyMyUyMEF2YWlsYWJsZSUyMG1vZGVscyUzQSUyMFdhbi1BSSUyRldhbjIuMS1JMlYtMTRCLTcyMFAtRGlmZnVzZXJzJTIwb3IlMjBXYW4tQUklMkZXYW4yLjEtSTJWLTE0Qi00ODBQLURpZmZ1c2VycyUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyV2FuLUFJJTJGV2FuMi4xLVQyVi0xLjNCLURpZmZ1c2VycyUyMiUwQSUwQXBpcGUlMjAlM0QlMjBXYW5QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwY2F0JTIwYW5kJTIwYSUyMGRvZyUyMGJha2luZyUyMGElMjBjYWtlJTIw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Fja2dyb3VuZCUyQyUyMHdhbGtpbmclMjBiYWNrd2FyZHMlMjIlMEFudW1fZnJhbWVzJTIwJTNEJTIwMzMlMEElMEFmcmFtZXMlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3Byb21wdCUyQyUyMG51bV9mcmFtZXMlM0RudW1fZnJhbWVzKS5mcmFtZXMlNUIwJTVEJTBBZXhwb3J0X3RvX3ZpZGVvKGZyYW1lcyUyQyUyMCUyMndhbi10MnYubXA0JTIyJTJDJTIwZnBzJTNEMTYp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> WanPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video

<span class="hljs-comment"># Available models: Wan-AI/Wan2.1-I2V-14B-720P-Diffusers or Wan-AI/Wan2.1-I2V-14B-480P-Diffusers</span>
model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-1.3B-Diffusers&quot;</span>

pipe = WanPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window.&quot;</span>
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>
num_frames = <span class="hljs-number">33</span>

frames = pipe(prompt=prompt, negative_prompt=negative_prompt, num_frames=num_frames).frames[<span class="hljs-number">0</span>]
export_to_video(frames, <span class="hljs-string">&quot;wan-t2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),C=new Da({props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ydF90b192aWRlbyhmcmFtZXMlMkMlMjAlMjJ3YW4tdDJ2Lm1wNCUyMiUyQyUyMGZwcyUzRDE2KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> WanPipeline, AutoencoderKLWan
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video

model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-1.3B-Diffusers&quot;</span>

vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)

<span class="hljs-comment"># replace this with pipe.to(&quot;cuda&quot;) if you have sufficient VRAM</span>
pipe.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window.&quot;</span>
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>
num_frames = <span class="hljs-number">33</span>

frames = pipe(prompt=prompt, num_frames=num_frames).frames[<span class="hljs-number">0</span>]
export_to_video(frames, <span class="hljs-string">&quot;wan-t2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),L=new U({props:{title:"Image to Video Generation",local:"image-to-video-generation",headingTag:"h3"}}),P=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b2VuY29kZXJLTFdhbiUyQyUyMFdhbkltYWdlVG9WaWRlb1BpcGVsaW5lJT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BiYWNrZ3JvdW5kJTJDJTIwd2Fsa2luZyUyMGJhY2t3YXJkcyUyMiUwQSUwQW51bV9mcmFtZXMlMjAlM0QlMjAzMyUwQSUwQW91dHB1dCUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMGhlaWdodCUzRGhlaWdodCUyQyUwQSUyMCUyMCUyMCUyMHdpZHRoJTNEd2lkdGglMkMlMEElMjAlMjAlMjAlMjBudW1fZnJhbWVzJTNEbnVtX2ZyYW1lcyUyQyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNENS4wJTJDJTBBKS5mcmFtZXMlNUIwJTVEJTBBZXhwb3J0X3RvX3ZpZGVvKG91dHB1dCUyQyUyMCUyMndhbi1pMnYubXA0JTIyJTJDJTIwZnBzJTNEMTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPVisionModel

<span class="hljs-comment"># Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers</span>
model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-I2V-14B-480P-Diffusers&quot;</span>
image_encoder = CLIPVisionModel.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32
)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
pipe = WanImageToVideoPipeline.from_pretrained(
    model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
)

<span class="hljs-comment"># replace this with pipe.to(&quot;cuda&quot;) if you have sufficient VRAM</span>
pipe.enable_model_cpu_offload()

image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>
)

max_area = <span class="hljs-number">480</span> * <span class="hljs-number">832</span>
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))

prompt = (
    <span class="hljs-string">&quot;An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in &quot;</span>
    <span class="hljs-string">&quot;the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.&quot;</span>
)
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>

num_frames = <span class="hljs-number">33</span>

output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=height,
    width=width,
    num_frames=num_frames,
    guidance_scale=<span class="hljs-number">5.0</span>,
).frames[<span class="hljs-number">0</span>]
export_to_video(output, <span class="hljs-string">&quot;wan-i2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),K=new U({props:{title:"First and Last Frame Interpolation",local:"first-and-last-frame-interpolation",headingTag:"h3"}}),O=new _({props:{code:" ",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">import</span> torchvision.transforms.functional <span class="hljs-keyword">as</span> TF
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPVisionModel


model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-FLF2V-14B-720P-diffusers&quot;</span>
image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
pipe = WanImageToVideoPipeline.from_pretrained(
    model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

first_frame = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png&quot;</span>)
last_frame = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png&quot;</span>)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">aspect_ratio_resize</span>(<span class="hljs-params">image, pipe, max_area=<span class="hljs-number">720</span> * <span class="hljs-number">1280</span></span>):
    aspect_ratio = image.height / image.width
    mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
    height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
    width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
    image = image.resize((width, height))
    <span class="hljs-keyword">return</span> image, height, width

<span class="hljs-keyword">def</span> <span class="hljs-title function_">center_crop_resize</span>(<span class="hljs-params">image, height, width</span>):
    <span class="hljs-comment"># Calculate resize ratio to match first frame dimensions</span>
    resize_ratio = <span class="hljs-built_in">max</span>(width / image.width, height / image.height)
    
    <span class="hljs-comment"># Resize the image</span>
    width = <span class="hljs-built_in">round</span>(image.width * resize_ratio)
    height = <span class="hljs-built_in">round</span>(image.height * resize_ratio)
    size = [width, height]
    image = TF.center_crop(image, size)
    
    <span class="hljs-keyword">return</span> image, height, width

first_frame, height, width = aspect_ratio_resize(first_frame, pipe)
<span class="hljs-keyword">if</span> last_frame.size != first_frame.size:
    last_frame, _, _ = center_crop_resize(last_frame, height, width)

prompt = <span class="hljs-string">&quot;CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird&#x27;s feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective.&quot;</span>

output = pipe(
    image=first_frame, last_image=last_frame, prompt=prompt, height=height, width=width, guidance_scale=<span class="hljs-number">5.5</span>
).frames[<span class="hljs-number">0</span>]
export_to_video(output, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),ee=new U({props:{title:"Video to Video Generation",local:"video-to-video-generation",headingTag:"h3"}}),le=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF92aWRlbyUyQyUyMGV4cG9ydF90b192aWRlbyUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBBdXRvZW5jb2RlcktMV2FuJTJDJTIwV2FuVmlkZW9Ub1ZpZGVvUGlwZWxpbmUlMkMlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlciUwQSUwQSUyMyUyMEF2YWlsYWJsZSUyMG1vZGVscyUzQSUyMFdhbi1BSSUyRldhbjIuMS1UMlYtMTRCLURpZmZ1c2VycyUyQyU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TIwcGlwZSglMEElMjAlMjAlMjAlMjB2aWRlbyUzRHZpZGVvJTJDJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwaGVpZ2h0JTNENDgwJTJDJTBBJTIwJTIwJTIwJTIwd2lkdGglM0Q1MTIlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDcuMCUyQyUwQSUyMCUyMCUyMCUyMHN0cmVuZ3RoJTNEMC43JTJDJTBBKS5mcmFtZXMlNUIwJTVEJTBBJTBBZXhwb3J0X3RvX3ZpZGVvKG91dHB1dCUyQyUyMCUyMndhbi12MnYubXA0JTIyJTJDJTIwZnBzJTNEMTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_video, export_to_video
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanVideoToVideoPipeline, UniPCMultistepScheduler

<span class="hljs-comment"># Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers</span>
model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-1.3B-Diffusers&quot;</span>
vae = AutoencoderKLWan.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32
)
pipe = WanVideoToVideoPipeline.from_pretrained(
    model_id, vae=vae, torch_dtype=torch.bfloat16
)
flow_shift = <span class="hljs-number">3.0</span>  <span class="hljs-comment"># 5.0 for 720P, 3.0 for 480P</span>
pipe.scheduler = UniPCMultistepScheduler.from_config(
    pipe.scheduler.config, flow_shift=flow_shift
)
<span class="hljs-comment"># change to pipe.to(&quot;cuda&quot;) if you have sufficient VRAM</span>
pipe.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;A robot standing on a mountain top. The sun is setting in the background&quot;</span>
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>
video = load_video(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/hiker.mp4&quot;</span>
)
output = pipe(
    video=video,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=<span class="hljs-number">480</span>,
    width=<span class="hljs-number">512</span>,
    guidance_scale=<span class="hljs-number">7.0</span>,
    strength=<span class="hljs-number">0.7</span>,
).frames[<span class="hljs-number">0</span>]

export_to_video(output, <span class="hljs-string">&quot;wan-v2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),ae=new U({props:{title:"Memory Optimizations for Wan 2.1",local:"memory-optimizations-for-wan-21",headingTag:"h2"}}),se=new U({props:{title:"Group Offloading the Transformer and UMT5 Text Encoder",local:"group-offloading-the-transformer-and-umt5-text-encoder",headingTag:"h3"}}),ie=new U({props:{title:"Block Level Group Offloading",local:"block-level-group-offloading",headingTag:"h4"}}),pe=new _({props:{code:" ",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanTransformer3DModel, WanImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.hooks.group_offloading <span class="hljs-keyword">import</span> apply_group_offloading
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> UMT5EncoderModel, CLIPVisionModel

<span class="hljs-comment"># Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers</span>
model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-I2V-14B-720P-Diffusers&quot;</span>
image_encoder = CLIPVisionModel.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32
)

text_encoder = UMT5EncoderModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, torch_dtype=torch.bfloat16)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
transformer = WanTransformer3DModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)

onload_device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>)
offload_device = torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)

apply_group_offloading(text_encoder,
    onload_device=onload_device,
    offload_device=offload_device,
    offload_type=<span class="hljs-string">&quot;block_level&quot;</span>,
    num_blocks_per_group=<span class="hljs-number">4</span>
)

transformer.enable_group_offload(
    onload_device=onload_device,
    offload_device=offload_device,
    offload_type=<span class="hljs-string">&quot;block_level&quot;</span>,
    num_blocks_per_group=<span class="hljs-number">4</span>,
)
pipe = WanImageToVideoPipeline.from_pretrained(
    model_id,
    vae=vae,
    transformer=transformer,
    text_encoder=text_encoder,
    image_encoder=image_encoder,
    torch_dtype=torch.bfloat16
)
<span class="hljs-comment"># Since we&#x27;ve offloaded the larger models already, we can move the rest of the model components to GPU</span>
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>
)

max_area = <span class="hljs-number">720</span> * <span class="hljs-number">832</span>
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))

prompt = (
    <span class="hljs-string">&quot;An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in &quot;</span>
    <span class="hljs-string">&quot;the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.&quot;</span>
)
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>

num_frames = <span class="hljs-number">33</span>

output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=height,
    width=width,
    num_frames=num_frames,
    guidance_scale=<span class="hljs-number">5.0</span>,
).frames[<span class="hljs-number">0</span>]

export_to_video(output, <span class="hljs-string">&quot;wan-i2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),ce=new U({props:{title:"Block Level Group Offloading with CUDA Streams",local:"block-level-group-offloading-with-cuda-streams",headingTag:"h4"}}),ye=new _({props:{code:" ",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanTransformer3DModel, WanImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.hooks.group_offloading <span class="hljs-keyword">import</span> apply_group_offloading
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> UMT5EncoderModel, CLIPVisionModel

<span class="hljs-comment"># Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers</span>
model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-I2V-14B-720P-Diffusers&quot;</span>
image_encoder = CLIPVisionModel.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32
)

text_encoder = UMT5EncoderModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, torch_dtype=torch.bfloat16)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)
transformer = WanTransformer3DModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)

onload_device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>)
offload_device = torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)

apply_group_offloading(text_encoder,
    onload_device=onload_device,
    offload_device=offload_device,
    offload_type=<span class="hljs-string">&quot;block_level&quot;</span>,
    num_blocks_per_group=<span class="hljs-number">4</span>
)

transformer.enable_group_offload(
    onload_device=onload_device,
    offload_device=offload_device,
    offload_type=<span class="hljs-string">&quot;leaf_level&quot;</span>,
    use_stream=<span class="hljs-literal">True</span>
)
pipe = WanImageToVideoPipeline.from_pretrained(
    model_id,
    vae=vae,
    transformer=transformer,
    text_encoder=text_encoder,
    image_encoder=image_encoder,
    torch_dtype=torch.bfloat16
)
<span class="hljs-comment"># Since we&#x27;ve offloaded the larger models already, we can move the rest of the model components to GPU</span>
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>
)

max_area = <span class="hljs-number">720</span> * <span class="hljs-number">832</span>
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))

prompt = (
    <span class="hljs-string">&quot;An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in &quot;</span>
    <span class="hljs-string">&quot;the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.&quot;</span>
)
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>

num_frames = <span class="hljs-number">33</span>

output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=height,
    width=width,
    num_frames=num_frames,
    guidance_scale=<span class="hljs-number">5.0</span>,
).frames[<span class="hljs-number">0</span>]

export_to_video(output, <span class="hljs-string">&quot;wan-i2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),he=new U({props:{title:"Applying Layerwise Casting to the Transformer",local:"applying-layerwise-casting-to-the-transformer",headingTag:"h3"}}),ge=new _({props:{code:" ",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, WanTransformer3DModel, WanImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.hooks.group_offloading <span class="hljs-keyword">import</span> apply_group_offloading
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> UMT5EncoderModel, CLIPVisionModel

model_id = <span class="hljs-string">&quot;Wan-AI/Wan2.1-I2V-14B-720P-Diffusers&quot;</span>
image_encoder = CLIPVisionModel.from_pretrained(
    model_id, subfolder=<span class="hljs-string">&quot;image_encoder&quot;</span>, torch_dtype=torch.float32
)
text_encoder = UMT5EncoderModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, torch_dtype=torch.bfloat16)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, torch_dtype=torch.float32)

transformer = WanTransformer3DModel.from_pretrained(model_id, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)
transformer.enable_layerwise_casting(storage_dtype=torch.float8_e4m3fn, compute_dtype=torch.bfloat16)

pipe = WanImageToVideoPipeline.from_pretrained(
    model_id,
    vae=vae,
    transformer=transformer,
    text_encoder=text_encoder,
    image_encoder=image_encoder,
    torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()
image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg&quot;</span>)

max_area = <span class="hljs-number">720</span> * <span class="hljs-number">832</span>
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[<span class="hljs-number">1</span>]
height = <span class="hljs-built_in">round</span>(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = <span class="hljs-built_in">round</span>(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))
prompt = (
    <span class="hljs-string">&quot;An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in &quot;</span>
    <span class="hljs-string">&quot;the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.&quot;</span>
)
negative_prompt = <span class="hljs-string">&quot;Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards&quot;</span>
num_frames = <span class="hljs-number">33</span>

output = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    height=height,
    width=width,
    num_frames=num_frames,
    num_inference_steps=<span class="hljs-number">50</span>,
    guidance_scale=<span class="hljs-number">5.0</span>,
).frames[<span class="hljs-number">0</span>]
export_to_video(output, <span class="hljs-string">&quot;wan-i2v.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),be=new U({props:{title:"Using a Custom Scheduler",local:"using-a-custom-scheduler",headingTag:"h2"}}),we=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEZsb3dNYXRjaEV1bGVyRGlzY3JldGVTY2hlZHVsZXIlMkMlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlciUyQyUyMFdhblBpcGVsaW5lJTBBJTBBc2NoZWR1bGVyX2ElMjAlM0QlMjBGbG93TWF0Y2hFdWxlckRpc2NyZXRlU2NoZWR1bGVyKHNoaWZ0JTNENS4wKSUwQXNjaGVkdWxlcl9iJTIwJTNEJTIwVW5pUENNdWx0aXN0ZXBTY2hlZHVsZXIocHJlZGljdGlvbl90eXBlJTNEJTIyZmxvd19wcmVkaWN0aW9uJTIyJTJDJTIwdXNlX2Zsb3dfc2lnbWFzJTNEVHJ1ZSUyQyUyMGZsb3dfc2hpZnQlM0Q0LjApJTBBJTBBcGlwZSUyMCUzRCUyMFdhblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJXYW4tQUklMkZXYW4yLjEtVDJWLTEuM0ItRGlmZnVzZXJzJTIyJTJDJTIwc2NoZWR1bGVyJTNEJTNDQ1VTVE9NX1NDSEVEVUxFUl9IRVJFJTNFKSUwQSUwQSUyMyUyMG9yJTJDJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjAlM0NDVVNUT01fU0NIRURVTEVSX0hFUkUlM0U=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlowMatchEulerDiscreteScheduler, UniPCMultistepScheduler, WanPipeline

scheduler_a = FlowMatchEulerDiscreteScheduler(shift=<span class="hljs-number">5.0</span>)
scheduler_b = UniPCMultistepScheduler(prediction_type=<span class="hljs-string">&quot;flow_prediction&quot;</span>, use_flow_sigmas=<span class="hljs-literal">True</span>, flow_shift=<span class="hljs-number">4.0</span>)

pipe = WanPipeline.from_pretrained(<span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-1.3B-Diffusers&quot;</span>, scheduler=&lt;CUSTOM_SCHEDULER_HERE&gt;)

<span class="hljs-comment"># or,</span>
pipe.scheduler = &lt;CUSTOM_SCHEDULER_HERE&gt;`,wrap:!1}}),Te=new U({props:{title:"Using Single File Loading with Wan 2.1",local:"using-single-file-loading-with-wan-21",headingTag:"h2"}}),je=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwV2FuUGlwZWxpbmUlMkMlMjBXYW5UcmFuc2Zvcm1lcjNETW9kZWwlMEElMEFja3B0X3BhdGglMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGQ29tZnktT3JnJTJGV2FuXzIuMV9Db21meVVJX3JlcGFja2FnZWQlMkZibG9iJTJGbWFpbiUyRnNwbGl0X2ZpbGVzJTJGZGlmZnVzaW9uX21vZGVscyUyRndhbjIuMV90MnZfMS4zQl9iZjE2LnNhZmV0ZW5zb3JzJTIyJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBXYW5UcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9zaW5nbGVfZmlsZShja3B0X3BhdGglMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQSUwQXBpcGUlMjAlM0QlMjBXYW5QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyV2FuLUFJJTJGV2FuMi4xLVQyVi0xLjNCLURpZmZ1c2VycyUyMiUyQyUyMHRyYW5zZm9ybWVyJTNEdHJhbnNmb3JtZXIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> WanPipeline, WanTransformer3DModel

ckpt_path = <span class="hljs-string">&quot;https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/diffusion_models/wan2.1_t2v_1.3B_bf16.safetensors&quot;</span>
transformer = WanTransformer3DModel.from_single_file(ckpt_path, torch_dtype=torch.bfloat16)

pipe = WanPipeline.from_pretrained(<span class="hljs-string">&quot;Wan-AI/Wan2.1-T2V-1.3B-Diffusers&quot;</span>, transformer=transformer)`,wrap:!1}}),We=new U({props:{title:"Recommendations for Inference",local:"recommendations-for-inference",headingTag:"h2"}}),Be=new U({props:{title:"WanPipeline",local:"diffusers.WanPipeline",headingTag:"h2"}}),Ge=new Ee({props:{name:"class diffusers.WanPipeline",anchor:"diffusers.WanPipeline",parameters:[{name:"tokenizer",val:": AutoTokenizer"},{name:"text_encoder",val:": UMT5EncoderModel"},{name:"transformer",val:": WanTransformer3DModel"},{name:"vae",val:": AutoencoderKLWan"},{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"}],parametersDescription:[{anchor:"diffusers.WanPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>T5Tokenizer</code>) &#x2014;
Tokenizer from <a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer" rel="nofollow">T5</a>,
specifically the <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> variant.`,name:"tokenizer"},{anchor:"diffusers.WanPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>T5EncoderModel</code>) &#x2014;
<a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel" rel="nofollow">T5</a>, specifically
the <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> variant.`,name:"text_encoder"},{anchor:"diffusers.WanPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/main/en/api/models/wan_transformer_3d#diffusers.WanTransformer3DModel">WanTransformer3DModel</a>) &#x2014;
Conditional Transformer to denoise the input latents.`,name:"transformer"},{anchor:"diffusers.WanPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler">UniPCMultistepScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.WanPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan">AutoencoderKLWan</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode videos to and from latent representations.`,name:"vae"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py#L95"}}),Ie=new Ee({props:{name:"__call__",anchor:"diffusers.WanPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = 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:"guidance_scale",val:": float = 5.0"},{name:"num_videos_per_prompt",val:": typing.Optional[int] = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.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"}],parametersDescription:[{anchor:"diffusers.WanPipeline.__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 image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.WanPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, defaults to <code>480</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.WanPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, defaults to <code>832</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.WanPipeline.__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.`,name:"num_frames"},{anchor:"diffusers.WanPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, defaults to <code>50</code>) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.WanPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, defaults to <code>5.0</code>) &#x2014;
Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting
<code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to
the text <code>prompt</code>, usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.WanPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.WanPipeline.__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.WanPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.WanPipeline.__call__.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 (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.WanPipeline.__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 of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.WanPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>WanPipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.WanPipeline.__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.WanPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <code>PipelineCallback</code>, <code>MultiPipelineCallbacks</code>, <em>optional</em>) &#x2014;
A function or a subclass of <code>PipelineCallback</code> or <code>MultiPipelineCallbacks</code> that is called at the end of
each denoising step during the inference. with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a
list of all tensors as specified by <code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.WanPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) &#x2014;
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list
will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the
<code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.WanPipeline.__call__.autocast_dtype",description:`<strong>autocast_dtype</strong> (<code>torch.dtype</code>, <em>optional</em>, defaults to <code>torch.bfloat16</code>) &#x2014;
The dtype to use for the torch.amp.autocast.`,name:"autocast_dtype"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py#L361",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <code>WanPipelineOutput</code> is returned, otherwise a <code>tuple</code> is returned where
the first element is a list with the generated images and the second element is a list of <code>bool</code>s
indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>~WanPipelineOutput</code> or <code>tuple</code></p>
`}}),F=new Qa({props:{anchor:"diffusers.WanPipeline.__call__.example",$$slots:{default:[Pa]},$$scope:{ctx:X}}}),ke=new Ee({props:{name:"encode_prompt",anchor:"diffusers.WanPipeline.encode_prompt",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = 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.WanPipeline.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.WanPipeline.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.WanPipeline.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.WanPipeline.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.WanPipeline.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.WanPipeline.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.WanPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.WanPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan.py#L183"}}),ve=new U({props:{title:"WanImageToVideoPipeline",local:"diffusers.WanImageToVideoPipeline",headingTag:"h2"}}),Ve=new Ee({props:{name:"class diffusers.WanImageToVideoPipeline",anchor:"diffusers.WanImageToVideoPipeline",parameters:[{name:"tokenizer",val:": AutoTokenizer"},{name:"text_encoder",val:": UMT5EncoderModel"},{name:"image_encoder",val:": CLIPVisionModel"},{name:"image_processor",val:": CLIPImageProcessor"},{name:"transformer",val:": WanTransformer3DModel"},{name:"vae",val:": AutoencoderKLWan"},{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"}],parametersDescription:[{anchor:"diffusers.WanImageToVideoPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>T5Tokenizer</code>) &#x2014;
Tokenizer from <a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer" rel="nofollow">T5</a>,
specifically the <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> variant.`,name:"tokenizer"},{anchor:"diffusers.WanImageToVideoPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>T5EncoderModel</code>) &#x2014;
<a href="https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel" rel="nofollow">T5</a>, specifically
the <a href="https://huggingface.co/google/umt5-xxl" rel="nofollow">google/umt5-xxl</a> variant.`,name:"text_encoder"},{anchor:"diffusers.WanImageToVideoPipeline.image_encoder",description:`<strong>image_encoder</strong> (<code>CLIPVisionModel</code>) &#x2014;
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPVisionModel" rel="nofollow">CLIP</a>, specifically
the
<a href="https://github.com/mlfoundations/open_clip/blob/main/docs/PRETRAINED.md#vit-h14-xlm-roberta-large" rel="nofollow">clip-vit-huge-patch14</a>
variant.`,name:"image_encoder"},{anchor:"diffusers.WanImageToVideoPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/main/en/api/models/wan_transformer_3d#diffusers.WanTransformer3DModel">WanTransformer3DModel</a>) &#x2014;
Conditional Transformer to denoise the input latents.`,name:"transformer"},{anchor:"diffusers.WanImageToVideoPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler">UniPCMultistepScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.WanImageToVideoPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan">AutoencoderKLWan</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode videos to and from latent representations.`,name:"vae"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan_i2v.py#L127"}}),Re=new Ee({props:{name:"__call__",anchor:"diffusers.WanImageToVideoPipeline.__call__",parameters:[{name:"image",val:": typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, typing.List[PIL.Image.Image], typing.List[numpy.ndarray], typing.List[torch.Tensor]]"},{name:"prompt",val:": typing.Union[str, typing.List[str]] = 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:"guidance_scale",val:": float = 5.0"},{name:"num_videos_per_prompt",val:": typing.Optional[int] = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.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:"image_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"last_image",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"}],parametersDescription:[{anchor:"diffusers.WanImageToVideoPipeline.__call__.image",description:`<strong>image</strong> (<code>PipelineImageInput</code>) &#x2014;
The input image to condition the generation on. Must be an image, a list of images or a <code>torch.Tensor</code>.`,name:"image"},{anchor:"diffusers.WanImageToVideoPipeline.__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 image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.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.WanImageToVideoPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, defaults to <code>480</code>) &#x2014;
The height of the generated video.`,name:"height"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, defaults to <code>832</code>) &#x2014;
The width of the generated video.`,name:"width"},{anchor:"diffusers.WanImageToVideoPipeline.__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.`,name:"num_frames"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, defaults to <code>50</code>) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, defaults to <code>5.0</code>) &#x2014;
Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting
<code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to
the text <code>prompt</code>, usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.num_videos_per_prompt",description:`<strong>num_videos_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_videos_per_prompt"},{anchor:"diffusers.WanImageToVideoPipeline.__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.WanImageToVideoPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.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 (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.image_embeds",description:`<strong>image_embeds</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated image embeddings. Can be used to easily tweak image inputs (weighting). If not provided,
image embeddings are generated from the <code>image</code> input argument.`,name:"image_embeds"},{anchor:"diffusers.WanImageToVideoPipeline.__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 of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>WanPipelineOutput</code> instead of a plain tuple.`,name:"return_dict"},{anchor:"diffusers.WanImageToVideoPipeline.__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.WanImageToVideoPipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <code>PipelineCallback</code>, <code>MultiPipelineCallbacks</code>, <em>optional</em>) &#x2014;
A function or a subclass of <code>PipelineCallback</code> or <code>MultiPipelineCallbacks</code> that is called at the end of
each denoising step during the inference. with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a
list of all tensors as specified by <code>callback_on_step_end_tensor_inputs</code>.`,name:"callback_on_step_end"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>List</code>, <em>optional</em>) &#x2014;
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the list
will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables listed in the
<code>._callback_tensor_inputs</code> attribute of your pipeline class.`,name:"callback_on_step_end_tensor_inputs"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
The maximum sequence length of the prompt.`,name:"max_sequence_length"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.shift",description:`<strong>shift</strong> (<code>float</code>, <em>optional</em>, defaults to <code>5.0</code>) &#x2014;
The shift of the flow.`,name:"shift"},{anchor:"diffusers.WanImageToVideoPipeline.__call__.autocast_dtype",description:`<strong>autocast_dtype</strong> (<code>torch.dtype</code>, <em>optional</em>, defaults to <code>torch.bfloat16</code>) &#x2014;
The dtype to use for the torch.amp.autocast.`,name:"autocast_dtype"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan_i2v.py#L474",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <code>WanPipelineOutput</code> is returned, otherwise a <code>tuple</code> is returned where
the first element is a list with the generated images and the second element is a list of <code>bool</code>s
indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>~WanPipelineOutput</code> or <code>tuple</code></p>
`}}),Q=new Qa({props:{anchor:"diffusers.WanImageToVideoPipeline.__call__.example",$$slots:{default:[Ka]},$$scope:{ctx:X}}}),Xe=new Ee({props:{name:"encode_prompt",anchor:"diffusers.WanImageToVideoPipeline.encode_prompt",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = 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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.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.WanImageToVideoPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>, <em>optional</em>):
torch device`,name:"device"},{anchor:"diffusers.WanImageToVideoPipeline.encode_prompt.dtype",description:`<strong>dtype</strong> &#x2014; (<code>torch.dtype</code>, <em>optional</em>):
torch dtype`,name:"dtype"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_wan_i2v.py#L236"}}),Ce=new U({props:{title:"WanPipelineOutput",local:"diffusers.pipelines.wan.pipeline_output.WanPipelineOutput",headingTag:"h2"}}),Fe=new Ee({props:{name:"class diffusers.pipelines.wan.pipeline_output.WanPipelineOutput",anchor:"diffusers.pipelines.wan.pipeline_output.WanPipelineOutput",parameters:[{name:"frames",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.pipelines.wan.pipeline_output.WanPipelineOutput.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/wan/pipeline_output.py#L8"}}),Ye=new La({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/wan.md"}}),{c(){h=m("meta"),w=n(),g=m("p"),f=n(),o(b.$$.fragment),y=n(),T=m("div"),T.innerHTML=ma,Ke=n(),N=m("p"),N.innerHTML=Ma,Oe=n(),o(x.$$.fragment),el=n(),H=m("p"),H.textContent=ya,ll=n(),o(z.$$.fragment),al=n(),o(S.$$.fragment),tl=n(),A=m("p"),A.innerHTML=ha,nl=n(),o($.$$.fragment),sl=n(),o(C.$$.fragment),ol=n(),o(D.$$.fragment),il=n(),o(L.$$.fragment),rl=n(),q=m("p"),q.innerHTML=ua,dl=n(),o(P.$$.fragment),pl=n(),o(K.$$.fragment),cl=n(),o(O.$$.fragment),ml=n(),o(ee.$$.fragment),Ml=n(),o(le.$$.fragment),yl=n(),o(ae.$$.fragment),hl=n(),te=m("p"),te.textContent=Ja,ul=n(),ne=m("p"),ne.innerHTML=fa,Jl=n(),o(se.$$.fragment),fl=n(),oe=m("p"),oe.innerHTML=ga,gl=n(),o(ie.$$.fragment),bl=n(),re=m("p"),re.innerHTML=ba,Ul=n(),de=m("p"),de.textContent=Ua,wl=n(),o(pe.$$.fragment),Tl=n(),o(ce.$$.fragment),Zl=n(),me=m("p"),me.innerHTML=wa,jl=n(),Me=m("p"),Me.innerHTML=Ta,Wl=n(),o(ye.$$.fragment),_l=n(),o(he.$$.fragment),Bl=n(),ue=m("p"),ue.innerHTML=Za,Gl=n(),Je=m("p"),Je.innerHTML=ja,Il=n(),fe=m("p"),fe.textContent=Wa,kl=n(),o(ge.$$.fragment),vl=n(),o(be.$$.fragment),Vl=n(),Ue=m("p"),Ue.innerHTML=_a,Rl=n(),o(we.$$.fragment),Xl=n(),o(Te.$$.fragment),Cl=n(),Ze=m("p"),Ze.innerHTML=Ba,Fl=n(),o(je.$$.fragment),Yl=n(),o(We.$$.fragment),Ql=n(),_e=m("ul"),_e.innerHTML=Ga,El=n(),o(Be.$$.fragment),Nl=n(),Z=m("div"),o(Ge.$$.fragment),Pl=n(),Ne=m("p"),Ne.textContent=Ia,Kl=n(),xe=m("p"),xe.innerHTML=ka,Ol=n(),B=m("div"),o(Ie.$$.fragment),ea=n(),He=m("p"),He.textContent=va,la=n(),o(F.$$.fragment),aa=n(),Y=m("div"),o(ke.$$.fragment),ta=n(),ze=m("p"),ze.textContent=Va,xl=n(),o(ve.$$.fragment),Hl=n(),j=m("div"),o(Ve.$$.fragment),na=n(),Se=m("p"),Se.textContent=Ra,sa=n(),Ae=m("p"),Ae.innerHTML=Xa,oa=n(),G=m("div"),o(Re.$$.fragment),ia=n(),$e=m("p"),$e.textContent=Ca,ra=n(),o(Q.$$.fragment),da=n(),E=m("div"),o(Xe.$$.fragment),pa=n(),De=m("p"),De.textContent=Fa,zl=n(),o(Ce.$$.fragment),Sl=n(),v=m("div"),o(Fe.$$.fragment),ca=n(),Le=m("p"),Le.textContent=Ya,Al=n(),o(Ye.$$.fragment),$l=n(),Pe=m("p"),this.h()},l(e){const l=Sa("svelte-u9bgzb",document.head);h=M(l,"META",{name:!0,content:!0}),l.forEach(a),w=s(e),g=M(e,"P",{}),R(g).forEach(a),f=s(e),i(b.$$.fragment,e),y=s(e),T=M(e,"DIV",{class:!0,"data-svelte-h":!0}),J(T)!=="svelte-si9ct8"&&(T.innerHTML=ma),Ke=s(e),N=M(e,"P",{"data-svelte-h":!0}),J(N)!=="svelte-16y8q1j"&&(N.innerHTML=Ma),Oe=s(e),i(x.$$.fragment,e),el=s(e),H=M(e,"P",{"data-svelte-h":!0}),J(H)!=="svelte-1l57b5w"&&(H.textContent=ya),ll=s(e),i(z.$$.fragment,e),al=s(e),i(S.$$.fragment,e),tl=s(e),A=M(e,"P",{"data-svelte-h":!0}),J(A)!=="svelte-ub05vh"&&(A.innerHTML=ha),nl=s(e),i($.$$.fragment,e),sl=s(e),i(C.$$.fragment,e),ol=s(e),i(D.$$.fragment,e),il=s(e),i(L.$$.fragment,e),rl=s(e),q=M(e,"P",{"data-svelte-h":!0}),J(q)!=="svelte-1wgdieo"&&(q.innerHTML=ua),dl=s(e),i(P.$$.fragment,e),pl=s(e),i(K.$$.fragment,e),cl=s(e),i(O.$$.fragment,e),ml=s(e),i(ee.$$.fragment,e),Ml=s(e),i(le.$$.fragment,e),yl=s(e),i(ae.$$.fragment,e),hl=s(e),te=M(e,"P",{"data-svelte-h":!0}),J(te)!=="svelte-1trx1st"&&(te.textContent=Ja),ul=s(e),ne=M(e,"P",{"data-svelte-h":!0}),J(ne)!=="svelte-16134hm"&&(ne.innerHTML=fa),Jl=s(e),i(se.$$.fragment,e),fl=s(e),oe=M(e,"P",{"data-svelte-h":!0}),J(oe)!=="svelte-1pym4hp"&&(oe.innerHTML=ga),gl=s(e),i(ie.$$.fragment,e),bl=s(e),re=M(e,"P",{"data-svelte-h":!0}),J(re)!=="svelte-uw02y7"&&(re.innerHTML=ba),Ul=s(e),de=M(e,"P",{"data-svelte-h":!0}),J(de)!=="svelte-1sgls4v"&&(de.textContent=Ua),wl=s(e),i(pe.$$.fragment,e),Tl=s(e),i(ce.$$.fragment,e),Zl=s(e),me=M(e,"P",{"data-svelte-h":!0}),J(me)!=="svelte-ued87y"&&(me.innerHTML=wa),jl=s(e),Me=M(e,"P",{"data-svelte-h":!0}),J(Me)!=="svelte-1bpr6ms"&&(Me.innerHTML=Ta),Wl=s(e),i(ye.$$.fragment,e),_l=s(e),i(he.$$.fragment,e),Bl=s(e),ue=M(e,"P",{"data-svelte-h":!0}),J(ue)!=="svelte-15at3eb"&&(ue.innerHTML=Za),Gl=s(e),Je=M(e,"P",{"data-svelte-h":!0}),J(Je)!=="svelte-3gypvb"&&(Je.innerHTML=ja),Il=s(e),fe=M(e,"P",{"data-svelte-h":!0}),J(fe)!=="svelte-e0h9kl"&&(fe.textContent=Wa),kl=s(e),i(ge.$$.fragment,e),vl=s(e),i(be.$$.fragment,e),Vl=s(e),Ue=M(e,"P",{"data-svelte-h":!0}),J(Ue)!=="svelte-c0om1t"&&(Ue.innerHTML=_a),Rl=s(e),i(we.$$.fragment,e),Xl=s(e),i(Te.$$.fragment,e),Cl=s(e),Ze=M(e,"P",{"data-svelte-h":!0}),J(Ze)!=="svelte-936le3"&&(Ze.innerHTML=Ba),Fl=s(e),i(je.$$.fragment,e),Yl=s(e),i(We.$$.fragment,e),Ql=s(e),_e=M(e,"UL",{"data-svelte-h":!0}),J(_e)!=="svelte-c5e0rt"&&(_e.innerHTML=Ga),El=s(e),i(Be.$$.fragment,e),Nl=s(e),Z=M(e,"DIV",{class:!0});var W=R(Z);i(Ge.$$.fragment,W),Pl=s(W),Ne=M(W,"P",{"data-svelte-h":!0}),J(Ne)!=="svelte-cppop6"&&(Ne.textContent=Ia),Kl=s(W),xe=M(W,"P",{"data-svelte-h":!0}),J(xe)!=="svelte-496sm0"&&(xe.innerHTML=ka),Ol=s(W),B=M(W,"DIV",{class:!0});var V=R(B);i(Ie.$$.fragment,V),ea=s(V),He=M(V,"P",{"data-svelte-h":!0}),J(He)!=="svelte-50j04k"&&(He.textContent=va),la=s(V),i(F.$$.fragment,V),V.forEach(a),aa=s(W),Y=M(W,"DIV",{class:!0});var Qe=R(Y);i(ke.$$.fragment,Qe),ta=s(Qe),ze=M(Qe,"P",{"data-svelte-h":!0}),J(ze)!=="svelte-16q0ax1"&&(ze.textContent=Va),Qe.forEach(a),W.forEach(a),xl=s(e),i(ve.$$.fragment,e),Hl=s(e),j=M(e,"DIV",{class:!0});var I=R(j);i(Ve.$$.fragment,I),na=s(I),Se=M(I,"P",{"data-svelte-h":!0}),J(Se)!=="svelte-1u5shki"&&(Se.textContent=Ra),sa=s(I),Ae=M(I,"P",{"data-svelte-h":!0}),J(Ae)!=="svelte-496sm0"&&(Ae.innerHTML=Xa),oa=s(I),G=M(I,"DIV",{class:!0});var qe=R(G);i(Re.$$.fragment,qe),ia=s(qe),$e=M(qe,"P",{"data-svelte-h":!0}),J($e)!=="svelte-50j04k"&&($e.textContent=Ca),ra=s(qe),i(Q.$$.fragment,qe),qe.forEach(a),da=s(I),E=M(I,"DIV",{class:!0});var Ll=R(E);i(Xe.$$.fragment,Ll),pa=s(Ll),De=M(Ll,"P",{"data-svelte-h":!0}),J(De)!=="svelte-16q0ax1"&&(De.textContent=Fa),Ll.forEach(a),I.forEach(a),zl=s(e),i(Ce.$$.fragment,e),Sl=s(e),v=M(e,"DIV",{class:!0});var ql=R(v);i(Fe.$$.fragment,ql),ca=s(ql),Le=M(ql,"P",{"data-svelte-h":!0}),J(Le)!=="svelte-fkhkmf"&&(Le.textContent=Ya),ql.forEach(a),Al=s(e),i(Ye.$$.fragment,e),$l=s(e),Pe=M(e,"P",{}),R(Pe).forEach(a),this.h()},h(){k(h,"name","hf:doc:metadata"),k(h,"content",et),k(T,"class","flex flex-wrap space-x-1"),k(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){u(document.head,h),t(e,w,l),t(e,g,l),t(e,f,l),r(b,e,l),t(e,y,l),t(e,T,l),t(e,Ke,l),t(e,N,l),t(e,Oe,l),r(x,e,l),t(e,el,l),t(e,H,l),t(e,ll,l),r(z,e,l),t(e,al,l),r(S,e,l),t(e,tl,l),t(e,A,l),t(e,nl,l),r($,e,l),t(e,sl,l),r(C,e,l),t(e,ol,l),r(D,e,l),t(e,il,l),r(L,e,l),t(e,rl,l),t(e,q,l),t(e,dl,l),r(P,e,l),t(e,pl,l),r(K,e,l),t(e,cl,l),r(O,e,l),t(e,ml,l),r(ee,e,l),t(e,Ml,l),r(le,e,l),t(e,yl,l),r(ae,e,l),t(e,hl,l),t(e,te,l),t(e,ul,l),t(e,ne,l),t(e,Jl,l),r(se,e,l),t(e,fl,l),t(e,oe,l),t(e,gl,l),r(ie,e,l),t(e,bl,l),t(e,re,l),t(e,Ul,l),t(e,de,l),t(e,wl,l),r(pe,e,l),t(e,Tl,l),r(ce,e,l),t(e,Zl,l),t(e,me,l),t(e,jl,l),t(e,Me,l),t(e,Wl,l),r(ye,e,l),t(e,_l,l),r(he,e,l),t(e,Bl,l),t(e,ue,l),t(e,Gl,l),t(e,Je,l),t(e,Il,l),t(e,fe,l),t(e,kl,l),r(ge,e,l),t(e,vl,l),r(be,e,l),t(e,Vl,l),t(e,Ue,l),t(e,Rl,l),r(we,e,l),t(e,Xl,l),r(Te,e,l),t(e,Cl,l),t(e,Ze,l),t(e,Fl,l),r(je,e,l),t(e,Yl,l),r(We,e,l),t(e,Ql,l),t(e,_e,l),t(e,El,l),r(Be,e,l),t(e,Nl,l),t(e,Z,l),r(Ge,Z,null),u(Z,Pl),u(Z,Ne),u(Z,Kl),u(Z,xe),u(Z,Ol),u(Z,B),r(Ie,B,null),u(B,ea),u(B,He),u(B,la),r(F,B,null),u(Z,aa),u(Z,Y),r(ke,Y,null),u(Y,ta),u(Y,ze),t(e,xl,l),r(ve,e,l),t(e,Hl,l),t(e,j,l),r(Ve,j,null),u(j,na),u(j,Se),u(j,sa),u(j,Ae),u(j,oa),u(j,G),r(Re,G,null),u(G,ia),u(G,$e),u(G,ra),r(Q,G,null),u(j,da),u(j,E),r(Xe,E,null),u(E,pa),u(E,De),t(e,zl,l),r(Ce,e,l),t(e,Sl,l),t(e,v,l),r(Fe,v,null),u(v,ca),u(v,Le),t(e,Al,l),r(Ye,e,l),t(e,$l,l),t(e,Pe,l),Dl=!0},p(e,[l]){const W={};l&2&&(W.$$scope={dirty:l,ctx:e}),C.$set(W);const V={};l&2&&(V.$$scope={dirty:l,ctx:e}),F.$set(V);const Qe={};l&2&&(Qe.$$scope={dirty:l,ctx:e}),Q.$set(Qe)},i(e){Dl||(d(b.$$.fragment,e),d(x.$$.fragment,e),d(z.$$.fragment,e),d(S.$$.fragment,e),d($.$$.fragment,e),d(C.$$.fragment,e),d(D.$$.fragment,e),d(L.$$.fragment,e),d(P.$$.fragment,e),d(K.$$.fragment,e),d(O.$$.fragment,e),d(ee.$$.fragment,e),d(le.$$.fragment,e),d(ae.$$.fragment,e),d(se.$$.fragment,e),d(ie.$$.fragment,e),d(pe.$$.fragment,e),d(ce.$$.fragment,e),d(ye.$$.fragment,e),d(he.$$.fragment,e),d(ge.$$.fragment,e),d(be.$$.fragment,e),d(we.$$.fragment,e),d(Te.$$.fragment,e),d(je.$$.fragment,e),d(We.$$.fragment,e),d(Be.$$.fragment,e),d(Ge.$$.fragment,e),d(Ie.$$.fragment,e),d(F.$$.fragment,e),d(ke.$$.fragment,e),d(ve.$$.fragment,e),d(Ve.$$.fragment,e),d(Re.$$.fragment,e),d(Q.$$.fragment,e),d(Xe.$$.fragment,e),d(Ce.$$.fragment,e),d(Fe.$$.fragment,e),d(Ye.$$.fragment,e),Dl=!0)},o(e){p(b.$$.fragment,e),p(x.$$.fragment,e),p(z.$$.fragment,e),p(S.$$.fragment,e),p($.$$.fragment,e),p(C.$$.fragment,e),p(D.$$.fragment,e),p(L.$$.fragment,e),p(P.$$.fragment,e),p(K.$$.fragment,e),p(O.$$.fragment,e),p(ee.$$.fragment,e),p(le.$$.fragment,e),p(ae.$$.fragment,e),p(se.$$.fragment,e),p(ie.$$.fragment,e),p(pe.$$.fragment,e),p(ce.$$.fragment,e),p(ye.$$.fragment,e),p(he.$$.fragment,e),p(ge.$$.fragment,e),p(be.$$.fragment,e),p(we.$$.fragment,e),p(Te.$$.fragment,e),p(je.$$.fragment,e),p(We.$$.fragment,e),p(Be.$$.fragment,e),p(Ge.$$.fragment,e),p(Ie.$$.fragment,e),p(F.$$.fragment,e),p(ke.$$.fragment,e),p(ve.$$.fragment,e),p(Ve.$$.fragment,e),p(Re.$$.fragment,e),p(Q.$$.fragment,e),p(Xe.$$.fragment,e),p(Ce.$$.fragment,e),p(Fe.$$.fragment,e),p(Ye.$$.fragment,e),Dl=!1},d(e){e&&(a(w),a(g),a(f),a(y),a(T),a(Ke),a(N),a(Oe),a(el),a(H),a(ll),a(al),a(tl),a(A),a(nl),a(sl),a(ol),a(il),a(rl),a(q),a(dl),a(pl),a(cl),a(ml),a(Ml),a(yl),a(hl),a(te),a(ul),a(ne),a(Jl),a(fl),a(oe),a(gl),a(bl),a(re),a(Ul),a(de),a(wl),a(Tl),a(Zl),a(me),a(jl),a(Me),a(Wl),a(_l),a(Bl),a(ue),a(Gl),a(Je),a(Il),a(fe),a(kl),a(vl),a(Vl),a(Ue),a(Rl),a(Xl),a(Cl),a(Ze),a(Fl),a(Yl),a(Ql),a(_e),a(El),a(Nl),a(Z),a(xl),a(Hl),a(j),a(zl),a(Sl),a(v),a(Al),a($l),a(Pe)),a(h),c(b,e),c(x,e),c(z,e),c(S,e),c($,e),c(C,e),c(D,e),c(L,e),c(P,e),c(K,e),c(O,e),c(ee,e),c(le,e),c(ae,e),c(se,e),c(ie,e),c(pe,e),c(ce,e),c(ye,e),c(he,e),c(ge,e),c(be,e),c(we,e),c(Te,e),c(je,e),c(We,e),c(Be,e),c(Ge),c(Ie),c(F),c(ke),c(ve,e),c(Ve),c(Re),c(Q),c(Xe),c(Ce,e),c(Fe),c(Ye,e)}}}const et='{"title":"Wan","local":"wan","sections":[{"title":"Generating Videos with Wan 2.1","local":"generating-videos-with-wan-21","sections":[{"title":"Text to Video Generation","local":"text-to-video-generation","sections":[],"depth":3},{"title":"Image to Video Generation","local":"image-to-video-generation","sections":[],"depth":3},{"title":"First and Last Frame Interpolation","local":"first-and-last-frame-interpolation","sections":[],"depth":3},{"title":"Video to Video Generation","local":"video-to-video-generation","sections":[],"depth":3}],"depth":2},{"title":"Memory Optimizations for Wan 2.1","local":"memory-optimizations-for-wan-21","sections":[{"title":"Group Offloading the Transformer and UMT5 Text Encoder","local":"group-offloading-the-transformer-and-umt5-text-encoder","sections":[{"title":"Block Level Group Offloading","local":"block-level-group-offloading","sections":[],"depth":4},{"title":"Block Level Group Offloading with CUDA Streams","local":"block-level-group-offloading-with-cuda-streams","sections":[],"depth":4}],"depth":3},{"title":"Applying Layerwise Casting to the Transformer","local":"applying-layerwise-casting-to-the-transformer","sections":[],"depth":3}],"depth":2},{"title":"Using a Custom Scheduler","local":"using-a-custom-scheduler","sections":[],"depth":2},{"title":"Using Single File Loading with Wan 2.1","local":"using-single-file-loading-with-wan-21","sections":[],"depth":2},{"title":"Recommendations for Inference","local":"recommendations-for-inference","sections":[],"depth":2},{"title":"WanPipeline","local":"diffusers.WanPipeline","sections":[],"depth":2},{"title":"WanImageToVideoPipeline","local":"diffusers.WanImageToVideoPipeline","sections":[],"depth":2},{"title":"WanPipelineOutput","local":"diffusers.pipelines.wan.pipeline_output.WanPipelineOutput","sections":[],"depth":2}],"depth":1}';function lt(X){return xa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dt extends Ha{constructor(h){super(),za(this,h,lt,Oa,Na,{})}}export{dt as component};
