MackinationsAi commited on
Commit
6172b2c
·
verified ·
1 Parent(s): 85cbde2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +148 -148
app.py CHANGED
@@ -1,148 +1,148 @@
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='MackinationsAi/dark_evo') as demo:
9
- with gr.Row().style(equal_height=True):
10
- with gr.Column(scale=10):
11
- gr.Markdown(
12
- """
13
- # Theme preview: `dark_evo`
14
- To use this theme, set `theme='MackinationsAi/dark_evo'` 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.Box():
21
- dropdown.render()
22
- toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
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="MackinationsAi",
38
- value="MackinationsAi",
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 Demo")
50
- radio = gr.Radio(
51
- ["A", "B", "C"],
52
- label="Theme Info",
53
- info="A gradio dark_theme for those of you how like to customize your own UI for a1111, forge & beyond. Hope you enjoy this theme! [If you'd like to customize the avatar, please duplicate this space and add your own image link in this app.py file in the Image widget below, as well as in themes/[email protected] file]",
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/98pxhL6/dark-dark-evo.webp",
67
- label="Image",
68
- ).style(height=320)
69
- with gr.Row():
70
- go_btn = gr.Button("Go", label="Primary Button", variant="primary")
71
- clear_btn = gr.Button(
72
- "Clear", label="Secondary Button", variant="secondary"
73
- )
74
-
75
- def go(*args):
76
- time.sleep(3)
77
- return "https://i.ibb.co/FHm8Xf3/faded-dark-evo.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").style(size="sm")
89
- btn2 = gr.UploadButton().style(size="sm")
90
- stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
91
- size="sm"
92
- )
93
-
94
- with gr.Row():
95
- gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
96
- gr.JSON(
97
- value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
98
- )
99
- gr.Label(value={"dog": 0.6, "cat": 0.3, "lizard": 0.1})
100
- gr.File()
101
- with gr.Row():
102
- gr.ColorPicker()
103
- gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
104
- gr.Gallery(
105
- [
106
- (
107
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
108
- "logo",
109
- ),
110
- (
111
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
112
- "lion",
113
- ),
114
- (
115
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
116
- "tower",
117
- ),
118
- ]
119
- ).style(height="200px", grid=2)
120
-
121
- with gr.Row():
122
- with gr.Column(scale=2):
123
- chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
124
- chat_btn = gr.Button("Add messages")
125
-
126
- def chat(history):
127
- time.sleep(2)
128
- yield [["How ya doing?", "I'm great, cheers! Thanks for asking."]]
129
-
130
- chat_btn.click(
131
- lambda history: history
132
- + [["How ya doing?", "I'm great, cheers! Thanks for asking."]]
133
- + (time.sleep(2) or []),
134
- chatbot,
135
- chatbot,
136
- )
137
- with gr.Column(scale=1):
138
- with gr.Accordion("Advanced Settings", open=False):
139
- gr.Markdown("Hello")
140
- gr.Number(label="Chatbot control 1")
141
- gr.Number(label="Chatbot control 2")
142
- gr.Number(label="Chatbot control 3")
143
-
144
-
145
- if __name__ == "__main__":
146
- demo.queue().launch()
147
-
148
- # Based on NoCrypt's original miku theme_scheme
 
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='MackinationsAi/dark_evo') as demo:
9
+ with gr.Row().style(equal_height=True):
10
+ with gr.Column(scale=10):
11
+ gr.Markdown(
12
+ """
13
+ # Theme preview: `dark_evo`
14
+ To use this theme, set `theme='MackinationsAi/dark_evo'` 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.Box():
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="MackinationsAi",
38
+ value="MackinationsAi",
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 Demo")
50
+ radio = gr.Radio(
51
+ ["A", "B", "C"],
52
+ label="Theme Info",
53
+ info="A gradio dark_theme for those of you how like to customize your own UI for a1111, forge & beyond. Hope you enjoy this theme! [If you'd like to customize the avatar, please duplicate this space and add your own image link in this app.py file in the Image widget below, as well as in themes/[email protected] file]",
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/98pxhL6/dark-dark-evo.webp",
67
+ label="Image",
68
+ ).style(height=320)
69
+ with gr.Row():
70
+ go_btn = gr.Button("Go", label="Primary Button", variant="primary")
71
+ clear_btn = gr.Button(
72
+ "Clear", label="Secondary Button", variant="secondary"
73
+ )
74
+
75
+ def go(*args):
76
+ time.sleep(3)
77
+ return "https://i.ibb.co/FHm8Xf3/faded-dark-evo.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").style(size="sm")
89
+ btn2 = gr.UploadButton().style(size="sm")
90
+ stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
91
+ size="sm"
92
+ )
93
+
94
+ with gr.Row():
95
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
96
+ gr.JSON(
97
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
98
+ )
99
+ gr.Label(value={"dog": 0.6, "cat": 0.3, "lizard": 0.1})
100
+ gr.File()
101
+ with gr.Row():
102
+ gr.ColorPicker()
103
+ gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
104
+ gr.Gallery(
105
+ [
106
+ (
107
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
108
+ "logo",
109
+ ),
110
+ (
111
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
112
+ "lion",
113
+ ),
114
+ (
115
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
116
+ "tower",
117
+ ),
118
+ ]
119
+ ).style(height="200px", grid=2)
120
+
121
+ with gr.Row():
122
+ with gr.Column(scale=2):
123
+ chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
124
+ chat_btn = gr.Button("Add messages")
125
+
126
+ def chat(history):
127
+ time.sleep(2)
128
+ yield [["How ya doing?", "I'm great, cheers! Thanks for asking."]]
129
+
130
+ chat_btn.click(
131
+ lambda history: history
132
+ + [["How ya doing?", "I'm great, cheers! Thanks for asking."]]
133
+ + (time.sleep(2) or []),
134
+ chatbot,
135
+ chatbot,
136
+ )
137
+ with gr.Column(scale=1):
138
+ with gr.Accordion("Advanced Settings", open=False):
139
+ gr.Markdown("Hello")
140
+ gr.Number(label="Chatbot control 1")
141
+ gr.Number(label="Chatbot control 2")
142
+ gr.Number(label="Chatbot control 3")
143
+
144
+
145
+ if __name__ == "__main__":
146
+ demo.queue().launch()
147
+
148
+ # Based on NoCrypt's original miku theme_scheme