Yaron Koresh commited on
Commit
f285313
verified
1 Parent(s): 905e20c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -10,10 +10,7 @@ import numpy as np
10
  from lxml.html import fromstring
11
  from diffusers import AutoPipelineForText2Image
12
  #from tempfile import NamedTemporaryFile
13
- #from pathos.multiprocessing import ProcessingPool as ProcessPoolExecutor
14
-
15
- #pool = ProcessPoolExecutor(1000)
16
- #pool.__enter__()
17
 
18
  #model_id = "runwayml/stable-diffusion-v1-5"
19
  #model_id = "kandinsky-community/kandinsky-3"
@@ -93,8 +90,8 @@ def Piper(_do,_dont):
93
  height=320,
94
  width=576,
95
  negative_prompt=_dont,
96
- num_inference_steps=100,
97
- guidance_scale=10
98
  )
99
 
100
  def infer(prompt,prompt2):
@@ -132,7 +129,7 @@ footer {
132
  margin: 0 auto !important;
133
  max-width: 15cm !important;
134
  }
135
- #image-container {
136
  aspect-ratio: 576 / 320 !important;
137
  }
138
  .dropdown-arrow {
@@ -175,21 +172,23 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
175
  )
176
  with gr.Row():
177
  run_button = gr.Button("讛转讞诇讛")
178
- result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
179
- prompt.submit(
180
- fn = infer,
181
- inputs = [prompt,prompt2],
182
- outputs = [result]
183
- )
184
- prompt2.submit(
185
- fn = infer,
186
- inputs = [prompt,prompt2],
187
- outputs = [result]
188
- )
189
- run_button.click(
190
- fn = infer,
191
- inputs = [prompt,prompt2],
192
- outputs = [result]
193
- )
 
 
194
 
195
  demo.queue().launch()
 
10
  from lxml.html import fromstring
11
  from diffusers import AutoPipelineForText2Image
12
  #from tempfile import NamedTemporaryFile
13
+ from pathos.multiprocessing import Pool
 
 
 
14
 
15
  #model_id = "runwayml/stable-diffusion-v1-5"
16
  #model_id = "kandinsky-community/kandinsky-3"
 
90
  height=320,
91
  width=576,
92
  negative_prompt=_dont,
93
+ num_inference_steps=50,
94
+ guidance_scale=2
95
  )
96
 
97
  def infer(prompt,prompt2):
 
129
  margin: 0 auto !important;
130
  max-width: 15cm !important;
131
  }
132
+ .image-container {
133
  aspect-ratio: 576 / 320 !important;
134
  }
135
  .dropdown-arrow {
 
172
  )
173
  with gr.Row():
174
  run_button = gr.Button("讛转讞诇讛")
175
+ with gr.Row():
176
+ result[0] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
177
+ result[1] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
178
+ result[2] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
179
+ with gr.Row():
180
+ result[3] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
181
+ result[4] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
182
+ result[5] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
183
+ with gr.Row():
184
+ result[6] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
185
+ result[7] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
186
+ result[8] = gr.Image(elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False)
187
+
188
+ def ret(idx):
189
+ result[idx] = infer(prompt,prompt2)
190
+ def rets():
191
+ Pool().map(ret,[range(9)])
192
+ run_button.click(rets)
193
 
194
  demo.queue().launch()