Spaces:
Running
Running
Nattapong Tapachoom
commited on
Commit
·
7cc22de
1
Parent(s):
3ff354c
Refactor CSS for modern minimal design and improved responsiveness in Gradio app
Browse files
app.py
CHANGED
|
@@ -157,48 +157,82 @@ def analyze_text(text: str, model_name: str) -> str:
|
|
| 157 |
|
| 158 |
return "\n".join(results)
|
| 159 |
|
| 160 |
-
#
|
| 161 |
CUSTOM_CSS = """
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
| 172 |
.main-card {
|
| 173 |
-
background:
|
| 174 |
-
border-radius:
|
| 175 |
-
box-shadow: 0
|
| 176 |
-
padding: 24px;
|
| 177 |
-
margin:
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
}
|
| 180 |
.output-markdown {
|
| 181 |
font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif !important;
|
| 182 |
-
line-height: 1.
|
|
|
|
| 183 |
}
|
| 184 |
.gr-button {
|
| 185 |
-
font-size: 1.
|
| 186 |
-
padding: 0.
|
| 187 |
-
border-radius:
|
| 188 |
font-weight: 600;
|
| 189 |
-
transition: all 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
}
|
| 191 |
.gr-button:hover {
|
| 192 |
-
transform: translateY(-2px);
|
| 193 |
-
box-shadow: 0
|
|
|
|
| 194 |
}
|
| 195 |
.gr-textbox textarea {
|
| 196 |
-
font-size: 1.
|
| 197 |
-
min-height:
|
| 198 |
font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
}
|
| 200 |
.gr-dropdown input {
|
| 201 |
font-size: 1.1em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
}
|
| 203 |
"""
|
| 204 |
|
|
@@ -210,9 +244,9 @@ with gr.Blocks(
|
|
| 210 |
) as demo:
|
| 211 |
|
| 212 |
gr.Markdown("""
|
| 213 |
-
<div style="text-align: center; padding:
|
| 214 |
-
<h1 style="font-size:
|
| 215 |
-
<div style="font-size:1.
|
| 216 |
AI วิเคราะห์ความรู้สึกในข้อความภาษาไทย รองรับหลายโมเดลและหลายประโยค
|
| 217 |
</div>
|
| 218 |
</div>
|
|
@@ -222,8 +256,8 @@ with gr.Blocks(
|
|
| 222 |
with gr.Column(scale=1):
|
| 223 |
gr.Markdown("""
|
| 224 |
<div class='main-card'>
|
| 225 |
-
<h3 style='color:#
|
| 226 |
-
<p style='color:#666; font-size:0.
|
| 227 |
</div>
|
| 228 |
""")
|
| 229 |
|
|
@@ -236,8 +270,8 @@ with gr.Blocks(
|
|
| 236 |
|
| 237 |
gr.Markdown("""
|
| 238 |
<div class='main-card' style='margin-top:20px;'>
|
| 239 |
-
<h3 style='color:#
|
| 240 |
-
<ul style='color:#
|
| 241 |
<li>พิมพ์ข้อความภาษาไทยที่ต้องการวิเคราะห์</li>
|
| 242 |
<li>แยกประโยคด้วยจุด (.) หรือขึ้นบรรทัดใหม่</li>
|
| 243 |
<li>รองรับการวิเคราะห์หลายประโยคพร้อมกัน</li>
|
|
@@ -249,7 +283,7 @@ with gr.Blocks(
|
|
| 249 |
with gr.Column(scale=2):
|
| 250 |
gr.Markdown("""
|
| 251 |
<div class='main-card'>
|
| 252 |
-
<h3 style='color:#
|
| 253 |
</div>
|
| 254 |
""")
|
| 255 |
|
|
@@ -286,27 +320,27 @@ with gr.Blocks(
|
|
| 286 |
|
| 287 |
# Sentiment legend with enhanced styling
|
| 288 |
gr.Markdown("""
|
| 289 |
-
<div class='main-card' style='margin-top:30px; background:
|
| 290 |
-
<h3 style='color:#
|
| 291 |
-
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap:
|
| 292 |
-
<div style="text-align: center; padding:
|
| 293 |
-
<div style="font-size:
|
| 294 |
-
<strong style="color: #4CAF50; font-size: 1.
|
| 295 |
<small style="color: #666;">ความรู้สึกเชิงบวก<br>ดี, สุข, ชอบ</small>
|
| 296 |
</div>
|
| 297 |
-
<div style="text-align: center; padding:
|
| 298 |
-
<div style="font-size:
|
| 299 |
-
<strong style="color: #F44336; font-size: 1.
|
| 300 |
<small style="color: #666;">ความรู้สึกเชิงลบ<br>เศร้า, โกรธ, ไม่ชอบ</small>
|
| 301 |
</div>
|
| 302 |
-
<div style="text-align: center; padding:
|
| 303 |
-
<div style="font-size:
|
| 304 |
-
<strong style="color: #FF9800; font-size: 1.
|
| 305 |
<small style="color: #666;">ความรู้สึกเป็นกลาง<br>ปกติ, พอใช้ได้</small>
|
| 306 |
</div>
|
| 307 |
-
<div style="text-align: center; padding:
|
| 308 |
-
<div style="font-size:
|
| 309 |
-
<strong style="color: #2196F3; font-size: 1.
|
| 310 |
<small style="color: #666;">ประโยคคำถาม<br>อะไร, ไหน, เมื่อไหร่</small>
|
| 311 |
</div>
|
| 312 |
</div>
|
|
|
|
| 157 |
|
| 158 |
return "\n".join(results)
|
| 159 |
|
| 160 |
+
# Modern minimal CSS
|
| 161 |
CUSTOM_CSS = """
|
| 162 |
+
body, .gradio-container {
|
| 163 |
+
background: #f7faff !important;
|
| 164 |
+
}
|
| 165 |
+
.gradio-container {
|
| 166 |
+
max-width: 1100px !important;
|
| 167 |
+
margin: 32px auto 32px auto !important;
|
| 168 |
+
border-radius: 22px !important;
|
| 169 |
+
box-shadow: 0 8px 32px 0 #bdbdbd33;
|
| 170 |
+
border: 1.5px solid #e3e3e3;
|
| 171 |
+
min-height: 96vh;
|
| 172 |
+
padding-bottom: 32px;
|
| 173 |
+
}
|
| 174 |
.main-card {
|
| 175 |
+
background: #fff;
|
| 176 |
+
border-radius: 18px;
|
| 177 |
+
box-shadow: 0 2px 12px 0 #bdbdbd22;
|
| 178 |
+
padding: 28px 24px 20px 24px;
|
| 179 |
+
margin: 18px 0;
|
| 180 |
+
border: 1px solid #e6e6e6;
|
| 181 |
+
transition: box-shadow 0.2s;
|
| 182 |
+
}
|
| 183 |
+
.main-card:hover {
|
| 184 |
+
box-shadow: 0 6px 24px 0 #bdbdbd44;
|
| 185 |
}
|
| 186 |
.output-markdown {
|
| 187 |
font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif !important;
|
| 188 |
+
line-height: 1.7;
|
| 189 |
+
font-size: 1.08em;
|
| 190 |
}
|
| 191 |
.gr-button {
|
| 192 |
+
font-size: 1.13em;
|
| 193 |
+
padding: 0.9em 2.7em;
|
| 194 |
+
border-radius: 13px;
|
| 195 |
font-weight: 600;
|
| 196 |
+
transition: all 0.2s;
|
| 197 |
+
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
| 198 |
+
color: #fff;
|
| 199 |
+
border: none;
|
| 200 |
+
box-shadow: 0 2px 8px #bdbdbd22;
|
| 201 |
+
}
|
| 202 |
+
.gr-button.secondary, .gr-button[variant="secondary"] {
|
| 203 |
+
background: #f3f3f3;
|
| 204 |
+
color: #4a4a7d;
|
| 205 |
+
border: 1px solid #e0e0e0;
|
| 206 |
}
|
| 207 |
.gr-button:hover {
|
| 208 |
+
transform: translateY(-2px) scale(1.03);
|
| 209 |
+
box-shadow: 0 6px 18px #bdbdbd33;
|
| 210 |
+
filter: brightness(1.04);
|
| 211 |
}
|
| 212 |
.gr-textbox textarea {
|
| 213 |
+
font-size: 1.13em;
|
| 214 |
+
min-height: 150px;
|
| 215 |
font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif;
|
| 216 |
+
background: #fafdff;
|
| 217 |
+
border-radius: 10px;
|
| 218 |
+
border: 1.2px solid #e0e0e0;
|
| 219 |
+
padding: 14px;
|
| 220 |
}
|
| 221 |
.gr-dropdown input {
|
| 222 |
font-size: 1.1em;
|
| 223 |
+
border-radius: 8px;
|
| 224 |
+
background: #fafdff;
|
| 225 |
+
border: 1.2px solid #e0e0e0;
|
| 226 |
+
}
|
| 227 |
+
.gr-markdown h1, .gr-markdown h3 {
|
| 228 |
+
color: #3b3b6d !important;
|
| 229 |
+
}
|
| 230 |
+
.gr-markdown ul {
|
| 231 |
+
margin-left: 1.2em;
|
| 232 |
+
}
|
| 233 |
+
@media (max-width: 900px) {
|
| 234 |
+
.gradio-container { max-width: 99vw !important; padding: 0 2vw; }
|
| 235 |
+
.main-card { padding: 16px 6px; }
|
| 236 |
}
|
| 237 |
"""
|
| 238 |
|
|
|
|
| 244 |
) as demo:
|
| 245 |
|
| 246 |
gr.Markdown("""
|
| 247 |
+
<div style="text-align: center; padding: 38px 0 18px 0;">
|
| 248 |
+
<h1 style="font-size:2.7em; margin-bottom: 0.18em; color:#3b3b6d; letter-spacing:0.5px;">🧠 Thai Sentiment Analyzer</h1>
|
| 249 |
+
<div style="font-size:1.18em; color:#4a4a7d; opacity:0.92;">
|
| 250 |
AI วิเคราะห์ความรู้สึกในข้อความภาษาไทย รองรับหลายโมเดลและหลายประโยค
|
| 251 |
</div>
|
| 252 |
</div>
|
|
|
|
| 256 |
with gr.Column(scale=1):
|
| 257 |
gr.Markdown("""
|
| 258 |
<div class='main-card'>
|
| 259 |
+
<h3 style='color:#3b3b6d; margin-bottom:15px; font-size:1.18em;'>🤖 เลือกโมเดลวิเคราะห์</h3>
|
| 260 |
+
<p style='color:#666; font-size:0.97em; margin-bottom:10px;'>เลือกโมเดล AI ที่ต้องการใช้ในการวิเคราะห์ความรู้สึก</p>
|
| 261 |
</div>
|
| 262 |
""")
|
| 263 |
|
|
|
|
| 270 |
|
| 271 |
gr.Markdown("""
|
| 272 |
<div class='main-card' style='margin-top:20px;'>
|
| 273 |
+
<h3 style='color:#3b3b6d; margin-bottom:15px; font-size:1.13em;'>📖 คำแนะนำการใช้งาน</h3>
|
| 274 |
+
<ul style='color:#555; font-size:1em; line-height:1.7; margin-bottom:0;'>
|
| 275 |
<li>พิมพ์ข้อความภาษาไทยที่ต้องการวิเคราะห์</li>
|
| 276 |
<li>แยกประโยคด้วยจุด (.) หรือขึ้นบรรทัดใหม่</li>
|
| 277 |
<li>รองรับการวิเคราะห์หลายประโยคพร้อมกัน</li>
|
|
|
|
| 283 |
with gr.Column(scale=2):
|
| 284 |
gr.Markdown("""
|
| 285 |
<div class='main-card'>
|
| 286 |
+
<h3 style='color:#3b3b6d; margin-bottom:15px; font-size:1.15em;'>📝 ข้อความที่ต้องการวิเคราะห์</h3>
|
| 287 |
</div>
|
| 288 |
""")
|
| 289 |
|
|
|
|
| 320 |
|
| 321 |
# Sentiment legend with enhanced styling
|
| 322 |
gr.Markdown("""
|
| 323 |
+
<div class='main-card' style='margin-top:30px; background: #fafdff;'>
|
| 324 |
+
<h3 style='color:#3b3b6d; text-align:center; margin-bottom:20px;'>🎯 คำอธิบายผลการวิเคราะห์</h3>
|
| 325 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; padding: 12px 0;">
|
| 326 |
+
<div style="text-align: center; padding: 13px; background: rgba(76, 175, 80, 0.08); border-radius: 11px;">
|
| 327 |
+
<div style="font-size: 26px; margin-bottom: 7px;">😊</div>
|
| 328 |
+
<strong style="color: #4CAF50; font-size: 1.08em;">Positive</strong><br>
|
| 329 |
<small style="color: #666;">ความรู้สึกเชิงบวก<br>ดี, สุข, ชอบ</small>
|
| 330 |
</div>
|
| 331 |
+
<div style="text-align: center; padding: 13px; background: rgba(244, 67, 54, 0.08); border-radius: 11px;">
|
| 332 |
+
<div style="font-size: 26px; margin-bottom: 7px;">😔</div>
|
| 333 |
+
<strong style="color: #F44336; font-size: 1.08em;">Negative</strong><br>
|
| 334 |
<small style="color: #666;">ความรู้สึกเชิงลบ<br>เศร้า, โกรธ, ไม่ชอบ</small>
|
| 335 |
</div>
|
| 336 |
+
<div style="text-align: center; padding: 13px; background: rgba(255, 152, 0, 0.08); border-radius: 11px;">
|
| 337 |
+
<div style="font-size: 26px; margin-bottom: 7px;">😐</div>
|
| 338 |
+
<strong style="color: #FF9800; font-size: 1.08em;">Neutral</strong><br>
|
| 339 |
<small style="color: #666;">ความรู้สึกเป็นกลาง<br>ปกติ, พอใช้ได้</small>
|
| 340 |
</div>
|
| 341 |
+
<div style="text-align: center; padding: 13px; background: rgba(33, 150, 243, 0.08); border-radius: 11px;">
|
| 342 |
+
<div style="font-size: 26px; margin-bottom: 7px;">❓</div>
|
| 343 |
+
<strong style="color: #2196F3; font-size: 1.08em;">Question</strong><br>
|
| 344 |
<small style="color: #666;">ประโยคคำถาม<br>อะไร, ไหน, เมื่อไหร่</small>
|
| 345 |
</div>
|
| 346 |
</div>
|