apply new theme
Browse files
app.py
CHANGED
@@ -7,7 +7,8 @@ import spaces
|
|
7 |
from PIL import Image
|
8 |
|
9 |
|
10 |
-
|
|
|
11 |
ladeco = Ladeco()
|
12 |
|
13 |
|
@@ -31,6 +32,12 @@ def infer(img: str) -> tuple[Figure, Figure]:
|
|
31 |
|
32 |
pie = plot_pie(l2_area, colors=colors)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
return seg, pie
|
35 |
|
36 |
|
@@ -98,17 +105,40 @@ css = """
|
|
98 |
}
|
99 |
.example-image {
|
100 |
height: 220px;
|
|
|
101 |
}
|
102 |
""".strip()
|
103 |
theme = gr.themes.Base(
|
104 |
primary_hue="orange",
|
105 |
-
secondary_hue="
|
106 |
neutral_hue="gray",
|
107 |
-
font=gr.themes.GoogleFont("Source Sans Pro"),
|
108 |
).set(
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
)
|
113 |
with gr.Blocks(css=css, theme=theme) as demo:
|
114 |
gr.HTML(
|
@@ -127,7 +157,8 @@ with gr.Blocks(css=css, theme=theme) as demo:
|
|
127 |
img = gr.Image(
|
128 |
label="輸入影像(不支援 SVG 格式)",
|
129 |
type="filepath",
|
130 |
-
|
|
|
131 |
)
|
132 |
gr.Label("範例影像", show_label=False)
|
133 |
with gr.Row():
|
@@ -163,7 +194,7 @@ with gr.Blocks(css=css, theme=theme) as demo:
|
|
163 |
seg = gr.Plot(label="語意分割")
|
164 |
pie = gr.Plot(label="元素面積比例")
|
165 |
|
166 |
-
start = gr.Button("
|
167 |
|
168 |
gr.HTML(
|
169 |
"""
|
@@ -180,6 +211,5 @@ with gr.Blocks(css=css, theme=theme) as demo:
|
|
180 |
ex2.select(fn=choose_example, inputs=ex2, outputs=img)
|
181 |
ex3.select(fn=choose_example, inputs=ex3, outputs=img)
|
182 |
|
183 |
-
|
184 |
if __name__ == "__main__":
|
185 |
demo.launch()
|
|
|
7 |
from PIL import Image
|
8 |
|
9 |
|
10 |
+
plt.rcParams['figure.facecolor'] = '#0b0f19'
|
11 |
+
plt.rcParams['text.color'] = '#aab6cc'
|
12 |
ladeco = Ladeco()
|
13 |
|
14 |
|
|
|
32 |
|
33 |
pie = plot_pie(l2_area, colors=colors)
|
34 |
|
35 |
+
seg.set_dpi(96)
|
36 |
+
seg.set_size_inches(256/96, 256/96) # 256px x 256px
|
37 |
+
|
38 |
+
pie.set_dpi(96)
|
39 |
+
pie.set_size_inches(256/96, 256/96) # 256px x 256px
|
40 |
+
|
41 |
return seg, pie
|
42 |
|
43 |
|
|
|
105 |
}
|
106 |
.example-image {
|
107 |
height: 220px;
|
108 |
+
padding: 25px;
|
109 |
}
|
110 |
""".strip()
|
111 |
theme = gr.themes.Base(
|
112 |
primary_hue="orange",
|
113 |
+
secondary_hue="cyan",
|
114 |
neutral_hue="gray",
|
|
|
115 |
).set(
|
116 |
+
body_text_color='*neutral_100',
|
117 |
+
body_text_color_subdued='*neutral_600',
|
118 |
+
background_fill_primary='*neutral_950',
|
119 |
+
background_fill_secondary='*neutral_600',
|
120 |
+
border_color_accent='*secondary_800',
|
121 |
+
color_accent='*primary_50',
|
122 |
+
color_accent_soft='*secondary_800',
|
123 |
+
code_background_fill='*neutral_700',
|
124 |
+
block_background_fill_dark='*body_background_fill',
|
125 |
+
block_info_text_color='#6b7280',
|
126 |
+
block_label_text_color='*neutral_300',
|
127 |
+
block_label_text_weight='700',
|
128 |
+
block_title_text_color='*block_label_text_color',
|
129 |
+
block_title_text_weight='300',
|
130 |
+
panel_background_fill='*neutral_800',
|
131 |
+
table_text_color_dark='*secondary_800',
|
132 |
+
checkbox_background_color_selected='*primary_500',
|
133 |
+
checkbox_label_background_fill='*neutral_500',
|
134 |
+
checkbox_label_background_fill_hover='*neutral_700',
|
135 |
+
checkbox_label_text_color='*neutral_200',
|
136 |
+
input_background_fill='*neutral_700',
|
137 |
+
input_background_fill_focus='*neutral_600',
|
138 |
+
slider_color='*primary_500',
|
139 |
+
table_even_background_fill='*neutral_700',
|
140 |
+
table_odd_background_fill='*neutral_600',
|
141 |
+
table_row_focus='*neutral_800'
|
142 |
)
|
143 |
with gr.Blocks(css=css, theme=theme) as demo:
|
144 |
gr.HTML(
|
|
|
157 |
img = gr.Image(
|
158 |
label="輸入影像(不支援 SVG 格式)",
|
159 |
type="filepath",
|
160 |
+
height="256px",
|
161 |
+
#elem_classes="selected-image",
|
162 |
)
|
163 |
gr.Label("範例影像", show_label=False)
|
164 |
with gr.Row():
|
|
|
194 |
seg = gr.Plot(label="語意分割")
|
195 |
pie = gr.Plot(label="元素面積比例")
|
196 |
|
197 |
+
start = gr.Button("開始", variant="primary")
|
198 |
|
199 |
gr.HTML(
|
200 |
"""
|
|
|
211 |
ex2.select(fn=choose_example, inputs=ex2, outputs=img)
|
212 |
ex3.select(fn=choose_example, inputs=ex3, outputs=img)
|
213 |
|
|
|
214 |
if __name__ == "__main__":
|
215 |
demo.launch()
|