xp3857 commited on
Commit
4b9f915
1 Parent(s): 477a5c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import requests
3
  import os
4
  import random
5
-
6
 
7
 
8
 
@@ -32,6 +32,32 @@ models=[
32
  o = os.getenv("P")
33
 
34
  def ac():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  def im_fn(put,fac="",h=None):
36
  if h == o:
37
  rn = random.randint(0, 19)
@@ -56,7 +82,13 @@ def ac():
56
  out4 = gr.Image()
57
  with gr.Row(visible=False):
58
  h=gr.Textbox("Q")
 
 
 
59
  fac_b = gr.Textbox(value="",visible=False)
 
 
 
60
  btn1.click(cl_fac,None,fac_b)
61
  btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
62
  out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
 
2
  import requests
3
  import os
4
  import random
5
+ import time
6
 
7
 
8
 
 
32
  o = os.getenv("P")
33
 
34
  def ac():
35
+ def clear(v):
36
+ if int(v) != 0:
37
+ v = 0
38
+ else:
39
+ v = 0
40
+ pass
41
+ return v
42
+ def start():
43
+ stamp = time.time()
44
+ return gr.update(value=stamp),gr.update(value=0)
45
+
46
+ def end(stamp):
47
+ ts = t_stamp + 6
48
+ ti = time.time()
49
+ if ti > ts and stamp != 0:
50
+ t=gr.update(value=1)
51
+ else:
52
+ t=gr.update(value=0)
53
+ pass
54
+ return t
55
+
56
+
57
+
58
+
59
+
60
+
61
  def im_fn(put,fac="",h=None):
62
  if h == o:
63
  rn = random.randint(0, 19)
 
82
  out4 = gr.Image()
83
  with gr.Row(visible=False):
84
  h=gr.Textbox("Q")
85
+ t_state=gr.Number()
86
+ t_switch=gr.Textbox(value=0)
87
+
88
  fac_b = gr.Textbox(value="",visible=False)
89
+ btn1.click(start,None,[t_state,t_switch])
90
+ sta = t_state.change(end,t_state,t_switch,every=1)
91
+ t_switch.change(clear,t_switch,t_switch, cancels=[sta])
92
  btn1.click(cl_fac,None,fac_b)
93
  btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
94
  out1.change(im_fn,[put,fac_b,h],[out2,fac_b])