Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
6d75eb4
1
Parent(s):
7a6e2eb
Update app.py
Browse files
app.py
CHANGED
@@ -216,11 +216,17 @@ with gr.Blocks(css='style.css') as demo:
|
|
216 |
def reset_do_inversion():
|
217 |
do_inversion = True
|
218 |
return do_inversion
|
|
|
|
|
219 |
gr.HTML(intro)
|
220 |
wts = gr.State()
|
221 |
zs = gr.State()
|
222 |
do_inversion = gr.State(value=True)
|
|
|
223 |
sega_concepts_counter = gr.State(1)
|
|
|
|
|
|
|
224 |
with gr.Row():
|
225 |
input_image = gr.Image(label="Input Image", interactive=True)
|
226 |
# ddpm_edited_image = gr.Image(label=f"DDPM Reconstructed Image", interactive=False, visible=False)
|
@@ -303,7 +309,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
303 |
seed = gr.Number(value=0, precision=0, label="Seed", interactive=True)
|
304 |
randomize_seed = gr.Checkbox(label='Randomize seed', value=False)
|
305 |
with gr.Column():
|
306 |
-
skip = gr.Slider(minimum=0, maximum=
|
307 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
308 |
|
309 |
|
@@ -348,14 +354,41 @@ with gr.Blocks(css='style.css') as demo:
|
|
348 |
threshold_1, threshold_2, threshold_3
|
349 |
|
350 |
],
|
351 |
-
outputs=[sega_edited_image],
|
352 |
-
|
353 |
)
|
354 |
|
|
|
355 |
input_image.change(
|
356 |
fn = reset_do_inversion,
|
357 |
-
outputs = [do_inversion]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
gr.Examples(
|
361 |
label='Examples',
|
|
|
216 |
def reset_do_inversion():
|
217 |
do_inversion = True
|
218 |
return do_inversion
|
219 |
+
|
220 |
+
|
221 |
gr.HTML(intro)
|
222 |
wts = gr.State()
|
223 |
zs = gr.State()
|
224 |
do_inversion = gr.State(value=True)
|
225 |
+
src_prompt_changed = gr.State(value=False)
|
226 |
sega_concepts_counter = gr.State(1)
|
227 |
+
|
228 |
+
|
229 |
+
|
230 |
with gr.Row():
|
231 |
input_image = gr.Image(label="Input Image", interactive=True)
|
232 |
# ddpm_edited_image = gr.Image(label=f"DDPM Reconstructed Image", interactive=False, visible=False)
|
|
|
309 |
seed = gr.Number(value=0, precision=0, label="Seed", interactive=True)
|
310 |
randomize_seed = gr.Checkbox(label='Randomize seed', value=False)
|
311 |
with gr.Column():
|
312 |
+
skip = gr.Slider(minimum=0, maximum=60, value=36, label="Skip Steps", interactive=True)
|
313 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
314 |
|
315 |
|
|
|
354 |
threshold_1, threshold_2, threshold_3
|
355 |
|
356 |
],
|
357 |
+
outputs=[sega_edited_image],
|
|
|
358 |
)
|
359 |
|
360 |
+
# Automatically start inverting upon input_image change
|
361 |
input_image.change(
|
362 |
fn = reset_do_inversion,
|
363 |
+
outputs = [do_inversion], queue = False
|
364 |
+
).then(
|
365 |
+
fn=invert_and_reconstruct,
|
366 |
+
inputs=[input_image,
|
367 |
+
do_inversion,
|
368 |
+
seed, randomize_seed,
|
369 |
+
wts, zs,
|
370 |
+
src_prompt,
|
371 |
+
tar_prompt,
|
372 |
+
steps,
|
373 |
+
src_cfg_scale,
|
374 |
+
skip,
|
375 |
+
tar_cfg_scale,
|
376 |
+
],
|
377 |
+
# outputs=[ddpm_edited_image, wts, zs, do_inversion],
|
378 |
+
outputs=[wts, zs, do_inversion],
|
379 |
+
)
|
380 |
+
|
381 |
+
# Repeat inversion when these params are changed:
|
382 |
+
src_prompt.changed(
|
383 |
+
fn = reset_do_inversion,
|
384 |
+
outputs = [do_inversion], queue = False
|
385 |
)
|
386 |
+
steps.changed(fn = reset_do_inversion,
|
387 |
+
outputs = [do_inversion], queue = False)
|
388 |
+
|
389 |
+
src_cfg_scale.changed(fn = reset_do_inversion,
|
390 |
+
outputs = [do_inversion], queue = False)
|
391 |
+
|
392 |
|
393 |
gr.Examples(
|
394 |
label='Examples',
|