Siraja704
commited on
Commit
Β·
b8cabae
1
Parent(s):
5c6141b
Enhance UI with modern dark/light mode CSS
Browse files- Add comprehensive CSS variables for dynamic theming
- Implement automatic dark/light mode detection using prefers-color-scheme
- Improve text visibility and contrast in both modes
- Add modern Inter font family and smooth transitions
- Style all components (medical disclaimers, info boxes, buttons, etc.)
- Create responsive grid layout for conditions section
- Add hover effects and better visual hierarchy
- Improve accessibility and readability across all themes
- Update Gradio theme configuration for better integration
Features:
- Automatic system theme detection
- Improved contrast ratios for accessibility
- Modern card-based design with shadows
- Consistent color scheme throughout the interface
- Better mobile responsiveness
app.py
CHANGED
|
@@ -156,28 +156,242 @@ def get_medical_advice(image):
|
|
| 156 |
|
| 157 |
return advice
|
| 158 |
|
| 159 |
-
# Custom CSS for better styling
|
| 160 |
custom_css = """
|
|
|
|
| 161 |
.gradio-container {
|
| 162 |
-
font-family: '
|
| 163 |
max-width: 1200px;
|
| 164 |
margin: 0 auto;
|
|
|
|
| 165 |
}
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
.medical-disclaimer {
|
| 168 |
-
background-color:
|
| 169 |
-
border:
|
| 170 |
-
border-radius:
|
| 171 |
-
padding:
|
| 172 |
-
margin:
|
| 173 |
-
color:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
}
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
.prediction-box {
|
| 177 |
-
background-color:
|
| 178 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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with gr.Blocks(
|
| 186 |
css=custom_css,
|
| 187 |
title="DermaAI - Skin Disease Classification",
|
| 188 |
-
theme=gr.themes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
) as demo:
|
| 190 |
|
| 191 |
gr.HTML("""
|
| 192 |
-
<div
|
| 193 |
<h1>π₯ DermaAI - Skin Disease Classification</h1>
|
| 194 |
-
<p
|
| 195 |
-
AI-powered skin condition analysis using deep learning
|
| 196 |
-
</p>
|
| 197 |
</div>
|
| 198 |
""")
|
| 199 |
|
|
@@ -208,7 +426,7 @@ with gr.Blocks(
|
|
| 208 |
|
| 209 |
with gr.Row():
|
| 210 |
with gr.Column(scale=1):
|
| 211 |
-
gr.HTML("<h3>πΈ Upload Skin Image</h3>")
|
| 212 |
input_image = gr.Image(
|
| 213 |
type="pil",
|
| 214 |
label="Upload a clear image of the skin condition",
|
|
@@ -216,7 +434,7 @@ with gr.Blocks(
|
|
| 216 |
)
|
| 217 |
|
| 218 |
gr.HTML("""
|
| 219 |
-
<div
|
| 220 |
<h4>π Image Guidelines:</h4>
|
| 221 |
<ul>
|
| 222 |
<li>Use good lighting and focus</li>
|
|
@@ -228,7 +446,7 @@ with gr.Blocks(
|
|
| 228 |
""")
|
| 229 |
|
| 230 |
with gr.Column(scale=1):
|
| 231 |
-
gr.HTML("<h3>π Analysis Results</h3>")
|
| 232 |
|
| 233 |
prediction_output = gr.Label(
|
| 234 |
label="Prediction Confidence Scores",
|
|
@@ -241,14 +459,14 @@ with gr.Blocks(
|
|
| 241 |
)
|
| 242 |
|
| 243 |
gr.HTML("""
|
| 244 |
-
<div
|
| 245 |
<h3>π©Ί Supported Skin Conditions</h3>
|
| 246 |
-
<div
|
| 247 |
-
<div><strong>Atopic Dermatitis:</strong> Chronic inflammatory skin condition</div>
|
| 248 |
-
<div><strong>Eczema:</strong> Red, itchy, inflamed skin patches</div>
|
| 249 |
-
<div><strong>Psoriasis:</strong> Thick, scaly skin patches</div>
|
| 250 |
-
<div><strong>Seborrheic Keratoses:</strong> Benign skin growths</div>
|
| 251 |
-
<div><strong>Tinea Ringworm Candidiasis:</strong> Fungal skin infections</div>
|
| 252 |
</div>
|
| 253 |
</div>
|
| 254 |
""")
|
|
@@ -267,7 +485,7 @@ with gr.Blocks(
|
|
| 267 |
)
|
| 268 |
|
| 269 |
gr.HTML("""
|
| 270 |
-
<div
|
| 271 |
<h3>π About DermaAI</h3>
|
| 272 |
<p>DermaAI is built using EfficientNetV2 architecture and trained on dermatological images.
|
| 273 |
The model analyzes skin images and provides confidence scores for 5 different skin conditions.</p>
|
|
|
|
| 156 |
|
| 157 |
return advice
|
| 158 |
|
| 159 |
+
# Custom CSS for better styling with dark/light mode support
|
| 160 |
custom_css = """
|
| 161 |
+
/* System theme detection and base styling */
|
| 162 |
.gradio-container {
|
| 163 |
+
font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
|
| 164 |
max-width: 1200px;
|
| 165 |
margin: 0 auto;
|
| 166 |
+
transition: all 0.3s ease;
|
| 167 |
}
|
| 168 |
|
| 169 |
+
/* Light mode (default) */
|
| 170 |
+
:root {
|
| 171 |
+
--bg-primary: #ffffff;
|
| 172 |
+
--bg-secondary: #f8f9fa;
|
| 173 |
+
--bg-accent: #e3f2fd;
|
| 174 |
+
--bg-warning: #fff3cd;
|
| 175 |
+
--text-primary: #212529;
|
| 176 |
+
--text-secondary: #6c757d;
|
| 177 |
+
--text-accent: #0d47a1;
|
| 178 |
+
--text-warning: #856404;
|
| 179 |
+
--border-color: #dee2e6;
|
| 180 |
+
--border-accent: #90caf9;
|
| 181 |
+
--border-warning: #ffeaa7;
|
| 182 |
+
--shadow: rgba(0, 0, 0, 0.1);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/* Dark mode */
|
| 186 |
+
@media (prefers-color-scheme: dark) {
|
| 187 |
+
:root {
|
| 188 |
+
--bg-primary: #1a1a1a;
|
| 189 |
+
--bg-secondary: #2d2d2d;
|
| 190 |
+
--bg-accent: #1e3a8a;
|
| 191 |
+
--bg-warning: #4d3800;
|
| 192 |
+
--text-primary: #f8f9fa;
|
| 193 |
+
--text-secondary: #adb5bd;
|
| 194 |
+
--text-accent: #90caf9;
|
| 195 |
+
--text-warning: #ffd60a;
|
| 196 |
+
--border-color: #495057;
|
| 197 |
+
--border-accent: #1976d2;
|
| 198 |
+
--border-warning: #b8860b;
|
| 199 |
+
--shadow: rgba(255, 255, 255, 0.1);
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/* Medical disclaimer styling */
|
| 204 |
.medical-disclaimer {
|
| 205 |
+
background-color: var(--bg-warning);
|
| 206 |
+
border: 2px solid var(--border-warning);
|
| 207 |
+
border-radius: 12px;
|
| 208 |
+
padding: 20px;
|
| 209 |
+
margin: 15px 0;
|
| 210 |
+
color: var(--text-warning);
|
| 211 |
+
box-shadow: 0 4px 6px var(--shadow);
|
| 212 |
+
transition: all 0.3s ease;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.medical-disclaimer h3 {
|
| 216 |
+
color: var(--text-warning);
|
| 217 |
+
margin-top: 0;
|
| 218 |
+
font-weight: 600;
|
| 219 |
}
|
| 220 |
|
| 221 |
+
.medical-disclaimer p {
|
| 222 |
+
color: var(--text-warning);
|
| 223 |
+
margin-bottom: 0;
|
| 224 |
+
line-height: 1.5;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/* Prediction box styling */
|
| 228 |
.prediction-box {
|
| 229 |
+
background-color: var(--bg-secondary);
|
| 230 |
+
border-radius: 12px;
|
| 231 |
+
padding: 20px;
|
| 232 |
+
margin: 15px 0;
|
| 233 |
+
border: 1px solid var(--border-color);
|
| 234 |
+
box-shadow: 0 4px 6px var(--shadow);
|
| 235 |
+
transition: all 0.3s ease;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/* Info boxes */
|
| 239 |
+
.info-box {
|
| 240 |
+
background-color: var(--bg-accent);
|
| 241 |
+
border: 2px solid var(--border-accent);
|
| 242 |
+
border-radius: 12px;
|
| 243 |
+
padding: 20px;
|
| 244 |
+
margin: 15px 0;
|
| 245 |
+
color: var(--text-accent);
|
| 246 |
+
box-shadow: 0 4px 6px var(--shadow);
|
| 247 |
+
transition: all 0.3s ease;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.info-box h3, .info-box h4 {
|
| 251 |
+
color: var(--text-accent);
|
| 252 |
+
margin-top: 0;
|
| 253 |
+
font-weight: 600;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.info-box p, .info-box li {
|
| 257 |
+
color: var(--text-accent);
|
| 258 |
+
line-height: 1.5;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
/* About section */
|
| 262 |
+
.about-section {
|
| 263 |
+
background-color: var(--bg-secondary);
|
| 264 |
+
border-radius: 12px;
|
| 265 |
+
padding: 25px;
|
| 266 |
+
margin-top: 30px;
|
| 267 |
+
border: 1px solid var(--border-color);
|
| 268 |
+
box-shadow: 0 4px 6px var(--shadow);
|
| 269 |
+
transition: all 0.3s ease;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.about-section h3 {
|
| 273 |
+
color: var(--text-primary);
|
| 274 |
+
margin-top: 0;
|
| 275 |
+
font-weight: 600;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
.about-section p {
|
| 279 |
+
color: var(--text-secondary);
|
| 280 |
+
line-height: 1.6;
|
| 281 |
+
margin-bottom: 10px;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.about-section a {
|
| 285 |
+
color: var(--text-accent);
|
| 286 |
+
text-decoration: none;
|
| 287 |
+
font-weight: 500;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.about-section a:hover {
|
| 291 |
+
text-decoration: underline;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
/* Main title styling */
|
| 295 |
+
.main-title {
|
| 296 |
+
text-align: center;
|
| 297 |
+
margin-bottom: 20px;
|
| 298 |
+
padding: 20px;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.main-title h1 {
|
| 302 |
+
color: var(--text-primary);
|
| 303 |
+
font-size: 2.5rem;
|
| 304 |
+
font-weight: 700;
|
| 305 |
+
margin-bottom: 10px;
|
| 306 |
+
text-shadow: 0 2px 4px var(--shadow);
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
.main-title p {
|
| 310 |
+
color: var(--text-secondary);
|
| 311 |
+
font-size: 1.2rem;
|
| 312 |
+
font-weight: 400;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/* Section headers */
|
| 316 |
+
.section-header {
|
| 317 |
+
color: var(--text-primary);
|
| 318 |
+
font-size: 1.4rem;
|
| 319 |
+
font-weight: 600;
|
| 320 |
+
margin-bottom: 15px;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
/* Conditions grid */
|
| 324 |
+
.conditions-grid {
|
| 325 |
+
display: grid;
|
| 326 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
| 327 |
+
gap: 15px;
|
| 328 |
+
margin-top: 15px;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.condition-item {
|
| 332 |
+
background-color: var(--bg-secondary);
|
| 333 |
padding: 15px;
|
| 334 |
+
border-radius: 8px;
|
| 335 |
+
border: 1px solid var(--border-color);
|
| 336 |
+
transition: all 0.3s ease;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
.condition-item:hover {
|
| 340 |
+
transform: translateY(-2px);
|
| 341 |
+
box-shadow: 0 6px 12px var(--shadow);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.condition-item strong {
|
| 345 |
+
color: var(--text-primary);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
.condition-item {
|
| 349 |
+
color: var(--text-secondary);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
/* Button and input styling improvements */
|
| 353 |
+
.gradio-container .gr-button {
|
| 354 |
+
background-color: var(--bg-accent);
|
| 355 |
+
color: var(--text-accent);
|
| 356 |
+
border: 2px solid var(--border-accent);
|
| 357 |
+
border-radius: 8px;
|
| 358 |
+
font-weight: 500;
|
| 359 |
+
transition: all 0.3s ease;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
.gradio-container .gr-button:hover {
|
| 363 |
+
transform: translateY(-1px);
|
| 364 |
+
box-shadow: 0 4px 8px var(--shadow);
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
/* Upload area styling */
|
| 368 |
+
.gradio-container .gr-file-upload {
|
| 369 |
+
border: 2px dashed var(--border-accent);
|
| 370 |
+
border-radius: 12px;
|
| 371 |
+
background-color: var(--bg-secondary);
|
| 372 |
+
transition: all 0.3s ease;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
.gradio-container .gr-file-upload:hover {
|
| 376 |
+
border-color: var(--text-accent);
|
| 377 |
+
background-color: var(--bg-accent);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
/* Results area styling */
|
| 381 |
+
.gradio-container .gr-label {
|
| 382 |
+
background-color: var(--bg-secondary);
|
| 383 |
+
border: 1px solid var(--border-color);
|
| 384 |
+
border-radius: 8px;
|
| 385 |
+
color: var(--text-primary);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
/* Ensure all text is visible */
|
| 389 |
+
* {
|
| 390 |
+
color: var(--text-primary);
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
p, span, div {
|
| 394 |
+
color: inherit;
|
| 395 |
}
|
| 396 |
"""
|
| 397 |
|
|
|
|
| 399 |
with gr.Blocks(
|
| 400 |
css=custom_css,
|
| 401 |
title="DermaAI - Skin Disease Classification",
|
| 402 |
+
theme=gr.themes.Base().set(
|
| 403 |
+
button_primary_background_fill="*primary_500",
|
| 404 |
+
button_primary_background_fill_hover="*primary_600",
|
| 405 |
+
button_primary_text_color="white",
|
| 406 |
+
block_background_fill="*background_fill_primary",
|
| 407 |
+
body_background_fill="*background_fill_primary",
|
| 408 |
+
)
|
| 409 |
) as demo:
|
| 410 |
|
| 411 |
gr.HTML("""
|
| 412 |
+
<div class="main-title">
|
| 413 |
<h1>π₯ DermaAI - Skin Disease Classification</h1>
|
| 414 |
+
<p>AI-powered skin condition analysis using deep learning</p>
|
|
|
|
|
|
|
| 415 |
</div>
|
| 416 |
""")
|
| 417 |
|
|
|
|
| 426 |
|
| 427 |
with gr.Row():
|
| 428 |
with gr.Column(scale=1):
|
| 429 |
+
gr.HTML("<h3 class='section-header'>πΈ Upload Skin Image</h3>")
|
| 430 |
input_image = gr.Image(
|
| 431 |
type="pil",
|
| 432 |
label="Upload a clear image of the skin condition",
|
|
|
|
| 434 |
)
|
| 435 |
|
| 436 |
gr.HTML("""
|
| 437 |
+
<div class="info-box">
|
| 438 |
<h4>π Image Guidelines:</h4>
|
| 439 |
<ul>
|
| 440 |
<li>Use good lighting and focus</li>
|
|
|
|
| 446 |
""")
|
| 447 |
|
| 448 |
with gr.Column(scale=1):
|
| 449 |
+
gr.HTML("<h3 class='section-header'>π Analysis Results</h3>")
|
| 450 |
|
| 451 |
prediction_output = gr.Label(
|
| 452 |
label="Prediction Confidence Scores",
|
|
|
|
| 459 |
)
|
| 460 |
|
| 461 |
gr.HTML("""
|
| 462 |
+
<div class="info-box">
|
| 463 |
<h3>π©Ί Supported Skin Conditions</h3>
|
| 464 |
+
<div class="conditions-grid">
|
| 465 |
+
<div class="condition-item"><strong>Atopic Dermatitis:</strong> Chronic inflammatory skin condition</div>
|
| 466 |
+
<div class="condition-item"><strong>Eczema:</strong> Red, itchy, inflamed skin patches</div>
|
| 467 |
+
<div class="condition-item"><strong>Psoriasis:</strong> Thick, scaly skin patches</div>
|
| 468 |
+
<div class="condition-item"><strong>Seborrheic Keratoses:</strong> Benign skin growths</div>
|
| 469 |
+
<div class="condition-item"><strong>Tinea Ringworm Candidiasis:</strong> Fungal skin infections</div>
|
| 470 |
</div>
|
| 471 |
</div>
|
| 472 |
""")
|
|
|
|
| 485 |
)
|
| 486 |
|
| 487 |
gr.HTML("""
|
| 488 |
+
<div class="about-section">
|
| 489 |
<h3>π About DermaAI</h3>
|
| 490 |
<p>DermaAI is built using EfficientNetV2 architecture and trained on dermatological images.
|
| 491 |
The model analyzes skin images and provides confidence scores for 5 different skin conditions.</p>
|