DemiPoto commited on
Commit
b3bcfcb
·
verified ·
1 Parent(s): b3d45b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -5
app.py CHANGED
@@ -280,9 +280,51 @@ def fonc_load_info(nb_of_models_to_gen,index_tag,index_first_model):
280
  str_temp+=f"{index_first_model+1}/{len(tags_plus_models[index_tag][2])} to {index_first_model+nb_of_models_to_gen}/{len(tags_plus_models[index_tag][2])}) :\n\n"
281
  for i in range(nb_of_models_to_gen):
282
  list_models_temp.append(tags_plus_models[index_tag][2][i+index_first_model])
283
- str_temp+=f"{tags_plus_models[index_tag][2][i+index_first_model]}\n"
284
-
285
  return nb_of_models_to_gen,gr.Textbox(str_temp),gr.Dropdown(choices=[["",list_models_temp]], value=list_models_temp )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  def make_me():
288
  with gr.Column():
@@ -326,15 +368,30 @@ def make_me():
326
  nb_images_by_prompt=gr.Number(2,label="Number of images by prompt:",interactive=True)
327
  nb_of_models_to_gen=gr.Number(10,label="Number of Models:",interactive=True)
328
  index_tag=gr.Dropdown(label="Tag",choices=list(list_tags),type="index")
329
- index_first_model=gr.Dropdown(label="First model",choices=list(tags_plus_models[1][2]), type="index")
330
- #index_tag.change(lambda i:gr.Dropdown(choices=list(tags_plus_models[i][2])),index_tag,index_first_model)
331
  index_tag.change(lambda i:gr.Dropdown(choices=list([f"({j+1}/{len(tags_plus_models[i][2])}) {tags_plus_models[i][2][j]}" for j in range(len(tags_plus_models[i][2]))])),
332
  index_tag,index_first_model)
333
  with gr.Row():
334
  list_models_to_gen=gr.Dropdown(choices=[["",[]]], value=[], visible=False)
335
  disp_info=gr.Textbox(label="Info")
336
- load_info=gr.Button("Load info")
337
  load_info.click(fonc_load_info,[nb_of_models_to_gen,index_tag,index_first_model],[nb_of_models_to_gen,disp_info,list_models_to_gen])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
 
339
  js_code = """
340
 
 
280
  str_temp+=f"{index_first_model+1}/{len(tags_plus_models[index_tag][2])} to {index_first_model+nb_of_models_to_gen}/{len(tags_plus_models[index_tag][2])}) :\n\n"
281
  for i in range(nb_of_models_to_gen):
282
  list_models_temp.append(tags_plus_models[index_tag][2][i+index_first_model])
283
+ str_temp+=f"\"{tags_plus_models[index_tag][2][i+index_first_model]}\",\n"
 
284
  return nb_of_models_to_gen,gr.Textbox(str_temp),gr.Dropdown(choices=[["",list_models_temp]], value=list_models_temp )
285
+ def fonc_load_info_custom(nb_of_models_to_gen,list_model_custom,index_first_model):
286
+ str_temp=""
287
+ list_models_temp=[]
288
+ if index_first_model+nb_of_models_to_gen>len(list_model_custom):
289
+ if nb_of_models_to_gen>len(list_model_custom):
290
+ str_temp+="warning : to many model chosen"
291
+ else:
292
+ str_temp+="warning : first model to close to the last model"
293
+ nb_of_models_to_gen= len(list_model_custom)-index_first_model
294
+ str_temp+=f" - only {nb_of_models_to_gen} will be use\n\n"
295
+ str_temp+="list of models use (from "
296
+ str_temp+=f"{index_first_model+1}/{len(list_model_custom)} to {index_first_model+nb_of_models_to_gen}/{len(list_model_custom)}) :\n\n"
297
+ for i in range(nb_of_models_to_gen):
298
+ list_models_temp.append(list_model_custom[i+index_first_model])
299
+ str_temp+=f"\"{list_model_custom[i+index_first_model]}\",\n"
300
+ return nb_of_models_to_gen,gr.Textbox(str_temp),gr.Dropdown(choices=[["",list_models_temp]], value=list_models_temp )
301
+
302
+
303
+
304
+
305
+ def cutStrg(longStrg,start,end):
306
+ shortStrg=''
307
+ for i in range(end-start):
308
+ shortStrg+=longStrg[start+i]
309
+ return shortStrg
310
+ def aff_models_perso(txt_list_perso,models=models):
311
+ list_perso=[]
312
+ t1=True
313
+ start=txt_list_perso.find('\"')
314
+ if start!=-1:
315
+ while t1:
316
+ start+=1
317
+ end=txt_list_perso.find('\"',start)
318
+ if end != -1:
319
+ txtTemp=cutStrg(txt_list_perso,start,end)
320
+ if txtTemp in models:
321
+ list_perso.append(cutStrg(txt_list_perso,start,end))
322
+ else :
323
+ t1=False
324
+ start=txt_list_perso.find('\"',end+1)
325
+ if start==-1:
326
+ t1=False
327
+ return gr.Dropdown(choices=[["",list_perso]], value=list_perso )
328
 
329
  def make_me():
330
  with gr.Column():
 
368
  nb_images_by_prompt=gr.Number(2,label="Number of images by prompt:",interactive=True)
369
  nb_of_models_to_gen=gr.Number(10,label="Number of Models:",interactive=True)
370
  index_tag=gr.Dropdown(label="Tag",choices=list(list_tags),type="index")
371
+ index_first_model=gr.Dropdown(label="First model",choices=list([]), type="index")
 
372
  index_tag.change(lambda i:gr.Dropdown(choices=list([f"({j+1}/{len(tags_plus_models[i][2])}) {tags_plus_models[i][2][j]}" for j in range(len(tags_plus_models[i][2]))])),
373
  index_tag,index_first_model)
374
  with gr.Row():
375
  list_models_to_gen=gr.Dropdown(choices=[["",[]]], value=[], visible=False)
376
  disp_info=gr.Textbox(label="Info")
377
+ load_info=gr.Button("Load Models")
378
  load_info.click(fonc_load_info,[nb_of_models_to_gen,index_tag,index_first_model],[nb_of_models_to_gen,disp_info,list_models_to_gen])
379
+
380
+ with gr.Accordion("Display/Load Models",show=False) :
381
+ with gr.Row():
382
+ text_list_model_custom=gr.Textbox(label="List Models Custom")
383
+ with gr.Column():
384
+ list_model_custom=gr.Dropdown(choices=[["",[]]], value=[], visible=False)
385
+ #use_models_custom=gr.Radio("Use Models Custom",value=False)
386
+ cut_model_custom=gr.Button("Cut Text Models Custom")
387
+ cut_model_custom.click(aff_models_perso,[text_list_model_custom],[list_model_custom])
388
+
389
+ index_first_model_custom=gr.Dropdown(label="First model",choices=list([]), type="index")
390
+ list_model_custom.change(lambda li:gr.Dropdown(choices=list([f"({j+1}/{len(li)}) {li[j]}" for j in range(len(li))])),
391
+ [list_model_custom],index_first_model_custom)
392
+
393
+ load_model_custom=gr.Button("Load Text Models Custom")
394
+ load_model_custom.click(fonc_load_info_custom,[nb_of_models_to_gen,list_model_custom,index_first_model_custom],[nb_of_models_to_gen,disp_info,list_models_to_gen])
395
 
396
  js_code = """
397