Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import os
|
2 |
import re
|
3 |
-
import spaces
|
4 |
import random
|
5 |
import string
|
6 |
import torch
|
@@ -83,7 +83,7 @@ def generate_random_string(length):
|
|
83 |
characters = string.ascii_letters + string.digits
|
84 |
return ''.join(random.choice(characters) for _ in range(length))
|
85 |
|
86 |
-
@
|
87 |
def Piper1(_do):
|
88 |
print("starting piper1")
|
89 |
retu = pp1(
|
@@ -97,7 +97,7 @@ def Piper1(_do):
|
|
97 |
print("returning piper1")
|
98 |
return retu
|
99 |
|
100 |
-
@
|
101 |
def Piper2(img,posi,neg):
|
102 |
retu = pp2(
|
103 |
prompt=posi,
|
@@ -200,6 +200,8 @@ def run1(p1,p2,*result):
|
|
200 |
pool1.clear()
|
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}
|
@@ -253,7 +255,7 @@ def main():
|
|
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]
|
257 |
demo.queue().launch()
|
258 |
|
259 |
if __name__ == "__main__":
|
|
|
1 |
import os
|
2 |
import re
|
3 |
+
import spaces
|
4 |
import random
|
5 |
import string
|
6 |
import torch
|
|
|
83 |
characters = string.ascii_letters + string.digits
|
84 |
return ''.join(random.choice(characters) for _ in range(length))
|
85 |
|
86 |
+
@spaces.GPU(duration=40)
|
87 |
def Piper1(_do):
|
88 |
print("starting piper1")
|
89 |
retu = pp1(
|
|
|
97 |
print("returning piper1")
|
98 |
return retu
|
99 |
|
100 |
+
@spaces.GPU(duration=40)
|
101 |
def Piper2(img,posi,neg):
|
102 |
retu = pp2(
|
103 |
prompt=posi,
|
|
|
200 |
pool1.clear()
|
201 |
|
202 |
def run2(p1,p2,*result):
|
203 |
+
global out1
|
204 |
+
|
205 |
p1_en = translate(p1,"english")
|
206 |
p2_en = translate(p2,"english")
|
207 |
p = {"a":p1_en,"b":p2_en}
|
|
|
255 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
256 |
result.append(gr.Image(interactive=False,elem_classes="image-container", label="Result", show_label=False, type='filepath', show_share_button=False))
|
257 |
|
258 |
+
run_button.click(fn=run1,inputs=[prompt,prompt2,*result]).then(fn=run2,inputs=[prompt,prompt2,*result],outputs=result)
|
259 |
demo.queue().launch()
|
260 |
|
261 |
if __name__ == "__main__":
|