Pamudu13 commited on
Commit
d4423e5
·
verified ·
1 Parent(s): 5264a22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -1,9 +1,22 @@
1
  import gradio as gr
 
 
 
2
  import time
3
 
4
- models = [
5
- "Yntec/ChickFlick"
 
 
 
 
 
 
 
 
 
6
  ]
 
7
 
8
  model_functions = {}
9
  model_idx = 1
@@ -12,8 +25,9 @@ for model_path in models:
12
  model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
13
  except Exception as error:
14
  def the_fn(txt):
15
- return None, None, None
16
- model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image", "image", "image"])
 
17
 
18
  model_idx+=1
19
 
@@ -62,15 +76,19 @@ def all_task_start():
62
 
63
  def clear_fn():
64
  nn = len(models)
65
- return tuple([None, *[None for _ in range(nn*3)]])
66
 
67
 
68
  with gr.Blocks(title="SD Models") as my_interface:
69
  with gr.Column(scale=12):
 
 
70
  with gr.Row():
71
  with gr.Row(scale=6):
72
  primary_prompt=gr.Textbox(label="Prompt", value="")
 
73
  with gr.Row(scale=6):
 
74
  with gr.Row():
75
  run=gr.Button("Run",variant="primary")
76
  clear_btn=gr.Button("Clear")
@@ -80,7 +98,7 @@ with gr.Blocks(title="SD Models") as my_interface:
80
  for model_path in models:
81
  with gr.Column(scale=3, min_width=320):
82
  with gr.Box():
83
- sd_outputs[model_idx] = [gr.Image(label=model_path), gr.Image(label=model_path), gr.Image(label=model_path)]
84
  pass
85
  model_idx += 1
86
  pass
@@ -103,15 +121,20 @@ with gr.Blocks(title="SD Models") as my_interface:
103
  runs_dict = {}
104
  model_idx = 1
105
  for model_path in models:
106
- runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=sd_outputs[model_idx])
107
  model_idx += 1
108
  pass
109
  pass
110
 
 
 
 
 
 
111
  clear_btn.click(
112
  clear_fn,
113
  None,
114
- [primary_prompt, *[image for images in sd_outputs.values() for image in images]],
115
  cancels=[*list(runs_dict.values())])
116
  tog_box.change(
117
  clear_it,
 
1
  import gradio as gr
2
+ # import os
3
+ # import sys
4
+ # from pathlib import Path
5
  import time
6
 
7
+ models =[
8
+ "mann-e/Mann-E_Dreams",
9
+ "Yntec/ChickFlick",
10
+ "John6666/ultimate-realistic-mix-v2-sdxl",
11
+ "Yntec/CrystalReality",
12
+ "John6666/9527-detail-realistic-xl-v55mix-sdxl",
13
+ "John6666/epicrealism-xl-v8kiss-sdxl",
14
+ "John6666/wai-real-mix-v8-sdxl",
15
+ "John6666/real-vis-xl-v40-sdxl",
16
+ "Yntec/DegreesOfFreedom",
17
+
18
  ]
19
+
20
 
21
  model_functions = {}
22
  model_idx = 1
 
25
  model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
26
  except Exception as error:
27
  def the_fn(txt):
28
+
29
+ return None
30
+ model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
31
 
32
  model_idx+=1
33
 
 
76
 
77
  def clear_fn():
78
  nn = len(models)
79
+ return tuple([None, *[None for _ in range(nn)]])
80
 
81
 
82
  with gr.Blocks(title="SD Models") as my_interface:
83
  with gr.Column(scale=12):
84
+ # with gr.Row():
85
+ # gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
86
  with gr.Row():
87
  with gr.Row(scale=6):
88
  primary_prompt=gr.Textbox(label="Prompt", value="")
89
+ # real_prompt=gr.Textbox(label="Real prompt")
90
  with gr.Row(scale=6):
91
+ # improve_prompts_btn=gr.Button("Improve")
92
  with gr.Row():
93
  run=gr.Button("Run",variant="primary")
94
  clear_btn=gr.Button("Clear")
 
98
  for model_path in models:
99
  with gr.Column(scale=3, min_width=320):
100
  with gr.Box():
101
+ sd_outputs[model_idx] = gr.Image(label=model_path)
102
  pass
103
  model_idx += 1
104
  pass
 
121
  runs_dict = {}
122
  model_idx = 1
123
  for model_path in models:
124
+ runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
125
  model_idx += 1
126
  pass
127
  pass
128
 
129
+ # improve_prompts_btn_clicked=improve_prompts_btn.click(
130
+ # get_prompts,
131
+ # inputs=[primary_prompt],
132
+ # outputs=[primary_prompt],
133
+ # cancels=list(runs_dict.values()))
134
  clear_btn.click(
135
  clear_fn,
136
  None,
137
+ [primary_prompt, *list(sd_outputs.values())],
138
  cancels=[*list(runs_dict.values())])
139
  tog_box.change(
140
  clear_it,