xp3857 commited on
Commit
b593cfa
1 Parent(s): f65f4eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -40
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import gradio as gr
2
- import requests
3
  import os
 
4
  import random
5
- import time
6
-
7
- name2 = "runwayml/stable-diffusion-v1-5"
 
 
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),None,None,None,None
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="",fac_c=None,h=None):
50
  if h == o:
51
- if int(fac_c)==1:
52
- rn = random.randint(0, 19)
53
- model=models[rn]
54
- put = f"{put}{fac}"
55
- fac = f"{fac} "
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,"",0)
62
  def cl_fac():
63
- return "",0,None,None,None,None
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
- o1 = gr.Textbox(value=0)
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
- fac_c = gr.Textbox(value=0)
86
- fac_d = gr.Textbox(value=1)
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
- b3=out1.change(im_fn,[put,fac_b,fac_c,h],[out2,fac_b,fac_c])
92
- b4=out2.change(im_fn,[put,fac_b,fac_c,h],[out3,fac_b,fac_c])
93
- b5=out3.change(im_fn,[put,fac_b,fac_c,h],[out4,fac_b,fac_c])
94
- b6=out4.change(clear,None,[t_switch,fac_c])
95
- b2=btn1.click(im_fn,[put,fac_b,fac_d,h],[out1,fac_b,fac_c])
96
- #b0=btn1.click(cl_fac,None,[fac_b,fac_c,out1,out2,out3,out4],show_progress=False)
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()