RamAnanth1 commited on
Commit
a8328c7
·
1 Parent(s): 80cae5a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ nets=[
4
+ "hysts/ControlNet",
5
+ "fffiloni/ControlNet-Video",
6
+ "RamAnanth1/ControlNet",
7
+ "hysts/ControlNet-with-other-models",
8
+ ]
9
+
10
+ width="100%"
11
+ height="2500"
12
+ class NetLink:
13
+ x=""
14
+ def change(self,link):
15
+ ch = link.replace("/","-").replace("_","-")
16
+ return f"https://{ch}.hf.space"
17
+ n=NetLink()
18
+
19
+ def fn0():
20
+ return gr.Accordion.update(label=f"{nets[0]}",visible=True),gr.Accordion.update(label=f"{nets[1]}",visible=False),gr.Accordion.update(label=f"{nets[2]}",visible=False),gr.Accordion.update(label=f"{nets[3]}",visible=False)
21
+ def fn1():
22
+ return gr.Accordion.update(label=f"{nets[0]}",visible=False),gr.Accordion.update(label=f"{nets[1]}",visible=True),gr.Accordion.update(label=f"{nets[2]}",visible=False),gr.Accordion.update(label=f"{nets[3]}",visible=False)
23
+ def fn2():
24
+ return gr.Accordion.update(label=f"{nets[0]}",visible=False),gr.Accordion.update(label=f"{nets[1]}",visible=False),gr.Accordion.update(label=f"{nets[2]}",visible=True),gr.Accordion.update(label=f"{nets[3]}",visible=False)
25
+ def fn3():
26
+ return gr.Accordion.update(label=f"{nets[0]}",visible=False),gr.Accordion.update(label=f"{nets[1]}",visible=False),gr.Accordion.update(label=f"{nets[2]}",visible=False),gr.Accordion.update(label=f"{nets[3]}",visible=True)
27
+
28
+
29
+ with gr.Blocks(css="sauce.css") as control_app:
30
+ gr.Markdown("""<center><h1>Control Net Collection</h1><center>""")
31
+ gr.Markdown(f"""<center><h3>Find these AI Demos and more at <br><a href='https://hugggingface.co/spaces'>Huggingface Spaces</a></h3>""")
32
+ with gr.Box():
33
+ with gr.Row():
34
+ with gr.Column():
35
+ btn0 = gr.Button(f'{nets[0]}')
36
+ btn1 = gr.Button(f'{nets[1]}')
37
+ with gr.Column():
38
+ btn2 = gr.Button(f'{nets[2]}')
39
+ btn3 = gr.Button(f'{nets[3]}')
40
+
41
+ with gr.Accordion(label=f"{nets[0]}",visible=True) as a0:
42
+ gr.Markdown(f"""<center><h5>Find this Space at <a href='https://huggingface.co/spaces/{nets[0]}'>{nets[0]}</a></h5>""")
43
+ gr.HTML(f'''<center><iframe src="{n.change(nets[0])}" frameborder="0" width={width} height={height}></iframe><center>''')
44
+ with gr.Accordion(label=f"{nets[1]}",visible=False) as a1:
45
+ gr.Markdown(f"""<center><h5>Find this Space at <a href='https://huggingface.co/spaces/{nets[1]}'>{nets[1]}</a></h5>""")
46
+ gr.HTML(f'''<center><iframe src="{n.change(nets[1])}" frameborder="0" width={width} height={height}></iframe><center>''')
47
+ with gr.Accordion(label=f"{nets[2]}",visible=False) as a2:
48
+ gr.Markdown(f"""<center><h5>Find this Space at <a href='https://huggingface.co/spaces/{nets[2]}'>{nets[2]}</a></h5>""")
49
+ gr.HTML(f'''<center><iframe src="{n.change(nets[2])}" frameborder="0" width={width} height={height}></iframe><center>''')
50
+ with gr.Accordion(label=f"{nets[3]}",visible=False) as a3:
51
+ gr.Markdown(f"""<center><h5>Find this Space at <a href='https://huggingface.co/spaces/{nets[3]}'>{nets[3]}</a></h5>""")
52
+ gr.HTML(f'''<center><iframe src="{n.change(nets[3])}" frameborder="0" width={width} height={height}></iframe><center>''')
53
+
54
+ btn0.click(fn0,None,[a0,a1,a2,a3])
55
+ btn1.click(fn1,None,[a0,a1,a2,a3])
56
+ btn2.click(fn2,None,[a0,a1,a2,a3])
57
+ btn3.click(fn3,None,[a0,a1,a2,a3])
58
+
59
+ control_app.queue(concurrency_count=100).launch()