Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
import requests
|
3 |
import os
|
|
|
4 |
import random
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
models=[
|
9 |
gr.Interface.load(f"models/{name2}"),
|
10 |
gr.Interface.load(f"models/{name2}"),
|
@@ -27,15 +29,14 @@ models=[
|
|
27 |
gr.Interface.load(f"models/{name2}"),
|
28 |
gr.Interface.load(f"models/{name2}"),
|
29 |
]
|
30 |
-
o = os.getenv("P")
|
31 |
-
|
32 |
def ac():
|
33 |
def clear():
|
34 |
return gr.update(value=0),gr.update(value=0)
|
35 |
def start():
|
36 |
stamp = time.time()
|
37 |
-
return gr.update(value=stamp),gr.update(value=0)
|
38 |
-
|
39 |
def end(stamp):
|
40 |
ts = stamp + 6
|
41 |
ti = time.time()
|
@@ -45,24 +46,19 @@ def ac():
|
|
45 |
else:
|
46 |
print("Passing")
|
47 |
return gr.update(value=0)
|
48 |
-
|
49 |
-
def im_fn(put,fac="",
|
50 |
if h == o:
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
print (rn)
|
57 |
-
return model(put),fac,gr.update(value=1)
|
58 |
-
elif int(fac_c)!=1:
|
59 |
-
pass
|
60 |
elif h != o:
|
61 |
-
return(None,
|
62 |
def cl_fac():
|
63 |
-
return ""
|
64 |
-
|
65 |
-
with gr.Blocks() as b:
|
66 |
with gr.Row():
|
67 |
put = gr.Textbox()
|
68 |
btn1 = gr.Button()
|
@@ -73,28 +69,24 @@ def ac():
|
|
73 |
out3 = gr.Image()
|
74 |
out4 = gr.Image()
|
75 |
with gr.Row(visible=False):
|
76 |
-
|
77 |
-
o2 = gr.Textbox(value=0)
|
78 |
-
o3 = gr.Textbox(value=0)
|
79 |
-
o4 = gr.Textbox(value=0)
|
80 |
-
with gr.Row(visible=False):
|
81 |
-
h=gr.Textbox("Q")
|
82 |
t_state=gr.Number()
|
83 |
t_switch=gr.Textbox(value=0)
|
|
|
84 |
fac_b = gr.Textbox(value="",visible=False)
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
b1=btn1.click(start,None,[t_state,t_switch,out1,out2,out3,out4])
|
90 |
sta = t_state.change(end,t_state,t_switch,every=1)
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
t_switch.change(clear,None,[t_switch,fac_c], cancels=[sta,b2,b3,b4,b5])
|
98 |
|
|
|
|
|
99 |
b.queue(concurrency_count=100).launch(show_api=False)
|
100 |
ac()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import os
|
3 |
+
import requests
|
4 |
import random
|
5 |
+
r = requests.get(f'https://huggingface.co/spaces/xp3857/text-to-image/raw/main/css.css')
|
6 |
+
css = r.text
|
7 |
+
|
8 |
+
|
9 |
+
model = gr.Interface.load(f"models/$name2")
|
10 |
models=[
|
11 |
gr.Interface.load(f"models/{name2}"),
|
12 |
gr.Interface.load(f"models/{name2}"),
|
|
|
29 |
gr.Interface.load(f"models/{name2}"),
|
30 |
gr.Interface.load(f"models/{name2}"),
|
31 |
]
|
32 |
+
#o = os.getenv("P")
|
33 |
+
o = "V"
|
34 |
def ac():
|
35 |
def clear():
|
36 |
return gr.update(value=0),gr.update(value=0)
|
37 |
def start():
|
38 |
stamp = time.time()
|
39 |
+
return gr.update(value=stamp),gr.update(value=0)
|
|
|
40 |
def end(stamp):
|
41 |
ts = stamp + 6
|
42 |
ti = time.time()
|
|
|
46 |
else:
|
47 |
print("Passing")
|
48 |
return gr.update(value=0)
|
49 |
+
|
50 |
+
def im_fn(put,fac="",h=None):
|
51 |
if h == o:
|
52 |
+
put = f"{put}{fac}"
|
53 |
+
fac = f"{fac} "
|
54 |
+
rn = random.randint(0, 19)
|
55 |
+
model=models[rn]
|
56 |
+
return model(put),fac
|
|
|
|
|
|
|
|
|
57 |
elif h != o:
|
58 |
+
return(None,None)
|
59 |
def cl_fac():
|
60 |
+
return ""
|
61 |
+
with gr.Blocks(css=css) as b:
|
|
|
62 |
with gr.Row():
|
63 |
put = gr.Textbox()
|
64 |
btn1 = gr.Button()
|
|
|
69 |
out3 = gr.Image()
|
70 |
out4 = gr.Image()
|
71 |
with gr.Row(visible=False):
|
72 |
+
h=gr.Textbox(value="V")
|
|
|
|
|
|
|
|
|
|
|
73 |
t_state=gr.Number()
|
74 |
t_switch=gr.Textbox(value=0)
|
75 |
+
|
76 |
fac_b = gr.Textbox(value="",visible=False)
|
77 |
+
btn1.click(cl_fac,None,fac_b)
|
78 |
+
|
79 |
+
b1=btn1.click(start,None,[t_state,t_switch])
|
|
|
|
|
80 |
sta = t_state.change(end,t_state,t_switch,every=1)
|
81 |
+
|
82 |
+
btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
|
83 |
+
out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
|
84 |
+
out2.change(im_fn,[put,fac_b,h],[out3,fac_b])
|
85 |
+
out3.change(im_fn,[put,fac_b,h],[out4,fac_b])
|
86 |
+
|
87 |
t_switch.change(clear,None,[t_switch,fac_c], cancels=[sta,b2,b3,b4,b5])
|
88 |
|
89 |
+
|
90 |
+
|
91 |
b.queue(concurrency_count=100).launch(show_api=False)
|
92 |
ac()
|