mrcuddle commited on
Commit
d8769ff
·
verified ·
1 Parent(s): d47b840

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -17
app.py CHANGED
@@ -10,27 +10,31 @@ pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
10
  pipe.to("cuda")
11
 
12
  @spaces.GPU
13
- def generate_video(image, prompt, num_frames=25, resolution=(576, 1024)):
14
  # Generate the video
15
- video_frames = pipe(prompt, image=image, num_frames=num_frames, height=resolution[0], width=resolution[1]).frames
16
  return video_frames
17
 
18
  # Create the Gradio interface
19
- iface = gr.Interface(
20
- fn=generate_video,
21
- inputs=[
22
- gr.inputs.Image(type="pil", label="Upload Image"),
23
- gr.inputs.Textbox(lines=2, placeholder="Enter prompt...", label="Prompt"),
24
- gr.inputs.Slider(1, 50, step=1, default=25, label="Number of Frames"),
25
- gr.inputs.Number(label="Resolution Height", default=576),
26
- gr.inputs.Number(label="Resolution Width", default=1024)
27
- ],
28
- outputs=gr.outputs.Video(label="Generated Video"),
29
- title="Image to Video with Stable Diffusion XT",
30
- description="Upload an image and enter a prompt to generate a video."
31
- )
 
 
 
 
 
32
 
33
  # Launch the interface
34
  if __name__ == "__main__":
35
- iface.launch()
36
-
 
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, image=image, num_frames=num_frames, height=height, width=width).frames
16
  return video_frames
17
 
18
  # Create the Gradio interface
19
+ 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="pil", label="Upload Image")
24
+ prompt_input = gr.Textbox(lines=2, placeholder="Enter prompt...", label="Prompt")
25
+ num_frames_input = gr.Slider(1, 50, step=1, default=25, label="Number of Frames")
26
+ height_input = gr.Number(label="Resolution Height", default=576)
27
+ width_input = gr.Number(label="Resolution Width", default=1024)
28
+ run_button = gr.Button("Generate Video")
29
+ with gr.Column():
30
+ video_output = gr.Video(label="Generated Video")
31
+
32
+ run_button.click(
33
+ generate_video,
34
+ inputs=[image_input, prompt_input, num_frames_input, height_input, width_input],
35
+ outputs=video_output
36
+ )
37
 
38
  # Launch the interface
39
  if __name__ == "__main__":
40
+ demo.launch()