Update app.py
Browse files
app.py
CHANGED
@@ -50,8 +50,8 @@ t_out = ("""
|
|
50 |
position: fixed;
|
51 |
width: 100%;
|
52 |
height: 100%;
|
53 |
-
top:
|
54 |
-
left:
|
55 |
z-index:19999;
|
56 |
background: #ff000059;
|
57 |
|
@@ -59,12 +59,13 @@ t_out = ("""
|
|
59 |
|
60 |
#restart_btn{
|
61 |
position: fixed;
|
62 |
-
width: 100%;
|
63 |
-
height: 100%;
|
64 |
top: 0px;
|
65 |
left: 0px;
|
66 |
z-index:19999;
|
67 |
background: #ff000059;
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
|
@@ -142,11 +143,17 @@ document.querySelector("#close").addEventListener("click", function(){
|
|
142 |
</script>
|
143 |
|
144 |
""")
|
|
|
|
|
|
|
|
|
|
|
145 |
|
|
|
146 |
|
147 |
def ac():
|
148 |
def clear():
|
149 |
-
return gr.update(value=0),gr.update(value=0)
|
150 |
def start():
|
151 |
print ("start")
|
152 |
stamp = time.time()
|
@@ -156,8 +163,8 @@ def ac():
|
|
156 |
ti = time.time()
|
157 |
if ti > ts and stamp != 0:
|
158 |
print("Cancelling")
|
159 |
-
|
160 |
-
return gr.update(value=1)
|
161 |
|
162 |
else:
|
163 |
print("Passing")
|
@@ -173,7 +180,7 @@ def ac():
|
|
173 |
elif h != o:
|
174 |
return(None,None)
|
175 |
def cl_fac():
|
176 |
-
return ""
|
177 |
with gr.Blocks(css=css) as b:
|
178 |
with gr.Row():
|
179 |
put = gr.Textbox()
|
@@ -184,27 +191,18 @@ def ac():
|
|
184 |
with gr.Row():
|
185 |
out3 = gr.Image()
|
186 |
out4 = gr.Image()
|
187 |
-
message=gr.HTML("", visible=
|
188 |
|
189 |
with gr.Row(visible=False):
|
190 |
h=gr.Textbox(value="V")
|
191 |
t_state=gr.Number()
|
192 |
t_switch=gr.Textbox(value=0)
|
193 |
-
with gr.Accordion(elem_id="restart_btn",label="Timeout",open=False, visible=False) as acc:
|
194 |
-
restart = gr.Button()
|
195 |
-
|
196 |
-
def un_btn():
|
197 |
-
return gr.Button.update(elem_id="blank", visible=False)
|
198 |
-
|
199 |
-
|
200 |
-
restart.click(un_btn, None, restart)
|
201 |
-
|
202 |
|
203 |
fac_b = gr.Textbox(value="",visible=False)
|
204 |
-
btn1.click(cl_fac,None,fac_b)
|
205 |
|
206 |
b1=btn1.click(start,None,[t_state,t_switch])
|
207 |
-
sta = t_state.change(end,t_state,[t_switch],every=1)
|
208 |
|
209 |
b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
|
210 |
b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
|
|
|
50 |
position: fixed;
|
51 |
width: 100%;
|
52 |
height: 100%;
|
53 |
+
top: 50%;
|
54 |
+
left: 50%;
|
55 |
z-index:19999;
|
56 |
background: #ff000059;
|
57 |
|
|
|
59 |
|
60 |
#restart_btn{
|
61 |
position: fixed;
|
|
|
|
|
62 |
top: 0px;
|
63 |
left: 0px;
|
64 |
z-index:19999;
|
65 |
background: #ff000059;
|
66 |
+
width: 420px;
|
67 |
+
padding: 30px 40px;
|
68 |
+
transform: translate(-50%,-50%);
|
69 |
}
|
70 |
|
71 |
|
|
|
143 |
</script>
|
144 |
|
145 |
""")
|
146 |
+
m_out = ("""
|
147 |
+
<div id="restart_btn">
|
148 |
+
<h1><center>Loading Time Limit Reached.<br>
|
149 |
+
Please Click Launch again to Continue, or choose a Simpler Prompt</h1></center>
|
150 |
+
<div>
|
151 |
|
152 |
+
""")
|
153 |
|
154 |
def ac():
|
155 |
def clear():
|
156 |
+
return gr.update(value=0),gr.update(value=0)
|
157 |
def start():
|
158 |
print ("start")
|
159 |
stamp = time.time()
|
|
|
163 |
ti = time.time()
|
164 |
if ti > ts and stamp != 0:
|
165 |
print("Cancelling")
|
166 |
+
return gr.update(value=1),gr.HTML.update(f"{m_out}", visible=True)
|
167 |
+
#return gr.update(value=1)
|
168 |
|
169 |
else:
|
170 |
print("Passing")
|
|
|
180 |
elif h != o:
|
181 |
return(None,None)
|
182 |
def cl_fac():
|
183 |
+
return "",gr.HTML.update("", visible=False)
|
184 |
with gr.Blocks(css=css) as b:
|
185 |
with gr.Row():
|
186 |
put = gr.Textbox()
|
|
|
191 |
with gr.Row():
|
192 |
out3 = gr.Image()
|
193 |
out4 = gr.Image()
|
194 |
+
message=gr.HTML("", visible=False)
|
195 |
|
196 |
with gr.Row(visible=False):
|
197 |
h=gr.Textbox(value="V")
|
198 |
t_state=gr.Number()
|
199 |
t_switch=gr.Textbox(value=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
fac_b = gr.Textbox(value="",visible=False)
|
202 |
+
btn1.click(cl_fac,None,[fac_b,message])
|
203 |
|
204 |
b1=btn1.click(start,None,[t_state,t_switch])
|
205 |
+
sta = t_state.change(end,t_state,[t_switch,message],every=1,show_progress=False)
|
206 |
|
207 |
b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
|
208 |
b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
|