Xiaoyan-Yang commited on
Commit
4ce4e6c
·
verified ·
1 Parent(s): 234acd4

Delete telestylevideo_pipeline.py

Browse files
Files changed (1) hide show
  1. telestylevideo_pipeline.py +0 -548
telestylevideo_pipeline.py DELETED
@@ -1,548 +0,0 @@
1
- # Copyright 2025 The Wan Team and The HuggingFace Team. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- import html
16
- from typing import Any, Callable, Dict, List, Optional, Union
17
-
18
- import ftfy
19
- import regex as re
20
- import torch
21
- from transformers import AutoTokenizer, UMT5EncoderModel
22
-
23
- from diffusers.callbacks import MultiPipelineCallbacks, PipelineCallback
24
- from diffusers.loaders import WanLoraLoaderMixin
25
- from diffusers.models import AutoencoderKLWan
26
- from transformer_semi_dit_2_patch_embedders import WanTransformer3DModel
27
- from diffusers.schedulers import FlowMatchEulerDiscreteScheduler
28
- from diffusers.utils import is_torch_xla_available, logging, replace_example_docstring
29
- from diffusers.utils.torch_utils import randn_tensor
30
- from diffusers.video_processor import VideoProcessor
31
- from diffusers.pipelines.pipeline_utils import DiffusionPipeline
32
- from diffusers.pipelines.wan.pipeline_output import WanPipelineOutput
33
-
34
-
35
- if is_torch_xla_available():
36
- import torch_xla.core.xla_model as xm
37
-
38
- XLA_AVAILABLE = True
39
- else:
40
- XLA_AVAILABLE = False
41
-
42
- logger = logging.get_logger(__name__) # pylint: disable=invalid-name
43
-
44
-
45
- EXAMPLE_DOC_STRING = """
46
- Examples:
47
- ```python
48
- >>> import torch
49
- >>> from diffusers.utils import export_to_video
50
- >>> from diffusers import AutoencoderKLWan, WanPipeline
51
- >>> from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
52
-
53
- >>> # Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers
54
- >>> model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
55
- >>> vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
56
- >>> pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
57
- >>> flow_shift = 5.0 # 5.0 for 720P, 3.0 for 480P
58
- >>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
59
- >>> pipe.to("cuda")
60
-
61
- >>> prompt = "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."
62
- >>> negative_prompt = "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"
63
-
64
- >>> output = pipe(
65
- ... prompt=prompt,
66
- ... negative_prompt=negative_prompt,
67
- ... height=720,
68
- ... width=1280,
69
- ... num_frames=81,
70
- ... guidance_scale=5.0,
71
- ... ).frames[0]
72
- >>> export_to_video(output, "output.mp4", fps=16)
73
- ```
74
- """
75
-
76
-
77
- def basic_clean(text):
78
- text = ftfy.fix_text(text)
79
- text = html.unescape(html.unescape(text))
80
- return text.strip()
81
-
82
-
83
- def whitespace_clean(text):
84
- text = re.sub(r"\s+", " ", text)
85
- text = text.strip()
86
- return text
87
-
88
-
89
- def prompt_clean(text):
90
- text = whitespace_clean(basic_clean(text))
91
- return text
92
-
93
-
94
- class WanPipeline(DiffusionPipeline, WanLoraLoaderMixin):
95
- r"""
96
- Pipeline for text-to-video generation using Wan.
97
-
98
- This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods
99
- implemented for all pipelines (downloading, saving, running on a particular device, etc.).
100
-
101
- Args:
102
- tokenizer ([`T5Tokenizer`]):
103
- Tokenizer from [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5Tokenizer),
104
- specifically the [google/umt5-xxl](https://huggingface.co/google/umt5-xxl) variant.
105
- text_encoder ([`T5EncoderModel`]):
106
- [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), specifically
107
- the [google/umt5-xxl](https://huggingface.co/google/umt5-xxl) variant.
108
- transformer ([`WanTransformer3DModel`]):
109
- Conditional Transformer to denoise the input latents.
110
- scheduler ([`UniPCMultistepScheduler`]):
111
- A scheduler to be used in combination with `transformer` to denoise the encoded image latents.
112
- vae ([`AutoencoderKLWan`]):
113
- Variational Auto-Encoder (VAE) Model to encode and decode videos to and from latent representations.
114
- """
115
-
116
- model_cpu_offload_seq = "text_encoder->transformer->vae"
117
- _callback_tensor_inputs = ["latents", "prompt_embeds", "negative_prompt_embeds"]
118
-
119
- def __init__(
120
- self,
121
- #tokenizer: AutoTokenizer,
122
- #text_encoder: UMT5EncoderModel,
123
- transformer: WanTransformer3DModel,
124
- vae: AutoencoderKLWan,
125
- scheduler: FlowMatchEulerDiscreteScheduler,
126
- ):
127
- super().__init__()
128
- self.register_modules(
129
- vae=vae,
130
- transformer=transformer,
131
- scheduler=scheduler,
132
- )
133
-
134
- # self.register_modules(
135
- # vae=vae,
136
- # text_encoder=text_encoder,
137
- # tokenizer=tokenizer,
138
- # transformer=transformer,
139
- # scheduler=scheduler,
140
- # )
141
-
142
- self.vae_scale_factor_temporal = 2 ** sum(self.vae.temperal_downsample) if getattr(self, "vae", None) else 4
143
- self.vae_scale_factor_spatial = 2 ** len(self.vae.temperal_downsample) if getattr(self, "vae", None) else 8
144
- self.video_processor = VideoProcessor(vae_scale_factor=self.vae_scale_factor_spatial)
145
-
146
- # def _get_t5_prompt_embeds(
147
- # self,
148
- # prompt: Union[str, List[str]] = None,
149
- # num_videos_per_prompt: int = 1,
150
- # max_sequence_length: int = 226,
151
- # device: Optional[torch.device] = None,
152
- # dtype: Optional[torch.dtype] = None,
153
- # ):
154
- # device = device or self._execution_device
155
- # dtype = dtype or self.text_encoder.dtype
156
-
157
- # prompt = [prompt] if isinstance(prompt, str) else prompt
158
- # prompt = [prompt_clean(u) for u in prompt]
159
- # batch_size = len(prompt)
160
-
161
- # text_inputs = self.tokenizer(
162
- # prompt,
163
- # padding="max_length",
164
- # max_length=max_sequence_length,
165
- # truncation=True,
166
- # add_special_tokens=True,
167
- # return_attention_mask=True,
168
- # return_tensors="pt",
169
- # )
170
- # text_input_ids, mask = text_inputs.input_ids, text_inputs.attention_mask
171
- # seq_lens = mask.gt(0).sum(dim=1).long()
172
-
173
- # prompt_embeds = self.text_encoder(text_input_ids.to(device), mask.to(device)).last_hidden_state
174
- # prompt_embeds = prompt_embeds.to(dtype=dtype, device=device)
175
- # prompt_embeds = [u[:v] for u, v in zip(prompt_embeds, seq_lens)]
176
- # prompt_embeds = torch.stack(
177
- # [torch.cat([u, u.new_zeros(max_sequence_length - u.size(0), u.size(1))]) for u in prompt_embeds], dim=0
178
- # )
179
-
180
- # # duplicate text embeddings for each generation per prompt, using mps friendly method
181
- # _, seq_len, _ = prompt_embeds.shape
182
- # prompt_embeds = prompt_embeds.repeat(1, num_videos_per_prompt, 1)
183
- # prompt_embeds = prompt_embeds.view(batch_size * num_videos_per_prompt, seq_len, -1)
184
-
185
- # return prompt_embeds
186
-
187
- # def encode_prompt(
188
- # self,
189
- # prompt: Union[str, List[str]],
190
- # negative_prompt: Optional[Union[str, List[str]]] = None,
191
- # do_classifier_free_guidance: bool = True,
192
- # num_videos_per_prompt: int = 1,
193
- # prompt_embeds: Optional[torch.Tensor] = None,
194
- # negative_prompt_embeds: Optional[torch.Tensor] = None,
195
- # max_sequence_length: int = 226,
196
- # device: Optional[torch.device] = None,
197
- # dtype: Optional[torch.dtype] = None,
198
- # ):
199
- # r"""
200
- # Encodes the prompt into text encoder hidden states.
201
-
202
- # Args:
203
- # prompt (`str` or `List[str]`, *optional*):
204
- # prompt to be encoded
205
- # negative_prompt (`str` or `List[str]`, *optional*):
206
- # The prompt or prompts not to guide the image generation. If not defined, one has to pass
207
- # `negative_prompt_embeds` instead. Ignored when not using guidance (i.e., ignored if `guidance_scale` is
208
- # less than `1`).
209
- # do_classifier_free_guidance (`bool`, *optional*, defaults to `True`):
210
- # Whether to use classifier free guidance or not.
211
- # num_videos_per_prompt (`int`, *optional*, defaults to 1):
212
- # Number of videos that should be generated per prompt. torch device to place the resulting embeddings on
213
- # prompt_embeds (`torch.Tensor`, *optional*):
214
- # Pre-generated text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt weighting. If not
215
- # provided, text embeddings will be generated from `prompt` input argument.
216
- # negative_prompt_embeds (`torch.Tensor`, *optional*):
217
- # Pre-generated negative text embeddings. Can be used to easily tweak text inputs, *e.g.* prompt
218
- # weighting. If not provided, negative_prompt_embeds will be generated from `negative_prompt` input
219
- # argument.
220
- # device: (`torch.device`, *optional*):
221
- # torch device
222
- # dtype: (`torch.dtype`, *optional*):
223
- # torch dtype
224
- # """
225
- # device = device or self._execution_device
226
-
227
- # prompt = [prompt] if isinstance(prompt, str) else prompt
228
- # if prompt is not None:
229
- # batch_size = len(prompt)
230
- # else:
231
- # batch_size = prompt_embeds.shape[0]
232
-
233
- # if prompt_embeds is None:
234
- # prompt_embeds = self._get_t5_prompt_embeds(
235
- # prompt=prompt,
236
- # num_videos_per_prompt=num_videos_per_prompt,
237
- # max_sequence_length=max_sequence_length,
238
- # device=device,
239
- # dtype=dtype,
240
- # )
241
-
242
- # if do_classifier_free_guidance and negative_prompt_embeds is None:
243
- # negative_prompt = negative_prompt or ""
244
- # negative_prompt = batch_size * [negative_prompt] if isinstance(negative_prompt, str) else negative_prompt
245
-
246
- # if prompt is not None and type(prompt) is not type(negative_prompt):
247
- # raise TypeError(
248
- # f"`negative_prompt` should be the same type to `prompt`, but got {type(negative_prompt)} !="
249
- # f" {type(prompt)}."
250
- # )
251
- # elif batch_size != len(negative_prompt):
252
- # raise ValueError(
253
- # f"`negative_prompt`: {negative_prompt} has batch size {len(negative_prompt)}, but `prompt`:"
254
- # f" {prompt} has batch size {batch_size}. Please make sure that passed `negative_prompt` matches"
255
- # " the batch size of `prompt`."
256
- # )
257
-
258
- # negative_prompt_embeds = self._get_t5_prompt_embeds(
259
- # prompt=negative_prompt,
260
- # num_videos_per_prompt=num_videos_per_prompt,
261
- # max_sequence_length=max_sequence_length,
262
- # device=device,
263
- # dtype=dtype,
264
- # )
265
-
266
- # return prompt_embeds, negative_prompt_embeds
267
-
268
- # def check_inputs(
269
- # self,
270
- # prompt,
271
- # negative_prompt,
272
- # height,
273
- # width,
274
- # prompt_embeds=None,
275
- # negative_prompt_embeds=None,
276
- # callback_on_step_end_tensor_inputs=None,
277
- # ):
278
- # if height % 16 != 0 or width % 16 != 0:
279
- # raise ValueError(f"`height` and `width` have to be divisible by 16 but are {height} and {width}.")
280
-
281
- # if callback_on_step_end_tensor_inputs is not None and not all(
282
- # k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs
283
- # ):
284
- # raise ValueError(
285
- # f"`callback_on_step_end_tensor_inputs` has to be in {self._callback_tensor_inputs}, but found {[k for k in callback_on_step_end_tensor_inputs if k not in self._callback_tensor_inputs]}"
286
- # )
287
-
288
- # if prompt is not None and prompt_embeds is not None:
289
- # raise ValueError(
290
- # f"Cannot forward both `prompt`: {prompt} and `prompt_embeds`: {prompt_embeds}. Please make sure to"
291
- # " only forward one of the two."
292
- # )
293
- # elif negative_prompt is not None and negative_prompt_embeds is not None:
294
- # raise ValueError(
295
- # f"Cannot forward both `negative_prompt`: {negative_prompt} and `negative_prompt_embeds`: {negative_prompt_embeds}. Please make sure to"
296
- # " only forward one of the two."
297
- # )
298
- # elif prompt is None and prompt_embeds is None:
299
- # raise ValueError(
300
- # "Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined."
301
- # )
302
- # elif prompt is not None and (not isinstance(prompt, str) and not isinstance(prompt, list)):
303
- # raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}")
304
- # elif negative_prompt is not None and (
305
- # not isinstance(negative_prompt, str) and not isinstance(negative_prompt, list)
306
- # ):
307
- # raise ValueError(f"`negative_prompt` has to be of type `str` or `list` but is {type(negative_prompt)}")
308
-
309
- def prepare_latents(
310
- self,
311
- batch_size: int,
312
- num_channels_latents: int = 16,
313
- height: int = 480,
314
- width: int = 832,
315
- num_frames: int = 81,
316
- dtype: Optional[torch.dtype] = None,
317
- device: Optional[torch.device] = None,
318
- generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
319
- latents: Optional[torch.Tensor] = None,
320
- ) -> torch.Tensor:
321
- if latents is not None:
322
- return latents.to(device=device, dtype=dtype)
323
-
324
- num_latent_frames = (num_frames - 1) // self.vae_scale_factor_temporal + 1
325
- shape = (
326
- batch_size,
327
- num_channels_latents,
328
- num_latent_frames,
329
- int(height) // self.vae_scale_factor_spatial,
330
- int(width) // self.vae_scale_factor_spatial,
331
- )
332
- if isinstance(generator, list) and len(generator) != batch_size:
333
- raise ValueError(
334
- f"You have passed a list of generators of length {len(generator)}, but requested an effective batch"
335
- f" size of {batch_size}. Make sure the batch size matches the length of the generators."
336
- )
337
-
338
- latents = randn_tensor(shape, generator=generator, device=device, dtype=dtype)
339
- return latents
340
-
341
- @property
342
- def guidance_scale(self):
343
- return self._guidance_scale
344
-
345
- @property
346
- def do_classifier_free_guidance(self):
347
- return self._guidance_scale > 1.0
348
-
349
- @property
350
- def num_timesteps(self):
351
- return self._num_timesteps
352
-
353
- @property
354
- def current_timestep(self):
355
- return self._current_timestep
356
-
357
- # @property
358
- # def interrupt(self):
359
- # return self._interrupt
360
-
361
- # @property
362
- # def attention_kwargs(self):
363
- # return self._attention_kwargs
364
-
365
- @torch.no_grad()
366
- #@replace_example_docstring(EXAMPLE_DOC_STRING)
367
- def __call__(
368
- self,
369
- prompt: Union[str, List[str]] = None,
370
- negative_prompt: Union[str, List[str]] = None,
371
- height: int = 480,
372
- width: int = 832,
373
- num_frames: int = 81,
374
- num_inference_steps: int = 50,
375
- guidance_scale: float = 5.0,
376
- num_videos_per_prompt: Optional[int] = 1,
377
- generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
378
- latents: Optional[torch.Tensor] = None,
379
- prompt_embeds: Optional[torch.Tensor] = None,
380
- prompt_embeds_: Optional[torch.Tensor] = None,
381
- negative_prompt_embeds: Optional[torch.Tensor] = None,
382
- output_type: Optional[str] = "np",
383
- return_dict: bool = True,
384
- attention_kwargs: Optional[Dict[str, Any]] = None,
385
- callback_on_step_end: Optional[
386
- Union[Callable[[int, int, Dict], None], PipelineCallback, MultiPipelineCallbacks]
387
- ] = None,
388
- callback_on_step_end_tensor_inputs: List[str] = ["latents"],
389
- max_sequence_length: int = 512,
390
- source_latents: Optional[torch.Tensor] = None,
391
- first_latents: Optional[torch.Tensor] = None,
392
- neg_first_latents: Optional[torch.Tensor] = None,
393
- ):
394
-
395
- if isinstance(callback_on_step_end, (PipelineCallback, MultiPipelineCallbacks)):
396
- callback_on_step_end_tensor_inputs = callback_on_step_end.tensor_inputs
397
-
398
- # 1. Check inputs. Raise error if not correct
399
- # self.check_inputs(
400
- # prompt,
401
- # negative_prompt,
402
- # height,
403
- # width,
404
- # prompt_embeds,
405
- # negative_prompt_embeds,
406
- # callback_on_step_end_tensor_inputs,
407
- # )
408
-
409
- # if num_frames % self.vae_scale_factor_temporal != 1:
410
- # logger.warning(
411
- # f"`num_frames - 1` has to be divisible by {self.vae_scale_factor_temporal}. Rounding to the nearest number."
412
- # )
413
- # num_frames = num_frames // self.vae_scale_factor_temporal * self.vae_scale_factor_temporal + 1
414
- # num_frames = max(num_frames, 1)
415
-
416
- self._guidance_scale = guidance_scale
417
- # self._attention_kwargs = attention_kwargs
418
- self._current_timestep = None
419
- self._interrupt = False
420
-
421
- device = self._execution_device
422
-
423
- # 2. Define call parameters
424
- # if prompt is not None and isinstance(prompt, str):
425
- # batch_size = 1
426
- # elif prompt is not None and isinstance(prompt, list):
427
- # batch_size = len(prompt)
428
- # else:
429
- # batch_size = prompt_embeds.shape[0]
430
-
431
- # batch_size = 1
432
-
433
- # 3. Encode input prompt
434
- # prompt_embeds, negative_prompt_embeds = self.encode_prompt(
435
- # prompt=prompt,
436
- # negative_prompt=negative_prompt,
437
- # do_classifier_free_guidance=self.do_classifier_free_guidance,
438
- # num_videos_per_prompt=num_videos_per_prompt,
439
- # prompt_embeds=prompt_embeds,
440
- # negative_prompt_embeds=negative_prompt_embeds,
441
- # max_sequence_length=max_sequence_length,
442
- # device=device,
443
- # )
444
-
445
- transformer_dtype = self.transformer.dtype
446
- # prompt_embeds = prompt_embeds.to(transformer_dtype)
447
- # if negative_prompt_embeds is not None:
448
- # negative_prompt_embeds = negative_prompt_embeds.to(transformer_dtype)
449
-
450
- # 4. Prepare timesteps
451
- self.scheduler.set_timesteps(num_inference_steps, device=device)
452
- timesteps = self.scheduler.timesteps
453
-
454
- # 5. Prepare latent variables
455
- # num_channels_latents = self.transformer.config.in_channels
456
- # latents = self.prepare_latents(
457
- # batch_size * num_videos_per_prompt,
458
- # num_channels_latents,
459
- # height,
460
- # width,
461
- # num_frames,
462
- # torch.float32,
463
- # device,
464
- # generator,
465
- # latents,
466
- # )
467
-
468
- latents = torch.randn_like(source_latents)
469
-
470
- # 6. Denoising loop
471
- # num_warmup_steps = len(timesteps) - num_inference_steps * self.scheduler.order
472
- self._num_timesteps = len(timesteps)
473
-
474
- condition_latent_model_input = first_latents
475
- neg_condition_latent_model_input = neg_first_latents
476
- with self.progress_bar(total=num_inference_steps) as progress_bar:
477
- for i, t in enumerate(timesteps):
478
-
479
- self._current_timestep = t
480
- latent_model_input = torch.cat([source_latents, latents.to(transformer_dtype)], dim=1)
481
- timestep = t.expand(latents.shape[0])
482
-
483
- print(timestep, torch.zeros_like(timestep))
484
- noise_pred = self.transformer(
485
- condition_hidden_states=condition_latent_model_input,
486
- hidden_states=latent_model_input,
487
- condition_timestep=torch.zeros_like(timestep),
488
- timestep=timestep,
489
- encoder_hidden_states=prompt_embeds_,
490
- return_dict=False,
491
- )[0]
492
-
493
- if self.do_classifier_free_guidance:
494
- noise_uncond = self.transformer(
495
- condition_hidden_states=neg_condition_latent_model_input,
496
- hidden_states=latent_model_input,
497
- condition_timestep=torch.zeros_like(timestep),
498
- timestep=timestep,
499
- encoder_hidden_states=prompt_embeds_,
500
- return_dict=False,
501
- )[0]
502
- noise_pred = noise_uncond + guidance_scale * (noise_pred - noise_uncond)
503
-
504
- # compute the previous noisy sample x_t -> x_t-1
505
- latents = self.scheduler.step(noise_pred, t, latents, return_dict=False)[0]
506
-
507
- # if callback_on_step_end is not None:
508
- # callback_kwargs = {}
509
- # for k in callback_on_step_end_tensor_inputs:
510
- # callback_kwargs[k] = locals()[k]
511
- # callback_outputs = callback_on_step_end(self, i, t, callback_kwargs)
512
-
513
- # latents = callback_outputs.pop("latents", latents)
514
- # prompt_embeds = callback_outputs.pop("prompt_embeds", prompt_embeds)
515
- # negative_prompt_embeds = callback_outputs.pop("negative_prompt_embeds", negative_prompt_embeds)
516
-
517
- # call the callback, if provided
518
- #if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
519
- progress_bar.update()
520
-
521
- # if XLA_AVAILABLE:
522
- # xm.mark_step()
523
-
524
- self._current_timestep = None
525
-
526
- if not output_type == "latent":
527
- latents = latents.to(self.vae.dtype)
528
- latents_mean = (
529
- torch.tensor(self.vae.config.latents_mean)
530
- .view(1, self.vae.config.z_dim, 1, 1, 1)
531
- .to(latents.device, latents.dtype)
532
- )
533
- latents_std = 1.0 / torch.tensor(self.vae.config.latents_std).view(1, self.vae.config.z_dim, 1, 1, 1).to(
534
- latents.device, latents.dtype
535
- )
536
- latents = latents / latents_std + latents_mean
537
- video = self.vae.decode(latents, return_dict=False)[0]
538
- video = self.video_processor.postprocess_video(video, output_type=output_type)
539
- else:
540
- video = latents
541
-
542
- # Offload all models
543
- # self.maybe_free_model_hooks()
544
-
545
- if not return_dict:
546
- return (video,)
547
-
548
- return WanPipelineOutput(frames=video)