Skip to content

Commit 2c33c09

Browse files
committedFeb 26, 2025
fix import order and deprecate for CVX 2B models
1 parent d6bb910 commit 2c33c09

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎inference/ddim_inversion.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
a video reconstruction based on a provided prompt. It utilizes the CogVideoX pipeline to
44
process video frames, apply the DDIM inverse scheduler, and produce an output video.
55
6+
**Please notice that this script is based on the CogVideoX 5B model, and would not generate
7+
a good result for 2B variants.**
8+
69
Usage:
7-
python script.py --model-path /path/to/model --prompt "a prompt" --video-path /path/to/video.mp4 --output-path /path/to/output
10+
python ddim_inversion.py
11+
--model-path /path/to/model
12+
--prompt "a prompt"
13+
--video-path /path/to/video.mp4
14+
--output-path /path/to/output
15+
16+
For more details about the cli arguments, please run `python ddim_inversion.py --help`.
817
918
Author:
1019
LittleNyima <littlenyima[at]163[dot]com>
@@ -15,7 +24,6 @@
1524
import os
1625
from typing import Any, Dict, List, Optional, Tuple, TypedDict, Union, cast
1726

18-
import decord
1927
import torch
2028
import torch.nn.functional as F
2129
import torchvision.transforms as T
@@ -27,6 +35,10 @@
2735
from diffusers.schedulers import CogVideoXDDIMScheduler, DDIMInverseScheduler
2836
from diffusers.utils import export_to_video
2937

38+
# Must import after torch because this can sometimes lead to a nasty segmentation fault, or stack smashing error.
39+
# Very few bug reports but it happens. Look in decord Github issues for more relevant information.
40+
import decord # isort: skip
41+
3042

3143
class DDIMInversionArguments(TypedDict):
3244
model_path: str
@@ -399,6 +411,8 @@ def ddim_inversion(
399411
device: torch.device,
400412
):
401413
pipeline: CogVideoXPipeline = CogVideoXPipeline.from_pretrained(model_path, torch_dtype=dtype).to(device=device)
414+
if not pipeline.transformer.config.use_rotary_positional_embeddings:
415+
raise NotImplementedError("This script supports CogVideoX 5B model only.")
402416
video_frames = get_video_frames(
403417
video_path=video_path,
404418
width=width,

0 commit comments

Comments
 (0)
Please sign in to comment.