Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -48,9 +48,6 @@ def pipe_i2i():
|
|
48 |
PIPE.unet = torch.compile(PIPE.unet, mode="reduce-overhead", fullgraph=True)
|
49 |
return PIPE
|
50 |
|
51 |
-
pp1=pipe_t2i()
|
52 |
-
pp2=pipe_i2i()
|
53 |
-
|
54 |
def translate(text,lang):
|
55 |
if text == None or lang == None:
|
56 |
return ""
|
@@ -131,18 +128,6 @@ def tok(txt):
|
|
131 |
print(toks)
|
132 |
return toks
|
133 |
|
134 |
-
def main(p1,p2,*result):
|
135 |
-
p1_en = translate(p1,"english")
|
136 |
-
p2_en = translate(p2,"english")
|
137 |
-
p = {"a":p1_en,"b":p2_en}
|
138 |
-
ln = len(result)
|
139 |
-
rng = list(range(ln))
|
140 |
-
arr = [p for _ in rng]
|
141 |
-
out = None
|
142 |
-
with Pool(ln, initializer=init_pool, initargs=(pp1,pp2)) as pool:
|
143 |
-
out = pool.imap(infer,arr)
|
144 |
-
return list(out)
|
145 |
-
|
146 |
def infer(p):
|
147 |
p1 = p["a"]
|
148 |
p2 = p["b"]
|
@@ -209,8 +194,27 @@ function custom(){
|
|
209 |
}
|
210 |
"""
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
213 |
result = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
215 |
with gr.Column(elem_id="col-container"):
|
216 |
gr.Markdown(f"""
|
@@ -237,9 +241,4 @@ def ui():
|
|
237 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
238 |
|
239 |
run_button.click(fn=main,inputs=[prompt,prompt2,*result],outputs=result)
|
240 |
-
demo.queue().launch(server_port=int(os.getenv("CUSTOM_PORT")))
|
241 |
-
|
242 |
-
if __name__ == "__main__":
|
243 |
-
port_inc()
|
244 |
-
mp.set_start_method("spawn", force=True)
|
245 |
-
ui()
|
|
|
48 |
PIPE.unet = torch.compile(PIPE.unet, mode="reduce-overhead", fullgraph=True)
|
49 |
return PIPE
|
50 |
|
|
|
|
|
|
|
51 |
def translate(text,lang):
|
52 |
if text == None or lang == None:
|
53 |
return ""
|
|
|
128 |
print(toks)
|
129 |
return toks
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
def infer(p):
|
132 |
p1 = p["a"]
|
133 |
p2 = p["b"]
|
|
|
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}
|
208 |
+
ln = len(result)
|
209 |
+
rng = list(range(ln))
|
210 |
+
arr = [p for _ in rng]
|
211 |
+
out = None
|
212 |
+
with Pool(ln, initializer=init_pool, initargs=(pp1,pp2)) as pool:
|
213 |
+
out = pool.imap(infer,arr)
|
214 |
+
return list(out)
|
215 |
+
port_inc()
|
216 |
+
mp.set_start_method("spawn", force=True)
|
217 |
+
|
218 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
219 |
with gr.Column(elem_id="col-container"):
|
220 |
gr.Markdown(f"""
|
|
|
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")))
|
|
|
|
|
|
|
|
|
|