Spaces:
Running
Running
Create appp.py
Browse files
appp.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import CogVideoXImageToVideoPipeline
|
3 |
+
from diffusers.utils import export_to_video, load_image
|
4 |
+
|
5 |
+
prompt = "A vast, shimmering ocean flows gracefully under a twilight sky, its waves undulating in a mesmerizing dance of blues and greens. The surface glints with the last rays of the setting sun, casting golden highlights that ripple across the water. Seagulls soar above, their cries blending with the gentle roar of the waves. The horizon stretches infinitely, where the ocean meets the sky in a seamless blend of hues. Close-ups reveal the intricate patterns of the waves, capturing the fluidity and dynamic beauty of the sea in motion."
|
6 |
+
|
7 |
+
image = load_image(image="cogvideox_rocket.png")
|
8 |
+
|
9 |
+
pipe = CogVideoXImageToVideoPipeline.from_pretrained(
|
10 |
+
"THUDM/CogVideoX-5b-I2V",
|
11 |
+
torch_dtype=torch.bfloat16
|
12 |
+
)
|
13 |
+
|
14 |
+
pipe.vae.enable_tiling()
|
15 |
+
pipe.vae.enable_slicing()
|
16 |
+
|
17 |
+
video = pipe(
|
18 |
+
prompt=prompt,
|
19 |
+
image=image,
|
20 |
+
num_videos_per_prompt=1,
|
21 |
+
num_inference_steps=50,
|
22 |
+
num_frames=49,
|
23 |
+
guidance_scale=6,
|
24 |
+
generator=torch.Generator(device="cuda").manual_seed(42),
|
25 |
+
).frames[0]
|
26 |
+
|
27 |
+
export_to_video(video, "output.mp4", fps=8)
|