Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,11 @@
|
|
1 |
-
import
|
2 |
-
from
|
3 |
-
from
|
4 |
|
5 |
-
|
6 |
-
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
# conditional image captioning
|
12 |
-
text = "a photography of"
|
13 |
-
inputs = processor(raw_image, text, return_tensors="pt")
|
14 |
-
|
15 |
-
out = model.generate(**inputs)
|
16 |
-
print(processor.decode(out[0], skip_special_tokens=True))
|
17 |
-
|
18 |
-
# unconditional image captioning
|
19 |
-
inputs = processor(raw_image, return_tensors="pt")
|
20 |
-
|
21 |
-
out = model.generate(**inputs)
|
22 |
-
print(processor.decode(out[0], skip_special_tokens=True))
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
3 |
+
from diffusers.utils import export_to_video
|
4 |
|
5 |
+
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
|
6 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
7 |
+
pipe.enable_model_cpu_offload()
|
8 |
|
9 |
+
prompt = "Spiderman is surfing"
|
10 |
+
video_frames = pipe(prompt, num_inference_steps=25).frames
|
11 |
+
video_path = export_to_video(video_frames)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|