Spaces:
Paused
Paused
Update app_gradio.py
Browse files- app_gradio.py +33 -17
app_gradio.py
CHANGED
@@ -175,7 +175,7 @@ def process_video(num_frames, num_seeds, generator, exp_dir, load_name, caption,
|
|
175 |
|
176 |
return gifs
|
177 |
|
178 |
-
def generate_output(image, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5) -> List[str]:
|
179 |
"""Main function to generate output GIFs"""
|
180 |
exp_dir = "static/app_tmp"
|
181 |
os.makedirs(exp_dir, exist_ok=True)
|
@@ -200,6 +200,10 @@ def generate_output(image, prompt: str, num_seeds: int = 3, lambda_value: float
|
|
200 |
|
201 |
return filtered_gifs
|
202 |
|
|
|
|
|
|
|
|
|
203 |
css=""" """
|
204 |
|
205 |
def create_gradio_interface():
|
@@ -229,6 +233,13 @@ def create_gradio_interface():
|
|
229 |
interactive=True,
|
230 |
height=300 # Fixed height for consistency
|
231 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
with gr.Tab("Draw"):
|
233 |
draw_sketchpad = gr.Sketchpad(
|
234 |
value={
|
@@ -241,11 +252,13 @@ def create_gradio_interface():
|
|
241 |
layers=False,
|
242 |
height=300
|
243 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
-
def load_drawing(im):
|
246 |
-
return im["composite"]
|
247 |
-
|
248 |
-
draw_sketchpad.change(load_drawing, outputs=input_sketch, inputs=draw_sketchpad, show_progress="hidden")
|
249 |
|
250 |
|
251 |
motion_prompt = gr.Textbox(
|
@@ -270,9 +283,9 @@ def create_gradio_interface():
|
|
270 |
label="Motion Strength"
|
271 |
)
|
272 |
|
|
|
273 |
|
274 |
-
|
275 |
-
|
276 |
gr.Examples(
|
277 |
examples=[
|
278 |
['./static/examples/sketch1.png', 'The camel walks slowly'],
|
@@ -291,16 +304,9 @@ def create_gradio_interface():
|
|
291 |
inputs=[input_sketch, motion_prompt],
|
292 |
examples_per_page=4
|
293 |
)
|
294 |
-
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
"Generate Animation",
|
299 |
-
variant="primary",
|
300 |
-
elem_classes="generate-btn",
|
301 |
-
interactive=True,
|
302 |
-
)
|
303 |
-
output_gallery = gr.Gallery(
|
304 |
label="Results",
|
305 |
elem_classes="output-gallery",
|
306 |
columns=3,
|
@@ -310,7 +316,7 @@ def create_gradio_interface():
|
|
310 |
show_share_button=False,
|
311 |
object_fit="cover",
|
312 |
preview=False
|
313 |
-
|
314 |
|
315 |
|
316 |
|
@@ -325,6 +331,16 @@ def create_gradio_interface():
|
|
325 |
],
|
326 |
outputs=output_gallery
|
327 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
return demo
|
330 |
|
|
|
175 |
|
176 |
return gifs
|
177 |
|
178 |
+
def generate_output(image, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5, progress=gr.Progress(track_tqdm=True)) -> List[str]:
|
179 |
"""Main function to generate output GIFs"""
|
180 |
exp_dir = "static/app_tmp"
|
181 |
os.makedirs(exp_dir, exist_ok=True)
|
|
|
200 |
|
201 |
return filtered_gifs
|
202 |
|
203 |
+
def generate_output_from_sketchpad(image, prompt, num_seed, lambda_value, progress=gr.Progress(track_tqdm=True)):
|
204 |
+
results = generate_output(image['composite'], prompt, num_seed, lambda_value)
|
205 |
+
return results
|
206 |
+
|
207 |
css=""" """
|
208 |
|
209 |
def create_gradio_interface():
|
|
|
233 |
interactive=True,
|
234 |
height=300 # Fixed height for consistency
|
235 |
)
|
236 |
+
generate_btn = gr.Button(
|
237 |
+
"Generate Animation",
|
238 |
+
variant="primary",
|
239 |
+
elem_classes="generate-btn",
|
240 |
+
interactive=True,
|
241 |
+
)
|
242 |
+
|
243 |
with gr.Tab("Draw"):
|
244 |
draw_sketchpad = gr.Sketchpad(
|
245 |
value={
|
|
|
252 |
layers=False,
|
253 |
height=300
|
254 |
)
|
255 |
+
sketchpad_generate_btn = gr.Button(
|
256 |
+
"Generate Animation",
|
257 |
+
variant="primary",
|
258 |
+
elem_classes="generate-btn",
|
259 |
+
interactive=True,
|
260 |
+
)
|
261 |
|
|
|
|
|
|
|
|
|
262 |
|
263 |
|
264 |
motion_prompt = gr.Textbox(
|
|
|
283 |
label="Motion Strength"
|
284 |
)
|
285 |
|
286 |
+
|
287 |
|
288 |
+
with gr.Column():
|
|
|
289 |
gr.Examples(
|
290 |
examples=[
|
291 |
['./static/examples/sketch1.png', 'The camel walks slowly'],
|
|
|
304 |
inputs=[input_sketch, motion_prompt],
|
305 |
examples_per_page=4
|
306 |
)
|
|
|
307 |
|
308 |
+
|
309 |
+
output_gallery = gr.Gallery(
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
label="Results",
|
311 |
elem_classes="output-gallery",
|
312 |
columns=3,
|
|
|
316 |
show_share_button=False,
|
317 |
object_fit="cover",
|
318 |
preview=False
|
319 |
+
)
|
320 |
|
321 |
|
322 |
|
|
|
331 |
],
|
332 |
outputs=output_gallery
|
333 |
)
|
334 |
+
sketchpad_generate_btn.click(
|
335 |
+
fn=generate_output_from_sketchpad,
|
336 |
+
inputs=[
|
337 |
+
draw_sketchpad,
|
338 |
+
motion_prompt,
|
339 |
+
num_seeds,
|
340 |
+
lambda_
|
341 |
+
],
|
342 |
+
outputs=output_gallery
|
343 |
+
)
|
344 |
|
345 |
return demo
|
346 |
|