VicFonch commited on
Commit
17c3fdf
·
unverified ·
1 Parent(s): 6edbb29

app.py: Fix bug render duplication

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -78,31 +78,33 @@ def build_demo() -> gr.Blocks:
78
  </div>
79
  </div>
80
  """
 
81
  with gr.Blocks() as demo:
82
  gr.HTML(header)
83
- gr.Interface(
84
- fn=interpolate,
85
- inputs=[
86
- gr.Image(type="pil", label="Initial Image (frame1)"),
87
- gr.Image(type="pil", label="Final Image (frame3)"),
88
- gr.Slider(0.0, 1.0, step=0.05, value=0.5, label="Tau Value (only if Num Samples = 1)"),
89
- gr.Slider(1, 15, step=1, value=1, label="Number of Samples"),
90
- ],
91
- outputs=[
92
- gr.Image(label="Interpolated Image (if num_samples = 1)"),
93
- gr.Video(label="Interpolation in video (if num_samples > 1)"),
94
- ],
95
- #title="Multi-Input ResShift Diffusion VFI",
96
- description=(
97
- "Video interpolation using Conditional Residual Diffusion.\n"
98
- "- All images are resized to 256x448.\n"
99
- "- If `Number of Samples = 1`, generates only one intermediate image with the given Tau value.\n"
100
- "- If `Number of Samples > 1`, ignores Tau and generates a sequence of interpolated images."
101
- ),
102
  examples=[
103
  ["_data/example_images/frame1.png", "_data/example_images/frame3.png", 0.5, 1],
104
  ],
 
105
  )
 
106
  return demo
107
 
108
  if __name__ == "__main__":
 
78
  </div>
79
  </div>
80
  """
81
+
82
  with gr.Blocks() as demo:
83
  gr.HTML(header)
84
+
85
+ with gr.Row():
86
+ img0 = gr.Image(type="pil", label="Initial Image (frame1)")
87
+ img2 = gr.Image(type="pil", label="Final Image (frame3)")
88
+
89
+ with gr.Row():
90
+ tau = gr.Slider(0.0, 1.0, step=0.05, value=0.5, label="Tau Value (only if Num Samples = 1)")
91
+ samples = gr.Slider(1, 20, step=1, value=1, label="Number of Samples")
92
+
93
+ btn = gr.Button("Generate")
94
+
95
+ with gr.Row():
96
+ output_img = gr.Image(label="Interpolated Image (if num_samples = 1)")
97
+ output_vid = gr.Video(label="Interpolation in video (if num_samples > 1)")
98
+
99
+ btn.click(interpolate, inputs=[img0, img2, tau, samples], outputs=[output_img, output_vid])
100
+
101
+ gr.Examples(
 
102
  examples=[
103
  ["_data/example_images/frame1.png", "_data/example_images/frame3.png", 0.5, 1],
104
  ],
105
+ inputs=[img0, img2, tau, samples],
106
  )
107
+
108
  return demo
109
 
110
  if __name__ == "__main__":