Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import StableVideoDiffusionPipeline, EulerDiscreteScheduler
|
| 3 |
import torch
|
|
|
|
| 4 |
import spaces
|
| 5 |
|
| 6 |
# Load the Stable Video Diffusion model
|
|
@@ -11,8 +12,10 @@ pipe.to("cuda")
|
|
| 11 |
|
| 12 |
@spaces.GPU
|
| 13 |
def generate_video(image, prompt, num_frames=25, height=576, width=1024):
|
|
|
|
|
|
|
| 14 |
# Generate the video
|
| 15 |
-
video_frames = pipe(prompt,
|
| 16 |
return video_frames
|
| 17 |
|
| 18 |
# Create the Gradio interface
|
|
@@ -20,7 +23,7 @@ with gr.Blocks() as demo:
|
|
| 20 |
gr.Markdown("## Image to Video with Stable Diffusion XT")
|
| 21 |
with gr.Row():
|
| 22 |
with gr.Column():
|
| 23 |
-
image_input = gr.Image(type="
|
| 24 |
prompt_input = gr.Textbox(lines=2, placeholder="Enter prompt...", label="Prompt")
|
| 25 |
num_frames_input = gr.Slider(1, 50, step=1, value=25, label="Number of Frames")
|
| 26 |
height_input = gr.Number(label="Resolution Height", value=576)
|
|
@@ -37,5 +40,4 @@ with gr.Blocks() as demo:
|
|
| 37 |
|
| 38 |
# Launch the interface
|
| 39 |
if __name__ == "__main__":
|
| 40 |
-
demo.launch()
|
| 41 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import StableVideoDiffusionPipeline, EulerDiscreteScheduler
|
| 3 |
import torch
|
| 4 |
+
from PIL import Image
|
| 5 |
import spaces
|
| 6 |
|
| 7 |
# Load the Stable Video Diffusion model
|
|
|
|
| 12 |
|
| 13 |
@spaces.GPU
|
| 14 |
def generate_video(image, prompt, num_frames=25, height=576, width=1024):
|
| 15 |
+
# Convert the image to a format suitable for the pipeline
|
| 16 |
+
image = Image.open(image)
|
| 17 |
# Generate the video
|
| 18 |
+
video_frames = pipe(prompt=prompt, init_image=image, num_frames=num_frames, height=height, width=width).frames
|
| 19 |
return video_frames
|
| 20 |
|
| 21 |
# Create the Gradio interface
|
|
|
|
| 23 |
gr.Markdown("## Image to Video with Stable Diffusion XT")
|
| 24 |
with gr.Row():
|
| 25 |
with gr.Column():
|
| 26 |
+
image_input = gr.Image(type="filepath", label="Upload Image")
|
| 27 |
prompt_input = gr.Textbox(lines=2, placeholder="Enter prompt...", label="Prompt")
|
| 28 |
num_frames_input = gr.Slider(1, 50, step=1, value=25, label="Number of Frames")
|
| 29 |
height_input = gr.Number(label="Resolution Height", value=576)
|
|
|
|
| 40 |
|
| 41 |
# Launch the interface
|
| 42 |
if __name__ == "__main__":
|
| 43 |
+
demo.launch()
|
|
|