holmbergfan commited on
Commit
e27f81d
1 Parent(s): a35cdc2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import CogVideoXPipeline
3
+ from diffusers.utils import export_to_video
4
+
5
+ prompt = "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical atmosphere of this unique musical performance."
6
+
7
+ pipe = CogVideoXPipeline.from_pretrained(
8
+ "THUDM/CogVideoX-2b",
9
+ torch_dtype=torch.float16
10
+ )
11
+
12
+ pipe.enable_model_cpu_offload()
13
+ pipe.enable_sequential_cpu_offload()
14
+ pipe.vae.enable_slicing()
15
+ pipe.vae.enable_tiling()
16
+ video = pipe(
17
+ prompt=prompt,
18
+ num_videos_per_prompt=1,
19
+ num_inference_steps=50,
20
+ num_frames=49,
21
+ guidance_scale=6,
22
+ generator=torch.Generator(device="cuda").manual_seed(42),
23
+ ).frames[0]
24
+
25
+ export_to_video(video, "output.mp4", fps=8)