Spaces:
Paused
Paused
Update app_gradio.py
Browse files- app_gradio.py +20 -5
app_gradio.py
CHANGED
@@ -155,7 +155,7 @@ def process_video(num_frames, num_seeds, generator, exp_dir, load_name, caption,
|
|
155 |
|
156 |
return gifs
|
157 |
|
158 |
-
def generate_output(image, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5, progress=gr.Progress(track_tqdm=True)) -> List[str]:
|
159 |
"""Main function to generate output GIFs"""
|
160 |
exp_dir = "static/app_tmp"
|
161 |
os.makedirs(exp_dir, exist_ok=True)
|
@@ -178,12 +178,17 @@ def generate_output(image, prompt: str, num_seeds: int = 3, lambda_value: float
|
|
178 |
# Apply filtering (assuming filter function is imported)
|
179 |
print("APPLYING FILTERS")
|
180 |
filtered_gifs = filter(generated_gifs, temp_image_path)
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
182 |
return filtered_gifs
|
183 |
|
184 |
-
def generate_output_from_sketchpad(image, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5, progress=gr.Progress(track_tqdm=True)):
|
185 |
image = image['composite']
|
186 |
-
results = generate_output(image, prompt, num_seeds, lambda_value)
|
187 |
return results
|
188 |
|
189 |
css=""" """
|
@@ -236,7 +241,11 @@ with gr.Blocks(css=css) as demo:
|
|
236 |
value=0.5,
|
237 |
step=0.1,
|
238 |
label="Motion Strength"
|
239 |
-
)
|
|
|
|
|
|
|
|
|
240 |
|
241 |
with gr.Column():
|
242 |
gr.Examples(
|
@@ -304,6 +313,10 @@ with gr.Blocks(css=css) as demo:
|
|
304 |
step=0.1,
|
305 |
label="Motion Strength"
|
306 |
)
|
|
|
|
|
|
|
|
|
307 |
|
308 |
sketchpad_generate_btn = gr.Button(
|
309 |
"Generate Animation",
|
@@ -332,6 +345,7 @@ with gr.Blocks(css=css) as demo:
|
|
332 |
fn=generate_output,
|
333 |
inputs=[
|
334 |
input_sketch,
|
|
|
335 |
motion_prompt,
|
336 |
num_seeds,
|
337 |
lambda_
|
@@ -356,6 +370,7 @@ with gr.Blocks(css=css) as demo:
|
|
356 |
fn=generate_output_from_sketchpad,
|
357 |
inputs=[
|
358 |
draw_sketchpad,
|
|
|
359 |
draw_motion_prompt,
|
360 |
draw_num_seeds,
|
361 |
draw_lambda_,
|
|
|
155 |
|
156 |
return gifs
|
157 |
|
158 |
+
def generate_output(image, apply_filter, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5, progress=gr.Progress(track_tqdm=True)) -> List[str]:
|
159 |
"""Main function to generate output GIFs"""
|
160 |
exp_dir = "static/app_tmp"
|
161 |
os.makedirs(exp_dir, exist_ok=True)
|
|
|
178 |
# Apply filtering (assuming filter function is imported)
|
179 |
print("APPLYING FILTERS")
|
180 |
filtered_gifs = filter(generated_gifs, temp_image_path)
|
181 |
+
|
182 |
+
if apply_filter == True:
|
183 |
+
print("APPLYING FILTER")
|
184 |
+
else:
|
185 |
+
print("NOT APPLYING FILTER")
|
186 |
+
|
187 |
return filtered_gifs
|
188 |
|
189 |
+
def generate_output_from_sketchpad(image, apply_filter, prompt: str, num_seeds: int = 3, lambda_value: float = 0.5, progress=gr.Progress(track_tqdm=True)):
|
190 |
image = image['composite']
|
191 |
+
results = generate_output(image, apply_filter, prompt, num_seeds, lambda_value)
|
192 |
return results
|
193 |
|
194 |
css=""" """
|
|
|
241 |
value=0.5,
|
242 |
step=0.1,
|
243 |
label="Motion Strength"
|
244 |
+
)
|
245 |
+
apply_filter = gr.Checkbox(
|
246 |
+
value=True,
|
247 |
+
visible=False
|
248 |
+
)
|
249 |
|
250 |
with gr.Column():
|
251 |
gr.Examples(
|
|
|
313 |
step=0.1,
|
314 |
label="Motion Strength"
|
315 |
)
|
316 |
+
draw_apply_filter = gr.Checkbox(
|
317 |
+
label="Appl Filters",
|
318 |
+
value=False
|
319 |
+
)
|
320 |
|
321 |
sketchpad_generate_btn = gr.Button(
|
322 |
"Generate Animation",
|
|
|
345 |
fn=generate_output,
|
346 |
inputs=[
|
347 |
input_sketch,
|
348 |
+
apply_filter,
|
349 |
motion_prompt,
|
350 |
num_seeds,
|
351 |
lambda_
|
|
|
370 |
fn=generate_output_from_sketchpad,
|
371 |
inputs=[
|
372 |
draw_sketchpad,
|
373 |
+
draw_apply_filter,
|
374 |
draw_motion_prompt,
|
375 |
draw_num_seeds,
|
376 |
draw_lambda_,
|