Spaces:
Configuration error
Configuration error
root
commited on
Commit
•
f9009d9
1
Parent(s):
8fe6d83
change ui to vertical
Browse files
app.py
CHANGED
@@ -517,55 +517,55 @@ with gr.Blocks(css=css) as demo:
|
|
517 |
base_model_to_use = gr.Dropdown(label="Which base model would you like to use?", choices=["alt", "alt_m9"], value="alt_m9", interactive=True)
|
518 |
|
519 |
#Very hacky approach to emulate dynamically created Gradio components
|
520 |
-
with gr.
|
521 |
with gr.Column():
|
522 |
thing_description = gr.Markdown("You are going to train an `object`, please upload 5-10 images of the object you are planning on training on from different angles/perspectives. You must have the right to do so and you are liable for the images you use, example")
|
523 |
thing_experimental = gr.Checkbox(label="Improve faces (prior preservation) - can take longer training but can improve faces", visible=False, value=False)
|
524 |
thing_image_example = gr.HTML('''<img src="file/cat-toy.png" />''')
|
525 |
things_naming = gr.Markdown("You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `cttoy` here). Images will be automatically cropped to 512x512.")
|
526 |
|
527 |
-
with gr.Column():
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
|
570 |
with gr.Accordion("Custom Settings", open=False):
|
571 |
swap_auto_calculated = gr.Checkbox(label="Use custom settings")
|
|
|
517 |
base_model_to_use = gr.Dropdown(label="Which base model would you like to use?", choices=["alt", "alt_m9"], value="alt_m9", interactive=True)
|
518 |
|
519 |
#Very hacky approach to emulate dynamically created Gradio components
|
520 |
+
with gr.Column() as upload_your_concept:
|
521 |
with gr.Column():
|
522 |
thing_description = gr.Markdown("You are going to train an `object`, please upload 5-10 images of the object you are planning on training on from different angles/perspectives. You must have the right to do so and you are liable for the images you use, example")
|
523 |
thing_experimental = gr.Checkbox(label="Improve faces (prior preservation) - can take longer training but can improve faces", visible=False, value=False)
|
524 |
thing_image_example = gr.HTML('''<img src="file/cat-toy.png" />''')
|
525 |
things_naming = gr.Markdown("You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `cttoy` here). Images will be automatically cropped to 512x512.")
|
526 |
|
527 |
+
# with gr.Column():
|
528 |
+
file_collection = []
|
529 |
+
concept_collection = []
|
530 |
+
buttons_collection = []
|
531 |
+
delete_collection = []
|
532 |
+
is_visible = []
|
533 |
|
534 |
+
row = [None] * maximum_concepts
|
535 |
+
for x in range(maximum_concepts):
|
536 |
+
ordinal = lambda n: "%d%s" % (n, "tsnrhtdd"[(n // 10 % 10 != 1) * (n % 10 < 4) * n % 10::4])
|
537 |
+
if(x == 0):
|
538 |
+
visible = True
|
539 |
+
is_visible.append(gr.State(value=True))
|
540 |
+
else:
|
541 |
+
visible = False
|
542 |
+
is_visible.append(gr.State(value=False))
|
543 |
|
544 |
+
file_collection.append(gr.File(label=f'''Upload the images for your {ordinal(x+1) if (x>0) else ""} concept''', file_count="multiple", interactive=True, visible=visible))
|
545 |
+
with gr.Column(visible=visible) as row[x]:
|
546 |
+
concept_collection.append(gr.Textbox(label=f'''{ordinal(x+1) if (x>0) else ""} concept prompt - use a unique, made up word to avoid collisions'''))
|
547 |
+
with gr.Row():
|
548 |
+
if(x < maximum_concepts-1):
|
549 |
+
buttons_collection.append(gr.Button(value="Add +1 concept", visible=visible))
|
550 |
+
if(x > 0):
|
551 |
+
delete_collection.append(gr.Button(value=f"Delete {ordinal(x+1)} concept"))
|
552 |
+
|
553 |
+
counter_add = 1
|
554 |
+
for button in buttons_collection:
|
555 |
+
if(counter_add < len(buttons_collection)):
|
556 |
+
button.click(lambda:
|
557 |
+
[gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), True, None],
|
558 |
+
None,
|
559 |
+
[row[counter_add], file_collection[counter_add], buttons_collection[counter_add-1], buttons_collection[counter_add], is_visible[counter_add], file_collection[counter_add]], queue=False)
|
560 |
+
else:
|
561 |
+
button.click(lambda:[gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), True], None, [row[counter_add], file_collection[counter_add], buttons_collection[counter_add-1], is_visible[counter_add]], queue=False)
|
562 |
+
counter_add += 1
|
563 |
+
|
564 |
+
counter_delete = 1
|
565 |
+
for delete_button in delete_collection:
|
566 |
+
if(counter_delete < len(delete_collection)+1):
|
567 |
+
delete_button.click(lambda:[gr.update(visible=False),gr.update(visible=False), gr.update(visible=True), False], None, [file_collection[counter_delete], row[counter_delete], buttons_collection[counter_delete-1], is_visible[counter_delete]], queue=False)
|
568 |
+
counter_delete += 1
|
569 |
|
570 |
with gr.Accordion("Custom Settings", open=False):
|
571 |
swap_auto_calculated = gr.Checkbox(label="Use custom settings")
|