Update app.py
Browse files
app.py
CHANGED
@@ -77,81 +77,77 @@ def draw_bar_chart(data: dict[str, list[str | float]]):
|
|
77 |
return plt
|
78 |
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
with gr.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
# )
|
151 |
-
|
152 |
-
return demo
|
153 |
|
154 |
|
155 |
if __name__ == "__main__":
|
156 |
-
|
157 |
-
app.queue().launch(server_name="0.0.0.0")
|
|
|
77 |
return plt
|
78 |
|
79 |
|
80 |
+
css = """
|
81 |
+
.main-title {
|
82 |
+
font-size: 24px;
|
83 |
+
font-weight: bold;
|
84 |
+
text-align: center;
|
85 |
+
margin-bottom: 20px;
|
86 |
+
}
|
87 |
+
.reference {
|
88 |
+
text-align: center;
|
89 |
+
font-size: 1.2em;
|
90 |
+
color: #d1d5db;
|
91 |
+
margin-bottom: 20px;
|
92 |
+
}
|
93 |
+
.reference a {
|
94 |
+
color: #FB923C;
|
95 |
+
text-decoration: none;
|
96 |
+
}
|
97 |
+
.reference a:hover {
|
98 |
+
text-decoration: underline;
|
99 |
+
color: #FB923C;
|
100 |
+
}
|
101 |
+
.title {
|
102 |
+
border-bottom: 1px solid;
|
103 |
+
}
|
104 |
+
.footer {
|
105 |
+
text-align: center;
|
106 |
+
margin-top: 30px;
|
107 |
+
padding-top: 20px;
|
108 |
+
border-top: 1px solid #ddd;
|
109 |
+
color: #d1d5db;
|
110 |
+
font-size: 14px;
|
111 |
+
}
|
112 |
+
"""
|
113 |
+
# theme = gr.themes.Base(
|
114 |
+
# primary_hue="orange",
|
115 |
+
# secondary_hue="orange",
|
116 |
+
# neutral_hue="gray",
|
117 |
+
# font=gr.themes.GoogleFont("Source Sans Pro"),
|
118 |
+
# ).set(
|
119 |
+
# background_fill_primary="*neutral_950", # 主背景色(深黑)
|
120 |
+
# button_primary_background_fill="*primary_500", # 按鈕顏色(橘色)
|
121 |
+
# body_text_color="*neutral_200", # 文字顏色(淺色)
|
122 |
+
# )
|
123 |
+
with gr.Blocks(css=css, theme='gstaff/xkcd') as demo:
|
124 |
+
with gr.Column():
|
125 |
+
gr.HTML(
|
126 |
+
value=(
|
127 |
+
'<div class="main-title">Litton7景觀分類模型</div>'
|
128 |
+
'<div class="reference">引用資料:'
|
129 |
+
'<a href="https://www.airitilibrary.com/Article/Detail/10125434-N202406210003-00003" target="_blank">'
|
130 |
+
"何立智、李沁築、邱浩修(2024)。Litton7:Litton視覺景觀分類深度學習模型。戶外遊憩研究,37(2)"
|
131 |
+
"</a>"
|
132 |
+
"</div>"
|
133 |
+
),
|
134 |
+
)
|
135 |
+
|
136 |
+
with gr.Row(equal_height=True):
|
137 |
+
image_input = gr.Image(label="上傳影像", type="pil")
|
138 |
+
bar_chart = gr.Plot(label="分類結果")
|
139 |
+
start_button = gr.Button("開始分類", variant="primary")
|
140 |
+
|
141 |
+
start_button.click(
|
142 |
+
fn=Classifier().predict,
|
143 |
+
inputs=image_input,
|
144 |
+
outputs=bar_chart,
|
145 |
+
)
|
146 |
+
|
147 |
+
gr.HTML(
|
148 |
+
'<div class="footer">© 2024 LCL 版權所有<br>開發者:何立智、楊哲睿</div>',
|
149 |
+
)
|
|
|
|
|
|
|
150 |
|
151 |
|
152 |
if __name__ == "__main__":
|
153 |
+
demo.queue().launch(server_name="0.0.0.0")
|
|