Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
import time
|
2 |
-
|
3 |
-
from theme_dropdown import create_theme_dropdown # noqa: F401
|
4 |
-
|
5 |
import gradio as gr
|
|
|
6 |
|
7 |
dropdown, js = create_theme_dropdown()
|
8 |
|
9 |
with gr.Blocks(theme='syddharth/base-inter') as demo:
|
10 |
-
with gr.Row()
|
11 |
with gr.Column(scale=10):
|
12 |
gr.Markdown(
|
13 |
"""
|
@@ -20,7 +18,7 @@ with gr.Blocks(theme='syddharth/base-inter') as demo:
|
|
20 |
with gr.Column(scale=3):
|
21 |
with gr.Box():
|
22 |
dropdown.render()
|
23 |
-
toggle_dark = gr.Button(value="Toggle Dark")
|
24 |
|
25 |
dropdown.change(None, dropdown, None, _js=js)
|
26 |
toggle_dark.click(
|
@@ -44,17 +42,18 @@ with gr.Blocks(theme='syddharth/base-inter') as demo:
|
|
44 |
with gr.Row():
|
45 |
slider1 = gr.Slider(label="Slider 1")
|
46 |
slider2 = gr.Slider(label="Slider 2")
|
|
|
47 |
gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
|
48 |
|
49 |
with gr.Row():
|
50 |
-
with gr.Column(
|
51 |
gr.Markdown("## Panel 1")
|
52 |
radio = gr.Radio(
|
53 |
["A", "B", "C"],
|
54 |
label="Radio",
|
55 |
-
info="Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
56 |
)
|
57 |
-
drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"],
|
58 |
drop_2 = gr.Dropdown(
|
59 |
["Option A", "Option B", "Option C"],
|
60 |
multiselect=True,
|
@@ -63,34 +62,32 @@ with gr.Blocks(theme='syddharth/base-inter') as demo:
|
|
63 |
interactive=True,
|
64 |
)
|
65 |
check = gr.Checkbox(label="Go")
|
66 |
-
|
|
|
67 |
img = gr.Image(
|
68 |
-
"https://gradio.app/assets/img/header-image.jpg",
|
69 |
-
|
|
|
70 |
with gr.Row():
|
71 |
-
go_btn = gr.Button("
|
72 |
-
clear_btn = gr.Button(
|
73 |
-
"Clear", label="Secondary Button", variant="secondary"
|
74 |
-
)
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
-
|
87 |
|
88 |
with gr.Row():
|
89 |
-
btn1 = gr.Button("Button 1")
|
90 |
-
btn2 = gr.UploadButton()
|
91 |
-
stop_btn = gr.Button("Stop
|
92 |
-
size="sm"
|
93 |
-
)
|
94 |
|
95 |
with gr.Row():
|
96 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
@@ -99,42 +96,29 @@ with gr.Blocks(theme='syddharth/base-inter') as demo:
|
|
99 |
)
|
100 |
gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
|
101 |
gr.File()
|
|
|
102 |
with gr.Row():
|
103 |
gr.ColorPicker()
|
104 |
gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
|
105 |
gr.Gallery(
|
106 |
[
|
107 |
-
(
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
"logo",
|
114 |
-
),
|
115 |
-
(
|
116 |
-
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
117 |
-
"tower",
|
118 |
-
),
|
119 |
-
]
|
120 |
-
).style(height="200px", grid=2)
|
121 |
|
122 |
with gr.Row():
|
123 |
with gr.Column(scale=2):
|
124 |
chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
|
125 |
chat_btn = gr.Button("Add messages")
|
126 |
|
127 |
-
def
|
128 |
-
|
129 |
-
|
|
|
130 |
|
131 |
-
chat_btn.click(
|
132 |
-
lambda history: history
|
133 |
-
+ [["How are you?", "I am good."]]
|
134 |
-
+ (time.sleep(2) or []),
|
135 |
-
chatbot,
|
136 |
-
chatbot,
|
137 |
-
)
|
138 |
with gr.Column(scale=1):
|
139 |
with gr.Accordion("Advanced Settings"):
|
140 |
gr.Markdown("Hello")
|
|
|
1 |
import time
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
+
from theme_dropdown import create_theme_dropdown # noqa: F401
|
4 |
|
5 |
dropdown, js = create_theme_dropdown()
|
6 |
|
7 |
with gr.Blocks(theme='syddharth/base-inter') as demo:
|
8 |
+
with gr.Row():
|
9 |
with gr.Column(scale=10):
|
10 |
gr.Markdown(
|
11 |
"""
|
|
|
18 |
with gr.Column(scale=3):
|
19 |
with gr.Box():
|
20 |
dropdown.render()
|
21 |
+
toggle_dark = gr.Button(value="Toggle Dark")
|
22 |
|
23 |
dropdown.change(None, dropdown, None, _js=js)
|
24 |
toggle_dark.click(
|
|
|
42 |
with gr.Row():
|
43 |
slider1 = gr.Slider(label="Slider 1")
|
44 |
slider2 = gr.Slider(label="Slider 2")
|
45 |
+
|
46 |
gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
|
47 |
|
48 |
with gr.Row():
|
49 |
+
with gr.Column(scale=1):
|
50 |
gr.Markdown("## Panel 1")
|
51 |
radio = gr.Radio(
|
52 |
["A", "B", "C"],
|
53 |
label="Radio",
|
54 |
+
info="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
|
55 |
)
|
56 |
+
drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], label="Dropdown")
|
57 |
drop_2 = gr.Dropdown(
|
58 |
["Option A", "Option B", "Option C"],
|
59 |
multiselect=True,
|
|
|
62 |
interactive=True,
|
63 |
)
|
64 |
check = gr.Checkbox(label="Go")
|
65 |
+
|
66 |
+
with gr.Column(scale=2):
|
67 |
img = gr.Image(
|
68 |
+
value="https://gradio.app/assets/img/header-image.jpg",
|
69 |
+
label="Image",
|
70 |
+
)
|
71 |
with gr.Row():
|
72 |
+
go_btn = gr.Button("Primary Button", variant="primary")
|
73 |
+
clear_btn = gr.Button("Secondary Button", variant="secondary")
|
|
|
|
|
74 |
|
75 |
+
def go(*args):
|
76 |
+
time.sleep(3)
|
77 |
+
return "https://gradio.app/assets/img/header-image.jpg"
|
78 |
|
79 |
+
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
80 |
|
81 |
+
def clear():
|
82 |
+
time.sleep(0.2)
|
83 |
+
return None
|
84 |
|
85 |
+
clear_btn.click(clear, None, img)
|
86 |
|
87 |
with gr.Row():
|
88 |
+
btn1 = gr.Button("Button 1")
|
89 |
+
btn2 = gr.UploadButton()
|
90 |
+
stop_btn = gr.Button("Stop Button", variant="stop")
|
|
|
|
|
91 |
|
92 |
with gr.Row():
|
93 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
|
|
96 |
)
|
97 |
gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
|
98 |
gr.File()
|
99 |
+
|
100 |
with gr.Row():
|
101 |
gr.ColorPicker()
|
102 |
gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
|
103 |
gr.Gallery(
|
104 |
[
|
105 |
+
("https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg", "lion"),
|
106 |
+
("https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png", "logo"),
|
107 |
+
("https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg", "tower"),
|
108 |
+
],
|
109 |
+
label="Gallery",
|
110 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
with gr.Row():
|
113 |
with gr.Column(scale=2):
|
114 |
chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
|
115 |
chat_btn = gr.Button("Add messages")
|
116 |
|
117 |
+
def chat_callback(history):
|
118 |
+
return history + [["How are you?", "I am good."]]
|
119 |
+
|
120 |
+
chat_btn.click(chat_callback, chatbot, chatbot)
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
with gr.Column(scale=1):
|
123 |
with gr.Accordion("Advanced Settings"):
|
124 |
gr.Markdown("Hello")
|