Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,94 +25,6 @@ nb_models=nb_mod_dif*nb_rep
|
|
25 |
cache_image={}
|
26 |
cache_image_actu={}
|
27 |
|
28 |
-
def split_models(models,nb_models):
|
29 |
-
models_temp=[]
|
30 |
-
models_lis_temp=[]
|
31 |
-
i=0
|
32 |
-
for m in models:
|
33 |
-
models_temp.append(m)
|
34 |
-
i=i+1
|
35 |
-
if i%nb_models==0:
|
36 |
-
models_lis_temp.append(models_temp)
|
37 |
-
models_temp=[]
|
38 |
-
if len(models_temp)>1:
|
39 |
-
models_lis_temp.append(models_temp)
|
40 |
-
return models_lis_temp
|
41 |
-
|
42 |
-
def split_models_axb(models,a,b):
|
43 |
-
models_temp=[]
|
44 |
-
models_lis_temp=[]
|
45 |
-
i=0
|
46 |
-
nb_models=b
|
47 |
-
for m in models:
|
48 |
-
for j in range(a):
|
49 |
-
models_temp.append(m)
|
50 |
-
i=i+1
|
51 |
-
if i%nb_models==0:
|
52 |
-
models_lis_temp.append(models_temp)
|
53 |
-
models_temp=[]
|
54 |
-
if len(models_temp)>1:
|
55 |
-
models_lis_temp.append(models_temp)
|
56 |
-
return models_lis_temp
|
57 |
-
|
58 |
-
def split_models_8x3(models,nb_models):
|
59 |
-
models_temp=[]
|
60 |
-
models_lis_temp=[]
|
61 |
-
i=0
|
62 |
-
nb_models_x3=8
|
63 |
-
for m in models:
|
64 |
-
models_temp.append(m)
|
65 |
-
i=i+1
|
66 |
-
if i%nb_models_x3==0:
|
67 |
-
models_lis_temp.append(models_temp+models_temp+models_temp)
|
68 |
-
models_temp=[]
|
69 |
-
if len(models_temp)>1:
|
70 |
-
models_lis_temp.append(models_temp+models_temp+models_temp)
|
71 |
-
return models_lis_temp
|
72 |
-
|
73 |
-
def construct_list_models(tags_plus_models,nb_rep,nb_mod_dif):
|
74 |
-
list_temp=[]
|
75 |
-
output=[]
|
76 |
-
for tag_plus_models in tags_plus_models:
|
77 |
-
list_temp=split_models_axb(tag_plus_models[2],nb_rep,nb_mod_dif)
|
78 |
-
list_temp2=[]
|
79 |
-
i=0
|
80 |
-
for elem in list_temp:
|
81 |
-
list_temp2.append([f"{tag_plus_models[0]}_{i+1}/{len(list_temp)} ({len(elem)}) : {elem[0]} - {elem[len(elem)-1]}" ,elem])
|
82 |
-
i+=1
|
83 |
-
output.append([f"{tag_plus_models[0]} ({tag_plus_models[1]})",list_temp2])
|
84 |
-
tag_plus_models[0]=f"{tag_plus_models[0]} ({tag_plus_models[1]})"
|
85 |
-
return output
|
86 |
-
|
87 |
-
models_test = []
|
88 |
-
models_test = construct_list_models(tags_plus_models,nb_rep,nb_mod_dif)
|
89 |
-
|
90 |
-
def get_current_time():
|
91 |
-
now = datetime.now()
|
92 |
-
now2 = now
|
93 |
-
current_time = now2.strftime("%Y-%m-%d %H:%M:%S")
|
94 |
-
kii = "" # ?
|
95 |
-
ki = f'{kii} {current_time}'
|
96 |
-
return ki
|
97 |
-
|
98 |
-
def load_fn_original(models):
|
99 |
-
global models_load
|
100 |
-
global num_models
|
101 |
-
global default_models
|
102 |
-
models_load = {}
|
103 |
-
num_models = len(models)
|
104 |
-
if num_models!=0:
|
105 |
-
default_models = models[:num_models]
|
106 |
-
else:
|
107 |
-
default_models = {}
|
108 |
-
for model in models:
|
109 |
-
if model not in models_load.keys():
|
110 |
-
try:
|
111 |
-
m = gr.load(f'models/{model}')
|
112 |
-
except Exception as error:
|
113 |
-
m = gr.Interface(lambda txt: None, ['text'], ['image'])
|
114 |
-
print(error)
|
115 |
-
models_load.update({model: m})
|
116 |
|
117 |
def load_fn(models):
|
118 |
global models_load
|
@@ -138,85 +50,8 @@ def load_fn(models):
|
|
138 |
models_load.update({model: m})
|
139 |
|
140 |
|
141 |
-
"""models = models_test[1]"""
|
142 |
-
#load_fn_original
|
143 |
load_fn(models)
|
144 |
-
"""models = {}
|
145 |
-
load_fn(models)"""
|
146 |
|
147 |
-
|
148 |
-
def extend_choices(choices):
|
149 |
-
return choices + (nb_models - len(choices)) * ['NA']
|
150 |
-
"""return choices + (num_models - len(choices)) * ['NA']"""
|
151 |
-
|
152 |
-
def extend_choices_b(choices):
|
153 |
-
choices_plus = extend_choices(choices)
|
154 |
-
return [gr.Textbox(m, visible=False) for m in choices_plus]
|
155 |
-
|
156 |
-
def update_imgbox(choices):
|
157 |
-
choices_plus = extend_choices(choices)
|
158 |
-
return [gr.Image(None, label=m,interactive=False, visible=(m != 'NA'),show_share_button=False) for m in choices_plus]
|
159 |
-
|
160 |
-
def choice_group_a(group_model_choice):
|
161 |
-
return group_model_choice
|
162 |
-
|
163 |
-
def choice_group_b(group_model_choice):
|
164 |
-
choiceTemp =choice_group_a(group_model_choice)
|
165 |
-
choiceTemp = extend_choices(choiceTemp)
|
166 |
-
"""return [gr.Image(label=m, min_width=170, height=170) for m in choice]"""
|
167 |
-
return [gr.Image(None, label=m,interactive=False, visible=(m != 'NA'),show_share_button=False) for m in choiceTemp]
|
168 |
-
|
169 |
-
def choice_group_c(group_model_choice):
|
170 |
-
choiceTemp=choice_group_a(group_model_choice)
|
171 |
-
choiceTemp = extend_choices(choiceTemp)
|
172 |
-
return [gr.Textbox(m) for m in choiceTemp]
|
173 |
-
|
174 |
-
def choice_group_d(group_model_choice):
|
175 |
-
choiceTemp=choice_group_a(group_model_choice)
|
176 |
-
choiceTemp = extend_choices(choiceTemp)
|
177 |
-
return [gr.Textbox(choiceTemp[i*nb_rep], visible=(choiceTemp[i*nb_rep] != 'NA'),show_label=False) for i in range(nb_mod_dif)]
|
178 |
-
def choice_group_e(group_model_choice):
|
179 |
-
choiceTemp=choice_group_a(group_model_choice)
|
180 |
-
choiceTemp = extend_choices(choiceTemp)
|
181 |
-
return [gr.Column(visible=(choiceTemp[i*nb_rep] != 'NA')) for i in range(nb_mod_dif)]
|
182 |
-
|
183 |
-
def cutStrg(longStrg,start,end):
|
184 |
-
shortStrg=''
|
185 |
-
for i in range(end-start):
|
186 |
-
shortStrg+=longStrg[start+i]
|
187 |
-
return shortStrg
|
188 |
-
|
189 |
-
def aff_models_perso(txt_list_perso,nb_models=nb_models,models=models):
|
190 |
-
list_perso=[]
|
191 |
-
t1=True
|
192 |
-
start=txt_list_perso.find('\"')
|
193 |
-
if start!=-1:
|
194 |
-
while t1:
|
195 |
-
start+=1
|
196 |
-
end=txt_list_perso.find('\"',start)
|
197 |
-
if end != -1:
|
198 |
-
txtTemp=cutStrg(txt_list_perso,start,end)
|
199 |
-
if txtTemp in models:
|
200 |
-
list_perso.append(cutStrg(txt_list_perso,start,end))
|
201 |
-
else :
|
202 |
-
t1=False
|
203 |
-
start=txt_list_perso.find('\"',end+1)
|
204 |
-
if start==-1:
|
205 |
-
t1=False
|
206 |
-
if len(list_perso)>=nb_models:
|
207 |
-
t1=False
|
208 |
-
return list_perso
|
209 |
-
|
210 |
-
def aff_models_perso_b(txt_list_perso):
|
211 |
-
return choice_group_b(aff_models_perso(txt_list_perso))
|
212 |
-
|
213 |
-
def aff_models_perso_c(txt_list_perso):
|
214 |
-
return choice_group_c(aff_models_perso(txt_list_perso))
|
215 |
-
|
216 |
-
|
217 |
-
def tag_choice(group_tag_choice):
|
218 |
-
return gr.Dropdown(label="List of Models with the chosen Tag", show_label=True, choices=list(group_tag_choice) , interactive = True , filterable = False)
|
219 |
-
|
220 |
def test_pass(test):
|
221 |
if test==os.getenv('p'):
|
222 |
print("ok")
|
@@ -280,19 +115,6 @@ def gen_fn(model_str, prompt, nprompt="", height=None, width=None, steps=None, c
|
|
280 |
loop.close()
|
281 |
return result
|
282 |
|
283 |
-
def gen_fn_original(model_str, prompt):
|
284 |
-
if model_str == 'NA':
|
285 |
-
return None
|
286 |
-
noise = str(randint(0, 9999))
|
287 |
-
try :
|
288 |
-
m=models_load[model_str](f'{prompt} {noise}')
|
289 |
-
except Exception as error :
|
290 |
-
print("error : " + model_str)
|
291 |
-
print(error)
|
292 |
-
m=False
|
293 |
-
|
294 |
-
return m
|
295 |
-
|
296 |
|
297 |
def add_gallery(image, model_str, gallery):
|
298 |
if gallery is None: gallery = []
|
@@ -407,44 +229,6 @@ def search_info(txt_search_info,models_plus_tags=models_plus_tags):
|
|
407 |
outputList.append("Model Not Find")
|
408 |
return gr.Textbox(label="out",value=outputList)
|
409 |
|
410 |
-
def add_in_blacklist(bl,model):
|
411 |
-
return gr.Textbox(bl+(f"\"{model}\",\n"))
|
412 |
-
def add_in_fav(fav,model):
|
413 |
-
return gr.Textbox(fav+(f"\"{model}\",\n"))
|
414 |
-
def rand_from_all_all_models():
|
415 |
-
if len(tags_plus_models[0][2])<nb_mod_dif:
|
416 |
-
return choice_group_c(tags_plus_models[0][2])
|
417 |
-
else:
|
418 |
-
result=[]
|
419 |
-
list_index_temp=[]
|
420 |
-
for i in range(len(tags_plus_models[0][2])):
|
421 |
-
list_index_temp.append(i)
|
422 |
-
for i in range(nb_mod_dif):
|
423 |
-
index_temp=randint(1,len(list_index_temp))-1
|
424 |
-
for j in range(nb_rep):
|
425 |
-
result.append(gr.Textbox(tags_plus_models[0][2][list_index_temp[index_temp]]))
|
426 |
-
list_index_temp.remove(list_index_temp[index_temp])
|
427 |
-
return result
|
428 |
-
def rand_from_tag_all_models(index):
|
429 |
-
if len(tags_plus_models[index][2])<nb_mod_dif:
|
430 |
-
return choice_group_c(models_test[index][1][0][1])
|
431 |
-
else:
|
432 |
-
result=[]
|
433 |
-
list_index_temp=[]
|
434 |
-
for i in range(len(tags_plus_models[index][2])):
|
435 |
-
list_index_temp.append(i)
|
436 |
-
for i in range(nb_mod_dif):
|
437 |
-
index_temp=randint(1,len(list_index_temp))-1
|
438 |
-
for j in range(nb_rep):
|
439 |
-
result.append(gr.Textbox(tags_plus_models[index][2][list_index_temp[index_temp]]))
|
440 |
-
list_index_temp.remove(list_index_temp[index_temp])
|
441 |
-
return result
|
442 |
-
|
443 |
-
def find_index_tag(group_tag_choice):
|
444 |
-
for i in (range(len(models_test)-1)):
|
445 |
-
if models_test[i][1]==group_tag_choice:
|
446 |
-
return gr.Number(i)
|
447 |
-
return gr.Number(0)
|
448 |
|
449 |
def ratio_chosen(choice_ratio,width,height):
|
450 |
if choice_ratio == [None,None]:
|
@@ -466,10 +250,7 @@ list_ratios=[["None",[None,None]],
|
|
466 |
["1:4 (512 x 2048)",[512,2048]]]
|
467 |
|
468 |
def make_me():
|
469 |
-
# with gr.Tab('The Dream'):
|
470 |
with gr.Row():
|
471 |
-
#txt_input = gr.Textbox(lines=3, width=300, max_height=100)
|
472 |
-
#txt_input = gr.Textbox(label='Your prompt:', lines=3, width=300, max_height=100)
|
473 |
with gr.Column(scale=4):
|
474 |
with gr.Group():
|
475 |
txt_input = gr.Textbox(label='Your prompt:', lines=3)
|
@@ -487,174 +268,19 @@ def make_me():
|
|
487 |
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
488 |
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
489 |
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
490 |
-
#gen_button = gr.Button('Generate images', width=150, height=30)
|
491 |
-
#stop_button = gr.Button('Stop', variant='secondary', interactive=False, width=150, height=30)
|
492 |
gen_button = gr.Button('Generate images', scale=3)
|
493 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False, scale=1)
|
494 |
-
|
495 |
gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
|
496 |
-
#gr.HTML("""
|
497 |
-
#<div style="text-align: center; max-width: 100%; margin: 0 auto;">
|
498 |
-
# <body>
|
499 |
-
# </body>
|
500 |
-
#</div>
|
501 |
-
#""")
|
502 |
-
with gr.Row() as block_images:
|
503 |
-
choices=[models_test[0][1][0][1][0]]
|
504 |
-
output = []
|
505 |
-
current_models = []
|
506 |
-
#text_disp_models = []
|
507 |
-
block_images_liste = []
|
508 |
-
block_images_options_liste = []
|
509 |
-
button_rand_from_tag=[]
|
510 |
-
button_rand_from_all=[]
|
511 |
-
button_rand_from_fav=[]
|
512 |
-
button_blacklisted=[]
|
513 |
-
button_favorites=[]
|
514 |
-
choices_plus = extend_choices(choices)
|
515 |
-
for i in range(nb_mod_dif):
|
516 |
-
with gr.Column(visible=(choices_plus[i*nb_rep] != 'NA')) as block_Temp :
|
517 |
-
block_images_liste.append(block_Temp)
|
518 |
-
with gr.Group():
|
519 |
-
with gr.Row():
|
520 |
-
for j in range(nb_rep):
|
521 |
-
output.append(gr.Image(None, label=choices_plus[i*nb_rep+j],interactive=False,
|
522 |
-
visible=(choices_plus[i*nb_rep+j] != 'NA'),show_label=False,show_share_button=False))
|
523 |
-
for j in range(nb_rep):
|
524 |
-
current_models.append(gr.Textbox(choices_plus[i*nb_rep+j], visible=(j==0),show_label=False))
|
525 |
-
#text_disp_models.append(gr.Textbox(choices_plus[i*nb_rep], visible=(choices_plus[i*nb_rep] != 'NA'),show_label=False))
|
526 |
-
with gr.Row(visible=False) as block_Temp:
|
527 |
-
block_images_options_liste.append(block_Temp)
|
528 |
-
button_rand_from_tag.append(gr.Button("Random\nfrom tag"))
|
529 |
-
button_rand_from_all.append(gr.Button("Random\nfrom all"))
|
530 |
-
button_rand_from_fav.append(gr.Button("Random\nfrom fav"))
|
531 |
-
button_blacklisted.append(gr.Button("put in\nblacklist"))
|
532 |
-
button_favorites.append(gr.Button("put in\nfavorites"))
|
533 |
-
|
534 |
-
|
535 |
-
#output = update_imgbox([choices[0]])
|
536 |
-
#current_models = extend_choices_b([choices[0]])
|
537 |
|
538 |
-
|
539 |
-
|
540 |
-
inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o])
|
541 |
-
stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
|
542 |
-
|
543 |
-
with gr.Row() as blockPass:
|
544 |
-
txt_input_p = gr.Textbox(label="Pass", lines=1)
|
545 |
-
test_button = gr.Button(' ')
|
546 |
-
|
547 |
-
|
548 |
-
with gr.Accordion( open=True, visible=False) as stuffs:
|
549 |
-
with gr.Accordion("Advanced",open=False):
|
550 |
-
images_options=gr.Checkbox(False,label="Images Options")
|
551 |
-
images_options.change(lambda x:[gr.Row(visible=x) for b in range(nb_mod_dif)],[images_options],block_images_options_liste)
|
552 |
-
blacklist_perso=gr.Textbox(label="Blacklist perso")
|
553 |
-
fav_perso=gr.Textbox(label="Fav perso")
|
554 |
-
button_rand_from_tag_all_models=gr.Button("Random all models from tag")
|
555 |
-
button_rand_from_all_all_models=gr.Button("Random all models from all")
|
556 |
-
button_rand_from_fav_all_models=gr.Button("Random all models from fav")
|
557 |
-
|
558 |
-
|
559 |
-
with gr.Accordion("Gallery",open=False):
|
560 |
-
with gr.Row():
|
561 |
-
#global cache_image
|
562 |
-
#global cache_image_actu
|
563 |
-
id_session=gr.Number(visible=False,value=0)
|
564 |
-
gen_button.click(set_session, id_session, id_session)
|
565 |
-
cache_image[f"{id_session.value}"]=[]
|
566 |
-
cache_image_actu[f"{id_session.value}"]=[]
|
567 |
-
with gr.Column():
|
568 |
-
b11 = gr.Button('Load Galerry Actu')
|
569 |
-
b12 = gr.Button('Load Galerry All')
|
570 |
-
b13 = gr.Button('Load Galerry All (sorted)')
|
571 |
-
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
572 |
-
interactive=False, show_share_button=True, container=True, format="png",
|
573 |
-
preview=True, object_fit="cover",columns=4,rows=4)
|
574 |
-
with gr.Column():
|
575 |
-
b21 = gr.Button('Reset Gallery')
|
576 |
-
b22 = gr.Button('Reset Gallery All')
|
577 |
-
b23 = gr.Button('Reset All Sessions')
|
578 |
-
b24 = gr.Button('print info sessions')
|
579 |
-
b11.click(load_gallery_actu,[gallery,id_session],gallery)
|
580 |
-
b12.click(load_gallery,[gallery,id_session],gallery)
|
581 |
-
b13.click(load_gallery_sorted,[gallery,id_session],gallery)
|
582 |
-
b21.click(reset_gallery,[gallery],gallery)
|
583 |
-
b22.click(reset_cache_image,[id_session],gallery)
|
584 |
-
b23.click(reset_cache_image_all_sessions,[],[])
|
585 |
-
b24.click(print_info_sessions,[],[])
|
586 |
-
for m, o in zip(current_models, output):
|
587 |
-
#o.change(add_gallery, [o, m, gallery], [gallery])
|
588 |
-
o.change(add_cache_image,[o,m,id_session],[])
|
589 |
-
o.change(add_cache_image_actu,[o,m,id_session],[])
|
590 |
-
gen_button.click(reset_cache_image_actu, [id_session], [])
|
591 |
-
gen_button.click(lambda id:gr.Button('Load Galerry All ('+str(len(cache_image[f"{id}"]))+")"), [id_session], [b12])
|
592 |
-
|
593 |
-
with gr.Group():
|
594 |
-
with gr.Row():
|
595 |
-
#group_tag_choice = gr.Dropdown(label="Lists Tags", show_label=True, choices=list([]) , interactive = True)
|
596 |
-
group_tag_choice = gr.Dropdown(label="Lists Tags", show_label=True, choices=list(models_test), interactive = True,value=models_test[0][1])
|
597 |
-
#group_tag_choice = gr.Dropdown(label="Lists Tags", show_label=True, choices=list(models_test), interactive = True)
|
598 |
-
index_tag=gr.Number(0,visible=False)
|
599 |
-
|
600 |
-
with gr.Row():
|
601 |
-
group_model_choice = gr.Dropdown(label="List of Models with the chosen Tag", show_label=True, choices=list([]), interactive = True)
|
602 |
-
group_model_choice.change(choice_group_b,group_model_choice,output)
|
603 |
-
group_model_choice.change(choice_group_c,group_model_choice,current_models)
|
604 |
-
#group_model_choice.change(choice_group_d,group_model_choice,text_disp_models)
|
605 |
-
group_model_choice.change(choice_group_e,group_model_choice,block_images_liste)
|
606 |
-
group_tag_choice.change(tag_choice,group_tag_choice,group_model_choice)
|
607 |
-
group_tag_choice.change(find_index_tag,group_tag_choice,index_tag)
|
608 |
-
|
609 |
-
with gr.Accordion("Display/Load Models") :
|
610 |
-
with gr.Row():
|
611 |
-
txt_list_models=gr.Textbox(label="Models Actu",value="")
|
612 |
-
group_model_choice.change(disp_models,group_model_choice,txt_list_models)
|
613 |
-
|
614 |
-
with gr.Column():
|
615 |
-
txt_list_perso = gr.Textbox(label='List Models Perso to Load')
|
616 |
-
|
617 |
-
button_list_perso = gr.Button('Load')
|
618 |
-
button_list_perso.click(aff_models_perso_b,txt_list_perso,output)
|
619 |
-
button_list_perso.click(aff_models_perso_c,txt_list_perso,current_models)
|
620 |
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
with gr.Row():
|
628 |
-
txt_search_info = gr.Textbox(label='Search info in')
|
629 |
-
txt_output_search_info = gr.Textbox(label='Search info out')
|
630 |
-
button_search_info = gr.Button('Research info')
|
631 |
-
button_search_info.click(search_info,txt_search_info,txt_output_search_info)
|
632 |
-
|
633 |
-
|
634 |
-
with gr.Row():
|
635 |
-
test_button.click(test_pass_aff,txt_input_p,[stuffs,blockPass])
|
636 |
-
#test_button.click(test_pass,txt_input_p,group_tag_choice)
|
637 |
-
|
638 |
-
#text_disp_models = []
|
639 |
-
#button_rand_from_tag=[]
|
640 |
-
#button_rand_from_all=[]
|
641 |
-
button_rand_from_all_all_models.click(rand_from_all_all_models,[],current_models)
|
642 |
-
button_rand_from_tag_all_models.click(rand_from_tag_all_models,index_tag,current_models)
|
643 |
-
for i in range(nb_mod_dif):
|
644 |
-
#######################################################################################################################
|
645 |
-
#button_rand_from_tag.click()
|
646 |
-
#button_rand_from_all.click()
|
647 |
-
#button_rand_from_fav.click()
|
648 |
-
button_blacklisted[i].click(add_in_blacklist,[blacklist_perso,current_models[i*nb_rep]],blacklist_perso)
|
649 |
-
button_favorites[i].click(add_in_fav,[fav_perso,current_models[i*nb_rep]],fav_perso)
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
gr.HTML("""
|
654 |
-
<div class="footer">
|
655 |
-
<p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77 and Omnibus's Maximum Multiplier!
|
656 |
-
</p>
|
657 |
-
""")
|
658 |
|
659 |
js_code = """
|
660 |
|
|
|
25 |
cache_image={}
|
26 |
cache_image_actu={}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def load_fn(models):
|
30 |
global models_load
|
|
|
50 |
models_load.update({model: m})
|
51 |
|
52 |
|
|
|
|
|
53 |
load_fn(models)
|
|
|
|
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
def test_pass(test):
|
56 |
if test==os.getenv('p'):
|
57 |
print("ok")
|
|
|
115 |
loop.close()
|
116 |
return result
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
def add_gallery(image, model_str, gallery):
|
120 |
if gallery is None: gallery = []
|
|
|
229 |
outputList.append("Model Not Find")
|
230 |
return gr.Textbox(label="out",value=outputList)
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
def ratio_chosen(choice_ratio,width,height):
|
234 |
if choice_ratio == [None,None]:
|
|
|
250 |
["1:4 (512 x 2048)",[512,2048]]]
|
251 |
|
252 |
def make_me():
|
|
|
253 |
with gr.Row():
|
|
|
|
|
254 |
with gr.Column(scale=4):
|
255 |
with gr.Group():
|
256 |
txt_input = gr.Textbox(label='Your prompt:', lines=3)
|
|
|
268 |
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
269 |
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
270 |
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
|
|
|
|
271 |
gen_button = gr.Button('Generate images', scale=3)
|
272 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False, scale=1)
|
|
|
273 |
gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
+
list_param_actu=[txt_input,neg_input,width,height,steps,cfg,seed]
|
276 |
+
examples=[["prompt","neg p",1024,800,50,3.0],["prompt 2","neg p 2",720,1200,30,2.5]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
+
examples_gradio = gr.Examples(
|
279 |
+
examples=examples,
|
280 |
+
inputs=[txt_input,neg_input,width,height,steps,cfg,seed],
|
281 |
+
outputs=[txt_input,neg_input,width,height,steps,cfg,seed],
|
282 |
+
cache_examples="lazy"
|
283 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
js_code = """
|
286 |
|