lichih commited on
Commit
5340fa1
·
verified ·
1 Parent(s): 58d19d8

Update app.py

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