Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,30 +3,11 @@ import os
|
|
3 |
import requests
|
4 |
import random
|
5 |
import time
|
|
|
6 |
name2 = "dreamlike-art/dreamlike-photoreal-2.0"
|
7 |
-
#name2 = "runwayml/stable-diffusion-v1-5"
|
8 |
|
9 |
models=[
|
10 |
-
|
11 |
-
gr.Interface.load(f"models/{name2}"),
|
12 |
-
gr.Interface.load(f"models/{name2}"),
|
13 |
-
gr.Interface.load(f"models/{name2}"),
|
14 |
-
gr.Interface.load(f"models/{name2}"),
|
15 |
-
gr.Interface.load(f"models/{name2}"),
|
16 |
-
gr.Interface.load(f"models/{name2}"),
|
17 |
-
gr.Interface.load(f"models/{name2}"),
|
18 |
-
gr.Interface.load(f"models/{name2}"),
|
19 |
-
gr.Interface.load(f"models/{name2}"),
|
20 |
-
gr.Interface.load(f"models/{name2}"),
|
21 |
-
gr.Interface.load(f"models/{name2}"),
|
22 |
-
gr.Interface.load(f"models/{name2}"),
|
23 |
-
gr.Interface.load(f"models/{name2}"),
|
24 |
-
gr.Interface.load(f"models/{name2}"),
|
25 |
-
gr.Interface.load(f"models/{name2}"),
|
26 |
-
gr.Interface.load(f"models/{name2}"),
|
27 |
-
gr.Interface.load(f"models/{name2}"),
|
28 |
-
gr.Interface.load(f"models/{name2}"),
|
29 |
-
gr.Interface.load(f"models/{name2}"),
|
30 |
]
|
31 |
#o = os.getenv("P")
|
32 |
o = "V"
|
@@ -39,72 +20,78 @@ m_out = ("""
|
|
39 |
""")
|
40 |
loading=("""
|
41 |
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>""")
|
42 |
-
def
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
3 |
import requests
|
4 |
import random
|
5 |
import time
|
6 |
+
|
7 |
name2 = "dreamlike-art/dreamlike-photoreal-2.0"
|
|
|
8 |
|
9 |
models=[
|
10 |
+
gr.Interface.load(f"models/{name2}"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
]
|
12 |
#o = os.getenv("P")
|
13 |
o = "V"
|
|
|
20 |
""")
|
21 |
loading=("""
|
22 |
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>""")
|
23 |
+
def build():
|
24 |
+
def clear():
|
25 |
+
return gr.update(value=0),gr.update(value=0)
|
26 |
+
def start():
|
27 |
+
stamp = time.time()
|
28 |
+
return gr.update(value=stamp),gr.update(value=0)
|
29 |
+
def end(stamp):
|
30 |
+
ts = stamp + 360
|
31 |
+
ti = time.time()
|
32 |
+
if ti > ts and stamp != 0:
|
33 |
+
return gr.update(value=1),gr.HTML.update(f"{m_out}",visible=True)
|
34 |
+
else:
|
35 |
+
return gr.update(value=0),None
|
36 |
+
def im_fn(put,fac="",h=None):
|
37 |
+
try:
|
38 |
+
if h == o:
|
39 |
+
put = f"{put}{fac}"
|
40 |
+
fac = f"{fac} "
|
41 |
+
rn = 0
|
42 |
+
# rn = random.randint(0, 19)
|
43 |
+
model=models[rn]
|
44 |
+
return model(put),fac
|
45 |
+
elif h != o:
|
46 |
+
return(None,None)
|
47 |
+
except Exception as E:
|
48 |
+
return None, None
|
49 |
+
def cl_fac():
|
50 |
+
return "",gr.HTML.update(f"{loading}")
|
51 |
+
with gr.Blocks() as b:
|
52 |
+
with gr.Row():
|
53 |
+
with gr.Column():
|
54 |
+
put = gr.Textbox()
|
55 |
+
with gr.Column():
|
56 |
+
with gr.Row():
|
57 |
+
btn1 = gr.Button("Run")
|
58 |
+
btn2 = gr.Button("Clear")
|
59 |
+
message=gr.HTML("<div></div>")
|
60 |
+
message2=gr.HTML("",visible=False)
|
61 |
|
62 |
+
with gr.Row():
|
63 |
+
out1 = gr.Image()
|
64 |
+
out2 = gr.Image()
|
65 |
+
with gr.Row():
|
66 |
+
out3 = gr.Image()
|
67 |
+
out4 = gr.Image()
|
68 |
+
with gr.Row():
|
69 |
+
out5 = gr.Image()
|
70 |
+
out6 = gr.Image()
|
71 |
|
72 |
+
with gr.Row(visible=False):
|
73 |
+
h_variavel=gr.Textbox(value="V")
|
74 |
+
t_state=gr.Number()
|
75 |
+
t_switch=gr.Textbox(value=0)
|
76 |
+
def clear_all():
|
77 |
+
return "",None,None,None,None,None,None,1,gr.HTML.update("<div></div>")
|
78 |
+
fac_b = gr.Textbox(value="",visible=False)
|
79 |
|
80 |
+
def noth():
|
81 |
+
return gr.HTML.update("<div></div>")
|
82 |
+
#a1=btn1.click(noth,None,btn1,every=1)
|
83 |
+
btn1.click(cl_fac,None,[fac_b,message],show_progress=False)
|
84 |
+
b1=btn1.click(start,None,[t_state,t_switch],show_progress=True)
|
85 |
+
sta = t_state.change(end,t_state,[t_switch,message2],every=1,show_progress=True)
|
86 |
+
b2=btn1.click(im_fn,[put,fac_b,h_variavel],[out1,fac_b], show_progress=True)
|
87 |
+
b3=out1.change(im_fn,[put,fac_b,h_variavel],[out2,fac_b], show_progress=True)
|
88 |
+
b4=out2.change(im_fn,[put,fac_b,h_variavel],[out3,fac_b], show_progress=True)
|
89 |
+
b5=out3.change(im_fn,[put,fac_b,h_variavel],[out4,fac_b], show_progress=True)
|
90 |
+
b6=out4.change(im_fn,[put,fac_b,h_variavel],[out5,fac_b], show_progress=True)
|
91 |
+
b7=out5.change(im_fn,[put,fac_b,h_variavel],[out6,fac_b], show_progress=True)
|
92 |
+
b8=out6.change(noth,None,message, show_progress=False)
|
93 |
+
swi=t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5,b6,b7],show_progress=False)
|
94 |
+
#btn2.click(noth,None,message,cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
|
95 |
+
btn2.click(clear_all, None,[fac_b,put,out1,out2,out3,out4,t_state,t_switch,message],cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
|
96 |
+
b.queue(concurrency_count=100).launch(show_api=False)
|
97 |
+
build()
|