Pamudu13 commited on
Commit
ca311ea
·
verified ·
1 Parent(s): 7bdcbc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -24
app.py CHANGED
@@ -1,16 +1,9 @@
1
  import gradio as gr
2
- # import os
3
- # import sys
4
- # from pathlib import Path
5
  import time
6
 
7
- models =[
8
-
9
  "John6666/ultimate-realistic-mix-v2-sdxl"
10
-
11
-
12
  ]
13
-
14
 
15
  model_functions = {}
16
  model_idx = 1
@@ -19,9 +12,8 @@ for model_path in models:
19
  model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
20
  except Exception as error:
21
  def the_fn(txt):
22
-
23
- return None
24
- model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
25
 
26
  model_idx+=1
27
 
@@ -70,19 +62,15 @@ def all_task_start():
70
 
71
  def clear_fn():
72
  nn = len(models)
73
- return tuple([None, *[None for _ in range(nn)]])
74
 
75
 
76
  with gr.Blocks(title="SD Models") as my_interface:
77
  with gr.Column(scale=12):
78
- # with gr.Row():
79
- # gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
80
  with gr.Row():
81
  with gr.Row(scale=6):
82
  primary_prompt=gr.Textbox(label="Prompt", value="")
83
- # real_prompt=gr.Textbox(label="Real prompt")
84
  with gr.Row(scale=6):
85
- # improve_prompts_btn=gr.Button("Improve")
86
  with gr.Row():
87
  run=gr.Button("Run",variant="primary")
88
  clear_btn=gr.Button("Clear")
@@ -92,7 +80,7 @@ with gr.Blocks(title="SD Models") as my_interface:
92
  for model_path in models:
93
  with gr.Column(scale=3, min_width=320):
94
  with gr.Box():
95
- sd_outputs[model_idx] = gr.Image(label=model_path)
96
  pass
97
  model_idx += 1
98
  pass
@@ -115,20 +103,15 @@ with gr.Blocks(title="SD Models") as my_interface:
115
  runs_dict = {}
116
  model_idx = 1
117
  for model_path in models:
118
- runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
119
  model_idx += 1
120
  pass
121
  pass
122
 
123
- # improve_prompts_btn_clicked=improve_prompts_btn.click(
124
- # get_prompts,
125
- # inputs=[primary_prompt],
126
- # outputs=[primary_prompt],
127
- # cancels=list(runs_dict.values()))
128
  clear_btn.click(
129
  clear_fn,
130
  None,
131
- [primary_prompt, *list(sd_outputs.values())],
132
  cancels=[*list(runs_dict.values())])
133
  tog_box.change(
134
  clear_it,
 
1
  import gradio as gr
 
 
 
2
  import time
3
 
4
+ models = [
 
5
  "John6666/ultimate-realistic-mix-v2-sdxl"
 
 
6
  ]
 
7
 
8
  model_functions = {}
9
  model_idx = 1
 
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
 
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
  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
  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,