Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -249,10 +249,13 @@ list_ratios=[["None",[None,None]],
|
|
| 249 |
["5:12 (640 x 1536)",[640,1536]],
|
| 250 |
["1:4 (512 x 2048)",[512,2048]]]
|
| 251 |
|
| 252 |
-
def fonc_add_param(lp,txt_input,neg_input,width,height,steps,cfg,seed)
|
| 253 |
if lp == [["","",0,0,0,0,-1]]:
|
| 254 |
lp.remove(["","",0,0,0,0,-1])
|
| 255 |
-
lp.append([txt_input,neg_input,width,height,steps,cfg,seed])
|
|
|
|
|
|
|
|
|
|
| 256 |
return gr.Dataset(samples=lp) , gr.Dropdown(choices=[["a",lp]], value=lp)
|
| 257 |
def fonc_del_param(lp,txt_input,neg_input,width,height,steps,cfg,seed):
|
| 258 |
if [txt_input,neg_input,width,height,steps,cfg,seed] in lp :
|
|
@@ -466,8 +469,18 @@ def fonc_load_gallery_by_model(id_session,gallery,models,index_g,index_m,gallery
|
|
| 466 |
for i in range(len(cache_image[f"{id_session}"])):
|
| 467 |
if cache_image[f"{id_session}"][i]["model"]==models[((index_m+index_g+delta)%nb_gallery_model)-delta]:
|
| 468 |
gallery=add_gallery(cache_image[f"{id_session}"][i]["image"],cache_image[f"{id_session}"][i]["model"],gallery)
|
| 469 |
-
return gr.Gallery(gallery,visible=(index_g==(index_m%nb_gallery_model))), gr.Gallery(gallery_all,visible=False)
|
| 470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
def index_gallery_next(i,list_models):
|
| 472 |
iT=i+1
|
| 473 |
return gr.Number(iT%len(list_models)),gr.Number(1)
|
|
@@ -589,6 +602,20 @@ def make_me():
|
|
| 589 |
update_actu=gr.Number(0,visible=False)
|
| 590 |
update_actu.change(fonc_update_actu,[text_actu,id_session],[text_actu])
|
| 591 |
button_start.click(fonc_update_actu,[text_actu,id_session],[text_actu])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 592 |
with gr.Row():
|
| 593 |
outputs=[]
|
| 594 |
id_modules=[]
|
|
@@ -608,46 +635,89 @@ def make_me():
|
|
| 608 |
|
| 609 |
with gr.Column(scale=2):
|
| 610 |
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
| 611 |
-
interactive=False, show_share_button=
|
| 612 |
-
preview=True, object_fit="
|
|
|
|
|
|
|
|
|
|
| 613 |
gallery_models=[]
|
| 614 |
index_gallery=[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
for i in range(nb_gallery_model):
|
| 616 |
gallery_models.append(gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
| 617 |
-
interactive=False, show_share_button=
|
| 618 |
-
preview=True, object_fit="
|
| 619 |
index_gallery.append(gr.Number(i,visible=False))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
with gr.Column(scale=3):
|
| 621 |
button_load_gallery=gr.Button("Load Gallery All")
|
| 622 |
button_load_gallery.click(fonc_load_gallery,[id_session,gallery],[gallery])
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
for g,i in zip(gallery_models,index_gallery):
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
button_add_to_fav=gr.Button("Add to Favlist")
|
| 649 |
-
text_fav=gr.Textbox(label='Favlist', lines=5, interactive = True)
|
| 650 |
-
button_add_to_fav.click(fonc_add_to_text,[text_fav,list_models_to_gen,index_gallery_m],[text_fav])
|
| 651 |
|
| 652 |
|
| 653 |
|
|
|
|
| 249 |
["5:12 (640 x 1536)",[640,1536]],
|
| 250 |
["1:4 (512 x 2048)",[512,2048]]]
|
| 251 |
|
| 252 |
+
def fonc_add_param(lp,txt_input,neg_input,width,height,steps,cfg,seed):###########################################
|
| 253 |
if lp == [["","",0,0,0,0,-1]]:
|
| 254 |
lp.remove(["","",0,0,0,0,-1])
|
| 255 |
+
#lp.append([txt_input,neg_input,width,height,steps,cfg,seed])
|
| 256 |
+
list_txt=txt_input.split("/")
|
| 257 |
+
for t in list_txt:
|
| 258 |
+
lp.append([t,neg_input,width,height,steps,cfg,seed])
|
| 259 |
return gr.Dataset(samples=lp) , gr.Dropdown(choices=[["a",lp]], value=lp)
|
| 260 |
def fonc_del_param(lp,txt_input,neg_input,width,height,steps,cfg,seed):
|
| 261 |
if [txt_input,neg_input,width,height,steps,cfg,seed] in lp :
|
|
|
|
| 469 |
for i in range(len(cache_image[f"{id_session}"])):
|
| 470 |
if cache_image[f"{id_session}"][i]["model"]==models[((index_m+index_g+delta)%nb_gallery_model)-delta]:
|
| 471 |
gallery=add_gallery(cache_image[f"{id_session}"][i]["image"],cache_image[f"{id_session}"][i]["model"],gallery)
|
| 472 |
+
return gr.Gallery(gallery,visible=(index_g==(index_m%nb_gallery_model))), gr.Gallery(gallery_all,visible=False)
|
| 473 |
+
|
| 474 |
+
def load_gallery_by_prompt(id_session,gallery,index_p,list_p):
|
| 475 |
+
#"prompt":p[0],"nprompt":p[1],"width":p[2],"height":p[3],"steps":p[4],"cfg":p[5],"seed":p[6]
|
| 476 |
+
gallery = reset_gallery(gallery)
|
| 477 |
+
for i in range(len(cache_image[f"{id_session}"])):
|
| 478 |
+
if cache_image[f"{id_session}"][i]["prompt"]==list_p[index_p][0] :
|
| 479 |
+
gallery=add_gallery(cache_image[f"{id_session}"][i]["image"],cache_image[f"{id_session}"][i]["model"],gallery)
|
| 480 |
+
if len(gallery)!=0:
|
| 481 |
+
gallery=sorted(gallery, key=itemgetter(1))
|
| 482 |
+
return gr.Gallery(gallery, visible=True)
|
| 483 |
+
|
| 484 |
def index_gallery_next(i,list_models):
|
| 485 |
iT=i+1
|
| 486 |
return gr.Number(iT%len(list_models)),gr.Number(1)
|
|
|
|
| 602 |
update_actu=gr.Number(0,visible=False)
|
| 603 |
update_actu.change(fonc_update_actu,[text_actu,id_session],[text_actu])
|
| 604 |
button_start.click(fonc_update_actu,[text_actu,id_session],[text_actu])
|
| 605 |
+
|
| 606 |
+
with gr.Accordion("Gallery Parameters",open=False) :
|
| 607 |
+
with gr.Row():
|
| 608 |
+
with gr.Column():
|
| 609 |
+
set_height_gallery=gr.Checkbox(True,label="set height",show_label=True)
|
| 610 |
+
height_gallery=gr.Number(650,label="height",show_label=True)
|
| 611 |
+
col_gallery=gr.Number(5,label="nb columns",show_label=True)
|
| 612 |
+
row_gallery=gr.Number(4,label="nb row",show_label=True)
|
| 613 |
+
with gr.Column():
|
| 614 |
+
button_reset_cache_image=gr.Button("Reset Images")
|
| 615 |
+
button_reset_cache_image.click(reset_cache_image,[id_session],[])
|
| 616 |
+
button_reset_cache_image_all_session=gr.Button("Reset Images ALL SESSION")
|
| 617 |
+
button_reset_cache_image_all_session.click(reset_cache_image_all_sessions,[],[])
|
| 618 |
+
|
| 619 |
with gr.Row():
|
| 620 |
outputs=[]
|
| 621 |
id_modules=[]
|
|
|
|
| 635 |
|
| 636 |
with gr.Column(scale=2):
|
| 637 |
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
| 638 |
+
interactive=False, show_share_button=False, container=True, format="png",
|
| 639 |
+
preview=True, object_fit="contain",columns=5,rows=4,height=650)
|
| 640 |
+
gallery_by_prompt = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
| 641 |
+
interactive=False, show_share_button=False, container=True, format="png",
|
| 642 |
+
preview=True, object_fit="contain",columns=5,rows=4,visible=False,height=650)
|
| 643 |
gallery_models=[]
|
| 644 |
index_gallery=[]
|
| 645 |
+
set_height_gallery.change(lambda g,h,s: gr.Gallery(g,height=h) if s else gr.Gallery(g,height=None),
|
| 646 |
+
[gallery,height_gallery,set_height_gallery],[gallery])
|
| 647 |
+
height_gallery.change(lambda g,h: gr.Gallery(g,height=h),[gallery,height_gallery],[gallery])
|
| 648 |
+
col_gallery.change(lambda g,h: gr.Gallery(g,columns=h),[gallery,col_gallery],[gallery])
|
| 649 |
+
row_gallery.change(lambda g,h: gr.Gallery(g,rows=h),[gallery,row_gallery],[gallery])
|
| 650 |
for i in range(nb_gallery_model):
|
| 651 |
gallery_models.append(gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
| 652 |
+
interactive=False, show_share_button=False, container=True, format="png",
|
| 653 |
+
preview=True, object_fit="contain",columns=5,rows=4,visible=False,height=650))
|
| 654 |
index_gallery.append(gr.Number(i,visible=False))
|
| 655 |
+
set_height_gallery.change(lambda g,h,s: gr.Gallery(g,height=h) if s else gr.Gallery(g,height=None),
|
| 656 |
+
[gallery_models[i],height_gallery,set_height_gallery],[gallery_models[i]])
|
| 657 |
+
height_gallery.change(lambda g,h: gr.Gallery(g,height=h),[gallery_models[i],height_gallery],[gallery_models[i]])
|
| 658 |
+
col_gallery.change(lambda g,h: gr.Gallery(g,columns=h),[gallery_models[i],col_gallery],[gallery_models[i]])
|
| 659 |
+
row_gallery.change(lambda g,h: gr.Gallery(g,rows=h),[gallery_models[i],row_gallery],[gallery_models[i]])
|
| 660 |
with gr.Column(scale=3):
|
| 661 |
button_load_gallery=gr.Button("Load Gallery All")
|
| 662 |
button_load_gallery.click(fonc_load_gallery,[id_session,gallery],[gallery])
|
| 663 |
+
|
| 664 |
+
with gr.Accordion("Gallery by Model",open=True) :
|
| 665 |
+
index_gallery_m=gr.Number(0,visible=False)
|
| 666 |
+
button_load_gallery_first=gr.Button("Init Gallery by model")
|
| 667 |
+
with gr.Row():
|
| 668 |
+
button_load_gallery_prev=gr.Button("Prev model")
|
| 669 |
+
button_load_gallery_next=gr.Button("Next model")
|
| 670 |
+
direction_gallery=gr.Number(0,visible=False)
|
| 671 |
+
button_load_gallery_next.click(index_gallery_next,[index_gallery_m,list_models_to_gen],[index_gallery_m,direction_gallery])
|
| 672 |
+
button_load_gallery_prev.click(index_gallery_prev,[index_gallery_m,list_models_to_gen],[index_gallery_m,direction_gallery])
|
| 673 |
+
for g,i in zip(gallery_models,index_gallery):
|
| 674 |
+
index_gallery_m.change(fonc_move_gallery_by_model,[id_session,g,i,list_models_to_gen,index_gallery_m,direction_gallery],[g])
|
| 675 |
+
gen_event_gallery_first = gr.on(triggers=[button_load_gallery_first.click], fn=fonc_load_gallery_by_model,
|
| 676 |
+
inputs=[id_session,g,list_models_to_gen,i,index_gallery_m,gallery], outputs=[g,gallery])
|
| 677 |
+
gen_event_gallery_first_all = gr.on(triggers=[button_load_gallery.click], fn=lambda g:gr.Gallery(g,visible=False),
|
| 678 |
+
inputs=[g], outputs=[g])
|
| 679 |
+
text_model_actu_gal = gr.Textbox(label='Model Actu:', lines=1, interactive = False)
|
| 680 |
+
index_gallery_m.change(change_text_model_actu_gal,[list_models_to_gen,index_gallery_m],[text_model_actu_gal])
|
| 681 |
+
with gr.Row():
|
| 682 |
+
with gr.Column():
|
| 683 |
+
button_add_to_bl=gr.Button("Add to Blacklist")
|
| 684 |
+
#button_remove_from_bl=gr.Button("Remove from Blacklist")
|
| 685 |
+
text_bl=gr.Textbox(label='Blacklist', lines=5, interactive = True)
|
| 686 |
+
button_add_to_bl.click(fonc_add_to_text,[text_bl,list_models_to_gen,index_gallery_m],[text_bl])
|
| 687 |
+
#button_remove_from_bl.click(fonc_remove_from_text,[text_bl,list_models_to_gen,index_gallery_m],[text_bl])
|
| 688 |
+
with gr.Column():
|
| 689 |
+
button_add_to_fav=gr.Button("Add to Favlist")
|
| 690 |
+
text_fav=gr.Textbox(label='Favlist', lines=5, interactive = True)
|
| 691 |
+
button_add_to_fav.click(fonc_add_to_text,[text_fav,list_models_to_gen,index_gallery_m],[text_fav])
|
| 692 |
+
with gr.Accordion("Gallery by Prompt",open=False) :
|
| 693 |
+
index_gallery_by_prompt=gr.Number(0,visible=False)
|
| 694 |
+
button_load_gallery_by_prompt=gr.Button("Load Gallery by prompt")
|
| 695 |
+
text_gallery_by_prompt=gr.Textbox(f"{index_gallery_by_prompt.value+1}/{len(list_param.value)}",show_label=False)
|
| 696 |
+
index_gallery_by_prompt.change(lambda i,p:gr.Textbox(f"{i+1}/{len(p)}"),[index_gallery_by_prompt,list_param],[text_gallery_by_prompt])
|
| 697 |
+
button_load_gallery_by_prompt.click(load_gallery_by_prompt,
|
| 698 |
+
[id_session,gallery_by_prompt,index_gallery_by_prompt,list_param],[gallery_by_prompt])
|
| 699 |
+
gen_event_gallery_by_prompt = gr.on(triggers=[button_load_gallery_by_prompt.click], fn=lambda g:gr.Gallery(g,visible=False),
|
| 700 |
+
inputs=[gallery], outputs=[gallery])
|
| 701 |
+
gen_event_gallery_first = gr.on(triggers=[button_load_gallery_first.click], fn=lambda g:gr.Gallery(g,visible=False),
|
| 702 |
+
inputs=[gallery_by_prompt], outputs=[gallery_by_prompt])
|
| 703 |
+
gen_event_gallery = gr.on(triggers=[button_load_gallery.click], fn=lambda g:gr.Gallery(g,visible=False),
|
| 704 |
+
inputs=[gallery_by_prompt], outputs=[gallery_by_prompt])
|
| 705 |
for g,i in zip(gallery_models,index_gallery):
|
| 706 |
+
gen_event_gallery_by_prompt = gr.on(triggers=[button_load_gallery_by_prompt.click], fn=lambda g:gr.Gallery(g,visible=False),
|
| 707 |
+
inputs=[g], outputs=[g])
|
| 708 |
+
with gr.Row():
|
| 709 |
+
button_gallery_prev_prompt=gr.Button("Prev prompt")
|
| 710 |
+
button_gallery_next_prompt=gr.Button("Next prompt")
|
| 711 |
+
button_gallery_next_prompt.click(lambda i,p: (i+1)%len(p),[index_gallery_by_prompt,list_param],[index_gallery_by_prompt])
|
| 712 |
+
button_gallery_prev_prompt.click(lambda i,p: (i-1)%len(p),[index_gallery_by_prompt,list_param],[index_gallery_by_prompt])
|
| 713 |
+
index_gallery_by_prompt.change(load_gallery_by_prompt,
|
| 714 |
+
[id_session,gallery_by_prompt,index_gallery_by_prompt,list_param],[gallery_by_prompt])
|
| 715 |
+
set_height_gallery.change(lambda g,h,s: gr.Gallery(g,height=h) if s else gr.Gallery(g,height=None),
|
| 716 |
+
[gallery_by_prompt,height_gallery,set_height_gallery],[gallery_by_prompt])
|
| 717 |
+
height_gallery.change(lambda g,h: gr.Gallery(g,height=h),[gallery_by_prompt,height_gallery],[gallery_by_prompt])
|
| 718 |
+
col_gallery.change(lambda g,h: gr.Gallery(g,columns=h),[gallery_by_prompt,col_gallery],[gallery_by_prompt])
|
| 719 |
+
row_gallery.change(lambda g,h: gr.Gallery(g,rows=h),[gallery_by_prompt,row_gallery],[gallery_by_prompt])
|
| 720 |
+
|
|
|
|
|
|
|
|
|
|
| 721 |
|
| 722 |
|
| 723 |
|