Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -160,14 +160,7 @@ function custom(){
|
|
| 160 |
}
|
| 161 |
"""
|
| 162 |
|
| 163 |
-
def
|
| 164 |
-
|
| 165 |
-
pp1=pipe_t2i()
|
| 166 |
-
pp2=pipe_i2i()
|
| 167 |
-
|
| 168 |
-
result = []
|
| 169 |
-
|
| 170 |
-
def infer(p):
|
| 171 |
p1 = p["a"]
|
| 172 |
p2 = p["b"]
|
| 173 |
name = generate_random_string(12)+".png"
|
|
@@ -193,8 +186,8 @@ def main():
|
|
| 193 |
else:
|
| 194 |
output2.images[0].save("_"+name)
|
| 195 |
return "_"+name
|
| 196 |
-
|
| 197 |
-
|
| 198 |
p1_en = translate(p1,"english")
|
| 199 |
p2_en = translate(p2,"english")
|
| 200 |
p = {"a":p1_en,"b":p2_en}
|
|
@@ -205,10 +198,8 @@ def main():
|
|
| 205 |
with Pool(ln, initializer=init_pool) as pool:
|
| 206 |
out = pool.imap(infer,arr)
|
| 207 |
return list(out)
|
| 208 |
-
port_inc()
|
| 209 |
-
|
| 210 |
-
mp.set_start_method("fork", force=True)
|
| 211 |
|
|
|
|
| 212 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
| 213 |
with gr.Column(elem_id="col-container"):
|
| 214 |
gr.Markdown(f"""
|
|
@@ -238,4 +229,16 @@ def main():
|
|
| 238 |
demo.queue().launch(server_port=int(os.getenv("CUSTOM_PORT")))
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
}
|
| 161 |
"""
|
| 162 |
|
| 163 |
+
def infer(p):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
p1 = p["a"]
|
| 165 |
p2 = p["b"]
|
| 166 |
name = generate_random_string(12)+".png"
|
|
|
|
| 186 |
else:
|
| 187 |
output2.images[0].save("_"+name)
|
| 188 |
return "_"+name
|
| 189 |
+
|
| 190 |
+
def run(p1,p2,*result):
|
| 191 |
p1_en = translate(p1,"english")
|
| 192 |
p2_en = translate(p2,"english")
|
| 193 |
p = {"a":p1_en,"b":p2_en}
|
|
|
|
| 198 |
with Pool(ln, initializer=init_pool) as pool:
|
| 199 |
out = pool.imap(infer,arr)
|
| 200 |
return list(out)
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
+
def ui():
|
| 203 |
with gr.Blocks(theme=gr.themes.Soft(),css=css,js=js) as demo:
|
| 204 |
with gr.Column(elem_id="col-container"):
|
| 205 |
gr.Markdown(f"""
|
|
|
|
| 229 |
demo.queue().launch(server_port=int(os.getenv("CUSTOM_PORT")))
|
| 230 |
|
| 231 |
if __name__ == "__main__":
|
| 232 |
+
|
| 233 |
+
global pp1
|
| 234 |
+
global pp2
|
| 235 |
+
global result
|
| 236 |
+
|
| 237 |
+
pp1=pipe_t2i()
|
| 238 |
+
pp2=pipe_i2i()
|
| 239 |
+
result=[]
|
| 240 |
+
|
| 241 |
+
mp.set_start_method("spawn", force=True)
|
| 242 |
+
|
| 243 |
+
port_inc()
|
| 244 |
+
ui()
|