Spaces:
Build error
Build error
hugforziio
commited on
Commit
•
ba36264
1
Parent(s):
864da09
Update app.py
Browse files
app.py
CHANGED
@@ -28,16 +28,21 @@ models =[
|
|
28 |
]
|
29 |
|
30 |
|
31 |
-
|
32 |
model_idx = 1
|
33 |
for model_path in models:
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
model_idx+=1
|
36 |
|
37 |
|
38 |
def send_it_idx(idx):
|
39 |
def send_it_fn(prompt):
|
40 |
-
output = (
|
41 |
return output
|
42 |
return send_it_fn
|
43 |
|
@@ -82,7 +87,7 @@ def clear_fn():
|
|
82 |
|
83 |
|
84 |
|
85 |
-
with gr.Blocks() as my_interface:
|
86 |
with gr.Column(scale=12):
|
87 |
# with gr.Row():
|
88 |
# gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
|
@@ -123,7 +128,7 @@ with gr.Blocks() as my_interface:
|
|
123 |
runs_dict = {}
|
124 |
model_idx = 1
|
125 |
for model_path in models:
|
126 |
-
runs_dict[model_idx] = run.click(
|
127 |
model_idx += 1
|
128 |
pass
|
129 |
pass
|
|
|
28 |
]
|
29 |
|
30 |
|
31 |
+
model_functions = {}
|
32 |
model_idx = 1
|
33 |
for model_path in models:
|
34 |
+
try:
|
35 |
+
model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
|
36 |
+
except Exception as error:
|
37 |
+
def the_fn(txt):
|
38 |
+
return None
|
39 |
+
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
40 |
model_idx+=1
|
41 |
|
42 |
|
43 |
def send_it_idx(idx):
|
44 |
def send_it_fn(prompt):
|
45 |
+
output = (model_functions.get(str(idx)) or model_functions.get(str(1)))(prompt)
|
46 |
return output
|
47 |
return send_it_fn
|
48 |
|
|
|
87 |
|
88 |
|
89 |
|
90 |
+
with gr.Blocks(title="SD Models") as my_interface:
|
91 |
with gr.Column(scale=12):
|
92 |
# with gr.Row():
|
93 |
# gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
|
|
|
128 |
runs_dict = {}
|
129 |
model_idx = 1
|
130 |
for model_path in models:
|
131 |
+
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
132 |
model_idx += 1
|
133 |
pass
|
134 |
pass
|