Yaron Koresh commited on
Commit
86f936d
·
verified ·
1 Parent(s): 1a244c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -166,6 +166,7 @@ def infer1(p):
166
  output = Piper1(posi)
167
  output.images[0].save(name)
168
  return name
 
169
  def infer2(p):
170
  print("infer2: started")
171
  p1 = p["a"]
@@ -181,7 +182,7 @@ def infer2(p):
181
  output2.images[0].save("_"+name)
182
  return "_"+name
183
 
184
- def run(p1,p2,*result):
185
  p1_en = translate(p1,"english")
186
  p2_en = translate(p2,"english")
187
  p = {"a":p1_en,"b":p2_en}
@@ -195,6 +196,16 @@ def run(p1,p2,*result):
195
  pool1.close()
196
  pool1.join()
197
  pool1.clear()
 
 
 
 
 
 
 
 
 
 
198
 
199
  arr2 = [{"a":p1_en,"b":p2_en,"c":out1[_]} for _ in rng]
200
  pool2 = Pool(ln)
@@ -242,7 +253,7 @@ def main():
242
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
243
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
244
 
245
- run_button.click(fn=run,inputs=[prompt,prompt2,*result],outputs=result)
246
  demo.queue().launch()
247
 
248
  if __name__ == "__main__":
 
166
  output = Piper1(posi)
167
  output.images[0].save(name)
168
  return name
169
+
170
  def infer2(p):
171
  print("infer2: started")
172
  p1 = p["a"]
 
182
  output2.images[0].save("_"+name)
183
  return "_"+name
184
 
185
+ def run1(p1,p2,*result):
186
  p1_en = translate(p1,"english")
187
  p2_en = translate(p2,"english")
188
  p = {"a":p1_en,"b":p2_en}
 
196
  pool1.close()
197
  pool1.join()
198
  pool1.clear()
199
+
200
+ return out1
201
+
202
+ def run2(p1,p2,*result):
203
+ p1_en = translate(p1,"english")
204
+ p2_en = translate(p2,"english")
205
+ p = {"a":p1_en,"b":p2_en}
206
+ ln = len(result)
207
+ print("images: "+str(ln))
208
+ rng = list(range(ln))
209
 
210
  arr2 = [{"a":p1_en,"b":p2_en,"c":out1[_]} for _ in rng]
211
  pool2 = Pool(ln)
 
253
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
254
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
255
 
256
+ run_button.click(fn=run1,inputs=[prompt,prompt2,*result],outputs=result).then(fn=run2,inputs=[prompt,prompt2,*result],outputs=result)
257
  demo.queue().launch()
258
 
259
  if __name__ == "__main__":