Yaron Koresh commited on
Commit
019b2bc
·
verified ·
1 Parent(s): 63a98a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -190,17 +190,15 @@ with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
190
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
191
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
192
 
193
- def _ret(idx):
194
- p1 = prompt.value
195
- p2 = prompt2.value
196
- print(f'Starting {idx}: {result[idx]} {p1} {p2}')
197
  v = infer(p1,p2)
198
  print(f'Finished {idx}: {v}')
199
- result[idx].value=v
200
- def _rets():
201
  ln = len(result)
202
- idxs = list(range(ln))
203
- Pool(ln).imap( _ret, idxs )
204
- run_button.click(fn=_rets)
205
 
206
  demo.queue().launch()
 
190
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
191
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
192
 
193
+ def _ret(idx,p1,p2):
194
+ print(f'Starting {idx}: {p1} {p2}')
 
 
195
  v = infer(p1,p2)
196
  print(f'Finished {idx}: {v}')
197
+ return v
198
+ def _rets(p1,p2):
199
  ln = len(result)
200
+ idxs = [ [idx,p1,p2] for idx in list(range(ln)) ]
201
+ return Pool(ln).imap( _ret, idxs ).get()
202
+ run_button.click(fn=_rets,inputs=[prompt,prompt2],outputs=result)
203
 
204
  demo.queue().launch()