Spaces:
Running
Running
Linoy Tsaban
commited on
Commit
•
96d1950
1
Parent(s):
4843bd8
Update app.py
Browse files
app.py
CHANGED
@@ -310,13 +310,20 @@ help_text = """
|
|
310 |
|
311 |
with gr.Blocks(css="style.css") as demo:
|
312 |
|
313 |
-
|
|
|
|
|
|
|
|
|
314 |
def add_concept(sega_concepts_counter):
|
315 |
if sega_concepts_counter == 1:
|
316 |
return row2.update(visible=True), row2_advanced.update(visible=True), row3.update(visible=False), row3_advanced.update(visible=False), add_concept_button.update(visible=True), 2
|
317 |
else:
|
318 |
return row2.update(visible=True), row2_advanced.update(visible=True), row3.update(visible=True), row3_advanced.update(visible=True), add_concept_button.update(visible=False), 3
|
319 |
|
|
|
|
|
|
|
320 |
def update_display_concept(add, edit_concept, neg_guidance):
|
321 |
guidance_scale_label = "Concept Guidance Scale"
|
322 |
disable_interactive = gr.update(interactive=False)
|
@@ -324,9 +331,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
324 |
if (add == 'Include' or add == 'Remove') and edit_concept != "":
|
325 |
if neg_guidance:
|
326 |
guidance_scale_label = "Negative Guidance Scale"
|
327 |
-
return gr.update(visible=True),
|
328 |
-
|
329 |
-
return gr.update(visible=False),"", gr.update(visible=False), "", gr.update(visible=False), False, "Include", enable_interactive,enable_interactive,enable_interactive,gr.update(label = guidance_scale_label)
|
330 |
|
331 |
def display_editing_options(run_button, clear_button, sega_tab):
|
332 |
return run_button.update(visible=True), clear_button.update(visible=True), sega_tab.update(visible=True)
|
@@ -393,23 +399,32 @@ with gr.Blocks(css="style.css") as demo:
|
|
393 |
|
394 |
with gr.Row():
|
395 |
with gr.Box(visible=False) as box1:
|
396 |
-
|
397 |
-
|
|
|
|
|
|
|
398 |
info="How strongly the concept should be included in the image",
|
399 |
value=DEFAULT_SEGA_CONCEPT_GUIDANCE_SCALE,
|
400 |
step=0.5, interactive=True,visible=False)
|
401 |
with gr.Box(visible=False) as box2:
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
407 |
with gr.Box(visible=False) as box3:
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
|
|
|
|
|
|
413 |
|
414 |
|
415 |
with gr.Row():
|
@@ -547,9 +562,13 @@ with gr.Blocks(css="style.css") as demo:
|
|
547 |
neg_guidance_1.change(fn = update_label, inputs=[neg_guidance_1], outputs=[add_1])
|
548 |
neg_guidance_2.change(fn = update_label, inputs=[neg_guidance_2], outputs=[add_2])
|
549 |
neg_guidance_3.change(fn = update_label, inputs=[neg_guidance_3], outputs=[add_3])
|
550 |
-
add_1.click(fn = update_display_concept, inputs=[add_1, edit_concept_1, neg_guidance_1], outputs=[box1, concept_1,
|
551 |
-
add_2.click(fn = update_display_concept, inputs=[add_2, edit_concept_2, neg_guidance_2], outputs=[box2, concept_2,
|
552 |
-
add_3.click(fn = update_display_concept, inputs=[add_3, edit_concept_3, neg_guidance_3], outputs=[box3, concept_3,
|
|
|
|
|
|
|
|
|
553 |
|
554 |
add_concept_button.click(fn = add_concept, inputs=sega_concepts_counter,
|
555 |
outputs= [row2, row2_advanced, row3, row3_advanced, add_concept_button, sega_concepts_counter], queue = False)
|
|
|
310 |
|
311 |
with gr.Blocks(css="style.css") as demo:
|
312 |
|
313 |
+
def remove_concept():
|
314 |
+
guidance_scale_label = "Concept Guidance Scale"
|
315 |
+
enable_interactive = gr.update(interactive=True)
|
316 |
+
return gr.update(visible=False), gr.update(visible=False, value="",), gr.update(interactive=True, value=""), gr.update(visible=False,label = guidance_scale_label), gr.update(interactive=True, value =False), gr.update(visible=True),enable_interactive
|
317 |
+
|
318 |
def add_concept(sega_concepts_counter):
|
319 |
if sega_concepts_counter == 1:
|
320 |
return row2.update(visible=True), row2_advanced.update(visible=True), row3.update(visible=False), row3_advanced.update(visible=False), add_concept_button.update(visible=True), 2
|
321 |
else:
|
322 |
return row2.update(visible=True), row2_advanced.update(visible=True), row3.update(visible=True), row3_advanced.update(visible=True), add_concept_button.update(visible=False), 3
|
323 |
|
324 |
+
|
325 |
+
|
326 |
+
|
327 |
def update_display_concept(add, edit_concept, neg_guidance):
|
328 |
guidance_scale_label = "Concept Guidance Scale"
|
329 |
disable_interactive = gr.update(interactive=False)
|
|
|
331 |
if (add == 'Include' or add == 'Remove') and edit_concept != "":
|
332 |
if neg_guidance:
|
333 |
guidance_scale_label = "Negative Guidance Scale"
|
334 |
+
return gr.update(visible=True), gr.update(visible=True, value=edit_concept), gr.update(value=edit_concept,interactive=False), gr.update(visible=True,label = guidance_scale_label ), gr.update(value=neg_guidance,interactive=False), gr.update(visible=False),disable_interactive, disable_interactive
|
335 |
+
|
|
|
336 |
|
337 |
def display_editing_options(run_button, clear_button, sega_tab):
|
338 |
return run_button.update(visible=True), clear_button.update(visible=True), sega_tab.update(visible=True)
|
|
|
399 |
|
400 |
with gr.Row():
|
401 |
with gr.Box(visible=False) as box1:
|
402 |
+
with gr.Row():
|
403 |
+
concept_1 = gr.Button(visible=False, scale=3)
|
404 |
+
remove_concept1 = gr.Button("x", scale=1)
|
405 |
+
with gr.Row():
|
406 |
+
guidnace_scale_1 = gr.Slider(label='Concept Guidance Scale', minimum=1, maximum=30,
|
407 |
info="How strongly the concept should be included in the image",
|
408 |
value=DEFAULT_SEGA_CONCEPT_GUIDANCE_SCALE,
|
409 |
step=0.5, interactive=True,visible=False)
|
410 |
with gr.Box(visible=False) as box2:
|
411 |
+
with gr.Row():
|
412 |
+
concept_2 = gr.Button(visible=False, scale=3)
|
413 |
+
remove_concept2 = gr.Button("x", scale=1)
|
414 |
+
with gr.Row():
|
415 |
+
guidnace_scale_2 = gr.Slider(label='Concept Guidance Scale', minimum=1, maximum=30,
|
416 |
+
info="How strongly the concept should be included in the image",
|
417 |
+
value=DEFAULT_SEGA_CONCEPT_GUIDANCE_SCALE,
|
418 |
+
step=0.5, interactive=True,visible=False)
|
419 |
with gr.Box(visible=False) as box3:
|
420 |
+
with gr.Row():
|
421 |
+
concept_3 = gr.Button(visible=False, scale=3)
|
422 |
+
remove_concept3 = gr.Button("x", scale=1)
|
423 |
+
with gr.Row():
|
424 |
+
guidnace_scale_3 = gr.Slider(label='Concept Guidance Scale', minimum=1, maximum=30,
|
425 |
+
info="How strongly the concept should be included in the image",
|
426 |
+
value=DEFAULT_SEGA_CONCEPT_GUIDANCE_SCALE,
|
427 |
+
step=0.5, interactive=True,visible=False)
|
428 |
|
429 |
|
430 |
with gr.Row():
|
|
|
562 |
neg_guidance_1.change(fn = update_label, inputs=[neg_guidance_1], outputs=[add_1])
|
563 |
neg_guidance_2.change(fn = update_label, inputs=[neg_guidance_2], outputs=[add_2])
|
564 |
neg_guidance_3.change(fn = update_label, inputs=[neg_guidance_3], outputs=[add_3])
|
565 |
+
add_1.click(fn = update_display_concept, inputs=[add_1, edit_concept_1, neg_guidance_1], outputs=[box1, concept_1, edit_concept_1, guidnace_scale_1,neg_guidance_1, add_1, dropdown1])
|
566 |
+
add_2.click(fn = update_display_concept, inputs=[add_2, edit_concept_2, neg_guidance_2], outputs=[box2, concept_2, edit_concept_2, guidnace_scale_2,neg_guidance_2, add_2 , dropdown2])
|
567 |
+
add_3.click(fn = update_display_concept, inputs=[add_3, edit_concept_3, neg_guidance_3], outputs=[box3, concept_3, edit_concept_3, guidnace_scale_3,neg_guidance_3, add_3, dropdown3])
|
568 |
+
|
569 |
+
remove_concept1.click(fn = remove_concept, outputs= [box1, concept_1, edit_concept_1, guidnace_scale_1,neg_guidance_1, add_1, dropdown1])
|
570 |
+
remove_concept2.click(fn = remove_concept, outputs=[box2, concept_2, edit_concept_2, guidnace_scale_2,neg_guidance_2, add_2 , dropdown2])
|
571 |
+
remove_concept3.click(fn = remove_concept, outputs=[box3, concept_3, edit_concept_3, guidnace_scale_3,neg_guidance_3, add_3, dropdown3])
|
572 |
|
573 |
add_concept_button.click(fn = add_concept, inputs=sega_concepts_counter,
|
574 |
outputs= [row2, row2_advanced, row3, row3_advanced, add_concept_button, sega_concepts_counter], queue = False)
|