Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
import torch
|
| 4 |
-
from PIL import Image
|
| 5 |
|
| 6 |
# Load the model and pipeline
|
| 7 |
model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
|
| 8 |
-
pipe =
|
| 9 |
-
pipe = pipe.to("cuda")
|
| 10 |
|
| 11 |
def generate_video(image, prompt):
|
| 12 |
-
# Convert the image to a format suitable for the model
|
| 13 |
-
image = Image.fromarray(image)
|
| 14 |
-
|
| 15 |
# Generate the video from the image and prompt
|
| 16 |
-
video = pipe(prompt, image, num_inference_steps=50, guidance_scale=7.5)
|
| 17 |
-
|
| 18 |
-
# Convert the video frames to a format suitable for Gradio
|
| 19 |
-
video_path = "output_video.mp4"
|
| 20 |
-
video[0].save(video_path, save_all=True, append_images=video[1:], duration=100, loop=0)
|
| 21 |
-
|
| 22 |
-
return video_path
|
| 23 |
|
| 24 |
# Create the Gradio interface
|
| 25 |
iface = gr.Interface(
|
|
@@ -35,4 +25,4 @@ iface = gr.Interface(
|
|
| 35 |
|
| 36 |
# Launch the interface
|
| 37 |
if __name__ == "__main__":
|
| 38 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
import torch
|
|
|
|
| 4 |
|
| 5 |
# Load the model and pipeline
|
| 6 |
model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
|
| 7 |
+
pipe = pipeline("text-to-video-generation", model=model_id, torch_dtype=torch.float16, device="cuda")
|
|
|
|
| 8 |
|
| 9 |
def generate_video(image, prompt):
|
|
|
|
|
|
|
|
|
|
| 10 |
# Generate the video from the image and prompt
|
| 11 |
+
video = pipe(prompt, image, num_inference_steps=50, guidance_scale=7.5)
|
| 12 |
+
return video
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Create the Gradio interface
|
| 15 |
iface = gr.Interface(
|
|
|
|
| 25 |
|
| 26 |
# Launch the interface
|
| 27 |
if __name__ == "__main__":
|
| 28 |
+
iface.launch()
|