Spaces:
Runtime error
Runtime error
Kvikontent
commited on
Commit
β’
b0267fa
1
Parent(s):
837cb24
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import spaces
|
|
3 |
import torch
|
4 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
from diffusers.utils import export_to_video
|
|
|
|
|
6 |
|
7 |
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
|
8 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
@@ -11,7 +13,14 @@ pipe.enable_model_cpu_offload()
|
|
11 |
@spaces.GPU(duration=250)
|
12 |
def generate(prompt, num_inference_steps=25):
|
13 |
video_frames = pipe(prompt, num_inference_steps).frames
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return video_path
|
16 |
|
17 |
prompt = gr.Textbox("Enter prompt to generate a video")
|
|
|
3 |
import torch
|
4 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
5 |
from diffusers.utils import export_to_video
|
6 |
+
import cv2
|
7 |
+
import numpy as np
|
8 |
|
9 |
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
|
10 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
13 |
@spaces.GPU(duration=250)
|
14 |
def generate(prompt, num_inference_steps=25):
|
15 |
video_frames = pipe(prompt, num_inference_steps).frames
|
16 |
+
resized_frames = []
|
17 |
+
for frame in video_frames:
|
18 |
+
height, width, _ = frame.shape
|
19 |
+
new_height = (height // 8) * 8
|
20 |
+
new_width = (width // 8) * 8
|
21 |
+
resized_frame = cv2.resize(frame, (new_width, new_height))
|
22 |
+
resized_frames.append(resized_frame)
|
23 |
+
video_path = export_to_video(np.array(resized_frames))
|
24 |
return video_path
|
25 |
|
26 |
prompt = gr.Textbox("Enter prompt to generate a video")
|