Spaces:
Running
Running
Create ITV.py
Browse files
ITV.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import CogVideoXImageToVideoPipeline
|
3 |
+
from diffusers.utils import export_to_video, load_image
|
4 |
+
|
5 |
+
prompt = "A little girl is riding a bicycle at high speed. Focused, detailed, realistic."
|
6 |
+
image = load_image(image="input.jpg")
|
7 |
+
pipe = CogVideoXImageToVideoPipeline.from_pretrained(
|
8 |
+
"THUDM/CogVideoX1.5-5B-I2V",
|
9 |
+
torch_dtype=torch.bfloat16
|
10 |
+
)
|
11 |
+
|
12 |
+
pipe.enable_sequential_cpu_offload()
|
13 |
+
pipe.vae.enable_tiling()
|
14 |
+
pipe.vae.enable_slicing()
|
15 |
+
|
16 |
+
video = pipe(
|
17 |
+
prompt=prompt,
|
18 |
+
image=image,
|
19 |
+
num_videos_per_prompt=1,
|
20 |
+
num_inference_steps=50,
|
21 |
+
num_frames=81,
|
22 |
+
guidance_scale=6,
|
23 |
+
generator=torch.Generator(device="cuda").manual_seed(42),
|
24 |
+
).frames[0]
|
25 |
+
|
26 |
+
export_to_video(video, "output.mp4", fps=8)
|