Spaces:
Configuration error
Configuration error
Sreerama
commited on
Commit
·
dc54f82
1
Parent(s):
fce5e9a
vertical align
Browse files
app.py
CHANGED
@@ -501,55 +501,56 @@ with gr.Blocks(css=css) as demo:
|
|
501 |
''')
|
502 |
|
503 |
#Very hacky approach to emulate dynamically created Gradio components
|
504 |
-
with gr.
|
505 |
with gr.Column():
|
506 |
thing_description = gr.Markdown("You are going to train an object or style, please upload 10-20 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")
|
507 |
thing_experimental = gr.Checkbox(label="Improve faces (prior preservation) - can take longer training but can improve faces", visible=False, value=False)
|
508 |
-
thing_image_example = gr.HTML('''<img src="file/cat-toy.png"
|
509 |
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.: `fantasy_world` here). Images will be automatically cropped to 512x512.")
|
510 |
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
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 |
with gr.Accordion("Custom Settings", open=False):
|
555 |
with gr.Row() as what_are_you_training:
|
|
|
501 |
''')
|
502 |
|
503 |
#Very hacky approach to emulate dynamically created Gradio components
|
504 |
+
with gr.Column() as upload_your_concept:
|
505 |
with gr.Column():
|
506 |
thing_description = gr.Markdown("You are going to train an object or style, please upload 10-20 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")
|
507 |
thing_experimental = gr.Checkbox(label="Improve faces (prior preservation) - can take longer training but can improve faces", visible=False, value=False)
|
508 |
+
thing_image_example = gr.HTML('''<div style="display:flex;justify-content:center"><img src="file/cat-toy.png" /></div>''')
|
509 |
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.: `fantasy_world` here). Images will be automatically cropped to 512x512.")
|
510 |
|
511 |
+
|
512 |
+
file_collection = []
|
513 |
+
concept_collection = []
|
514 |
+
buttons_collection = []
|
515 |
+
delete_collection = []
|
516 |
+
is_visible = []
|
517 |
+
|
518 |
+
row = [None] * maximum_concepts
|
519 |
+
for x in range(maximum_concepts):
|
520 |
+
ordinal = lambda n: "%d%s" % (n, "tsnrhtdd"[(n // 10 % 10 != 1) * (n % 10 < 4) * n % 10::4])
|
521 |
+
if(x == 0):
|
522 |
+
visible = True
|
523 |
+
is_visible.append(gr.State(value=True))
|
524 |
+
else:
|
525 |
+
visible = False
|
526 |
+
is_visible.append(gr.State(value=False))
|
527 |
+
|
528 |
+
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))
|
529 |
+
with gr.Column(visible=visible) as row[x]:
|
530 |
+
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'''))
|
531 |
+
# with gr.Row():
|
532 |
+
# if(x < maximum_concepts-1):
|
533 |
+
# buttons_collection.append(gr.Button(value="Add +1 concept", visible=visible))
|
534 |
+
# if(x > 0):
|
535 |
+
# delete_collection.append(gr.Button(value=f"Delete {ordinal(x+1)} concept"))
|
536 |
+
|
537 |
+
counter_add = 1
|
538 |
+
for button in buttons_collection:
|
539 |
+
if(counter_add < len(buttons_collection)):
|
540 |
+
button.click(lambda:
|
541 |
+
[gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), True, None],
|
542 |
+
None,
|
543 |
+
[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)
|
544 |
+
else:
|
545 |
+
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)
|
546 |
+
counter_add += 1
|
547 |
+
|
548 |
+
counter_delete = 1
|
549 |
+
for delete_button in delete_collection:
|
550 |
+
if(counter_delete < len(delete_collection)+1):
|
551 |
+
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)
|
552 |
+
counter_delete += 1
|
553 |
+
|
554 |
|
555 |
with gr.Accordion("Custom Settings", open=False):
|
556 |
with gr.Row() as what_are_you_training:
|