soiz1 commited on
Commit
622cbea
·
verified ·
1 Parent(s): 0d581f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +145 -144
app.py CHANGED
@@ -1,144 +1,145 @@
1
- import time
2
-
3
- import gradio as gr
4
- from gradio.themes.utils.theme_dropdown import create_theme_dropdown
5
-
6
- dropdown, js = create_theme_dropdown()
7
-
8
- with gr.Blocks(theme='John6666/YntecDark') as demo:
9
- with gr.Row():
10
- with gr.Column(scale=10):
11
- gr.Markdown(
12
- """
13
- # Theme preview: `YntecDark`
14
- To use this theme, set `theme='John6666/YntecDark'` in `gr.Blocks()` or `gr.Interface()`.
15
- You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
16
- of this theme.
17
- """
18
- )
19
- with gr.Column(scale=3):
20
- with gr.Group():
21
- dropdown.render()
22
- toggle_dark = gr.Button(value="Toggle Dark")
23
-
24
- dropdown.change(None, dropdown, None, _js=js)
25
- toggle_dark.click(
26
- None,
27
- _js="""
28
- () => {
29
- document.body.classList.toggle('dark');
30
- }
31
- """,
32
- )
33
-
34
- name = gr.Textbox(
35
- label="Name",
36
- info="Full name, including middle name. No special characters.",
37
- placeholder="John Doe",
38
- value="John Doe",
39
- interactive=True,
40
- )
41
-
42
- with gr.Row():
43
- slider1 = gr.Slider(label="Slider 1")
44
- slider2 = gr.Slider(label="Slider 2")
45
- gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
46
-
47
- with gr.Row():
48
- with gr.Column(variant="panel", scale=1):
49
- gr.Markdown("## Panel 1")
50
- radio = gr.Radio(
51
- ["A", "B", "C"],
52
- label="Radio",
53
- info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
54
- )
55
- drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
56
- drop_2 = gr.Dropdown(
57
- ["Option A", "Option B", "Option C"],
58
- multiselect=True,
59
- value=["Option A"],
60
- label="Dropdown",
61
- interactive=True,
62
- )
63
- check = gr.Checkbox(label="Go")
64
- with gr.Column(variant="panel", scale=2):
65
- img = gr.Image(
66
- "https://i.ibb.co/F4hKFrZ/dark-miku.webp",
67
- label="Image",
68
- )
69
- with gr.Row():
70
- go_btn = gr.Button("Go", variant="primary")
71
- clear_btn = gr.Button(
72
- "Clear", variant="secondary"
73
- )
74
-
75
- def go(*args):
76
- time.sleep(3)
77
- return "https://i.ibb.co/0rfK9Wm/light-miku-faded.webp"
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", variant="stop")
91
-
92
- with gr.Row():
93
- gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
94
- gr.JSON(
95
- value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
96
- )
97
- gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
98
- gr.File()
99
- with gr.Row():
100
- gr.ColorPicker()
101
- gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
102
- gr.Gallery(
103
- [
104
- (
105
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
106
- "lion",
107
- ),
108
- (
109
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
110
- "logo",
111
- ),
112
- (
113
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
114
- "tower",
115
- ),
116
- ]
117
- )
118
-
119
- with gr.Row():
120
- with gr.Column(scale=2):
121
- chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
122
- chat_btn = gr.Button("Add messages")
123
-
124
- def chat(history):
125
- time.sleep(2)
126
- yield [["How are you?", "I am good."]]
127
-
128
- chat_btn.click(
129
- lambda history: history
130
- + [["How are you?", "I am good."]]
131
- + (time.sleep(2) or []),
132
- chatbot,
133
- chatbot,
134
- )
135
- with gr.Column(scale=1):
136
- with gr.Accordion("Advanced Settings"):
137
- gr.Markdown("Hello")
138
- gr.Number(label="Chatbot control 1")
139
- gr.Number(label="Chatbot control 2")
140
- gr.Number(label="Chatbot control 3")
141
-
142
-
143
- if __name__ == "__main__":
144
- demo.queue().launch()
 
 
1
+ #Meaningless comments for restarting
2
+ import time
3
+
4
+ import gradio as gr
5
+ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
6
+
7
+ dropdown, js = create_theme_dropdown()
8
+
9
+ with gr.Blocks(theme='John6666/YntecDark') as demo:
10
+ with gr.Row():
11
+ with gr.Column(scale=10):
12
+ gr.Markdown(
13
+ """
14
+ # Theme preview: `YntecDark`
15
+ To use this theme, set `theme='John6666/YntecDark'` in `gr.Blocks()` or `gr.Interface()`.
16
+ You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
17
+ of this theme.
18
+ """
19
+ )
20
+ with gr.Column(scale=3):
21
+ with gr.Group():
22
+ dropdown.render()
23
+ toggle_dark = gr.Button(value="Toggle Dark")
24
+
25
+ dropdown.change(None, dropdown, None, _js=js)
26
+ toggle_dark.click(
27
+ None,
28
+ _js="""
29
+ () => {
30
+ document.body.classList.toggle('dark');
31
+ }
32
+ """,
33
+ )
34
+
35
+ name = gr.Textbox(
36
+ label="Name",
37
+ info="Full name, including middle name. No special characters.",
38
+ placeholder="John Doe",
39
+ value="John Doe",
40
+ interactive=True,
41
+ )
42
+
43
+ with gr.Row():
44
+ slider1 = gr.Slider(label="Slider 1")
45
+ slider2 = gr.Slider(label="Slider 2")
46
+ gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
47
+
48
+ with gr.Row():
49
+ with gr.Column(variant="panel", 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, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
55
+ )
56
+ drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
57
+ drop_2 = gr.Dropdown(
58
+ ["Option A", "Option B", "Option C"],
59
+ multiselect=True,
60
+ value=["Option A"],
61
+ label="Dropdown",
62
+ interactive=True,
63
+ )
64
+ check = gr.Checkbox(label="Go")
65
+ with gr.Column(variant="panel", scale=2):
66
+ img = gr.Image(
67
+ "https://i.ibb.co/F4hKFrZ/dark-miku.webp",
68
+ label="Image",
69
+ )
70
+ with gr.Row():
71
+ go_btn = gr.Button("Go", variant="primary")
72
+ clear_btn = gr.Button(
73
+ "Clear", variant="secondary"
74
+ )
75
+
76
+ def go(*args):
77
+ time.sleep(3)
78
+ return "https://i.ibb.co/0rfK9Wm/light-miku-faded.webp"
79
+
80
+ go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
81
+
82
+ def clear():
83
+ time.sleep(0.2)
84
+ return None
85
+
86
+ clear_btn.click(clear, None, img)
87
+
88
+ with gr.Row():
89
+ btn1 = gr.Button("Button 1")
90
+ btn2 = gr.UploadButton()
91
+ stop_btn = gr.Button("Stop", variant="stop")
92
+
93
+ with gr.Row():
94
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
95
+ gr.JSON(
96
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
97
+ )
98
+ gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
99
+ gr.File()
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
+ (
106
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
107
+ "lion",
108
+ ),
109
+ (
110
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
111
+ "logo",
112
+ ),
113
+ (
114
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
115
+ "tower",
116
+ ),
117
+ ]
118
+ )
119
+
120
+ with gr.Row():
121
+ with gr.Column(scale=2):
122
+ chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
123
+ chat_btn = gr.Button("Add messages")
124
+
125
+ def chat(history):
126
+ time.sleep(2)
127
+ yield [["How are you?", "I am good."]]
128
+
129
+ chat_btn.click(
130
+ lambda history: history
131
+ + [["How are you?", "I am good."]]
132
+ + (time.sleep(2) or []),
133
+ chatbot,
134
+ chatbot,
135
+ )
136
+ with gr.Column(scale=1):
137
+ with gr.Accordion("Advanced Settings"):
138
+ gr.Markdown("Hello")
139
+ gr.Number(label="Chatbot control 1")
140
+ gr.Number(label="Chatbot control 2")
141
+ gr.Number(label="Chatbot control 3")
142
+
143
+
144
+ if __name__ == "__main__":
145
+ demo.queue().launch()