Yaron Koresh commited on
Commit
51883a2
·
verified ·
1 Parent(s): cb17486

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -8,7 +8,7 @@ import requests
8
  import gradio as gr
9
  import numpy as np
10
  from lxml.html import fromstring
11
- from transformers import pipeline
12
  from torch import multiprocessing as mp
13
  #from pathos.multiprocessing import ProcessPool as Pool
14
  from pathos.threading import ThreadPool as Pool
@@ -123,7 +123,7 @@ def Piper2(pipe,img,posi,neg):
123
  return None
124
 
125
  @spaces.GPU(duration=55)
126
- def tok(txt):
127
  toks = pipe.tokenizer(txt)['input_ids']
128
  print(toks)
129
  return toks
@@ -194,14 +194,14 @@ function custom(){
194
  }
195
  """
196
 
197
- if __name__ == "__main__":
198
-
199
  pp1=pipe_t2i()
200
  pp2=pipe_i2i()
201
 
202
  result = []
203
 
204
- def main(p1,p2,*result):
205
  p1_en = translate(p1,"english")
206
  p2_en = translate(p2,"english")
207
  p = {"a":p1_en,"b":p2_en}
@@ -240,5 +240,8 @@ if __name__ == "__main__":
240
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
241
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
242
 
243
- run_button.click(fn=main,inputs=[prompt,prompt2,*result],outputs=result)
244
- demo.queue().launch(server_port=int(os.getenv("CUSTOM_PORT")))
 
 
 
 
8
  import gradio as gr
9
  import numpy as np
10
  from lxml.html import fromstring
11
+ #from transformers import pipeline
12
  from torch import multiprocessing as mp
13
  #from pathos.multiprocessing import ProcessPool as Pool
14
  from pathos.threading import ThreadPool as Pool
 
123
  return None
124
 
125
  @spaces.GPU(duration=55)
126
+ def tok(pipe,txt):
127
  toks = pipe.tokenizer(txt)['input_ids']
128
  print(toks)
129
  return toks
 
194
  }
195
  """
196
 
197
+ def main():
198
+
199
  pp1=pipe_t2i()
200
  pp2=pipe_i2i()
201
 
202
  result = []
203
 
204
+ def run(p1,p2,*result):
205
  p1_en = translate(p1,"english")
206
  p2_en = translate(p2,"english")
207
  p = {"a":p1_en,"b":p2_en}
 
240
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
241
  result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
242
 
243
+ run_button.click(fn=run,inputs=[prompt,prompt2,*result],outputs=result)
244
+ demo.queue().launch(server_port=int(os.getenv("CUSTOM_PORT")))
245
+
246
+ if __name__ == "__main__":
247
+ main()