Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -365,6 +365,150 @@ html, body, .gradio-container {
|
|
| 365 |
border-color: rgba(148,163,184,.24) !important;
|
| 366 |
}
|
| 367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
@media (max-width: 900px) {
|
| 369 |
.hero-card { padding: 28px 20px; }
|
| 370 |
.metric-grid { grid-template-columns: 1fr; }
|
|
@@ -549,29 +693,32 @@ with gr.Blocks(
|
|
| 549 |
|
| 550 |
with gr.Row(equal_height=False):
|
| 551 |
with gr.Column(scale=5, min_width=360):
|
| 552 |
-
with gr.Group(elem_classes=["glass-card"]):
|
| 553 |
gr.HTML('<h3 class="card-title">Upload MRI Image</h3>')
|
| 554 |
image_input = gr.Image(
|
| 555 |
label="Upload MRI Image",
|
| 556 |
show_label=False,
|
| 557 |
type="pil",
|
| 558 |
-
height=
|
| 559 |
sources=["upload", "clipboard"],
|
|
|
|
| 560 |
)
|
| 561 |
heatmap_toggle = gr.Checkbox(
|
| 562 |
value=False,
|
| 563 |
label="Generate optional heatmap",
|
| 564 |
info=None,
|
|
|
|
| 565 |
)
|
| 566 |
run_button = gr.Button("Run Prediction", variant="primary", elem_id="run_button")
|
| 567 |
|
| 568 |
-
with gr.Group(elem_classes=["glass-card"]):
|
| 569 |
gr.HTML('<h3 class="card-title">Optional Heatmap</h3>')
|
| 570 |
heatmap_output = gr.Image(
|
| 571 |
label="Optional Heatmap",
|
| 572 |
show_label=False,
|
| 573 |
type="pil",
|
| 574 |
-
height=
|
|
|
|
| 575 |
)
|
| 576 |
|
| 577 |
with gr.Column(scale=7, min_width=420):
|
|
|
|
| 365 |
border-color: rgba(148,163,184,.24) !important;
|
| 366 |
}
|
| 367 |
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
/* Fix heatmap checkbox: the dark theme was hiding the checked mark. */
|
| 371 |
+
#heatmap_checkbox {
|
| 372 |
+
margin-top: 18px !important;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
#heatmap_checkbox label {
|
| 376 |
+
min-height: 58px !important;
|
| 377 |
+
padding: 16px 18px !important;
|
| 378 |
+
border-radius: 18px !important;
|
| 379 |
+
background: rgba(255,255,255,.055) !important;
|
| 380 |
+
border: 1px solid rgba(148,163,184,.22) !important;
|
| 381 |
+
display: flex !important;
|
| 382 |
+
align-items: center !important;
|
| 383 |
+
gap: 12px !important;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
#heatmap_checkbox input[type="checkbox"] {
|
| 387 |
+
appearance: none !important;
|
| 388 |
+
-webkit-appearance: none !important;
|
| 389 |
+
width: 26px !important;
|
| 390 |
+
height: 26px !important;
|
| 391 |
+
min-width: 26px !important;
|
| 392 |
+
border-radius: 8px !important;
|
| 393 |
+
background: rgba(2,6,23,.85) !important;
|
| 394 |
+
border: 2px solid rgba(148,163,184,.65) !important;
|
| 395 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,.08) !important;
|
| 396 |
+
cursor: pointer !important;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
#heatmap_checkbox input[type="checkbox"]:checked {
|
| 400 |
+
background-color: #8b5cf6 !important;
|
| 401 |
+
border-color: #c4b5fd !important;
|
| 402 |
+
background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.2 10.4L8.1 14.2L15.9 5.8' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
|
| 403 |
+
background-repeat: no-repeat !important;
|
| 404 |
+
background-position: center !important;
|
| 405 |
+
background-size: 18px 18px !important;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
#heatmap_checkbox input[type="checkbox"]:focus-visible {
|
| 409 |
+
outline: 3px solid rgba(139,92,246,.45) !important;
|
| 410 |
+
outline-offset: 3px !important;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
#heatmap_checkbox span,
|
| 414 |
+
#heatmap_checkbox label span {
|
| 415 |
+
color: var(--ink) !important;
|
| 416 |
+
font-weight: 780 !important;
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
/* Pixel-lock the MRI upload and Grad-CAM panels so they fill the full card width. */
|
| 420 |
+
#mri_upload,
|
| 421 |
+
#heatmap_preview {
|
| 422 |
+
width: 100% !important;
|
| 423 |
+
max-width: 100% !important;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
#mri_upload *,
|
| 427 |
+
#heatmap_preview * {
|
| 428 |
+
box-sizing: border-box !important;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
#mri_upload .wrap,
|
| 432 |
+
#heatmap_preview .wrap,
|
| 433 |
+
#mri_upload .image-container,
|
| 434 |
+
#heatmap_preview .image-container,
|
| 435 |
+
#mri_upload .upload-container,
|
| 436 |
+
#heatmap_preview .upload-container,
|
| 437 |
+
#mri_upload [data-testid="image"],
|
| 438 |
+
#heatmap_preview [data-testid="image"],
|
| 439 |
+
#mri_upload .empty,
|
| 440 |
+
#heatmap_preview .empty {
|
| 441 |
+
width: 100% !important;
|
| 442 |
+
max-width: 100% !important;
|
| 443 |
+
min-width: 100% !important;
|
| 444 |
+
border-radius: 24px !important;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
#mri_upload .wrap,
|
| 448 |
+
#mri_upload .image-container,
|
| 449 |
+
#mri_upload .upload-container,
|
| 450 |
+
#mri_upload [data-testid="image"],
|
| 451 |
+
#mri_upload .empty {
|
| 452 |
+
min-height: 520px !important;
|
| 453 |
+
height: 520px !important;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
#heatmap_preview .wrap,
|
| 457 |
+
#heatmap_preview .image-container,
|
| 458 |
+
#heatmap_preview .upload-container,
|
| 459 |
+
#heatmap_preview [data-testid="image"],
|
| 460 |
+
#heatmap_preview .empty {
|
| 461 |
+
min-height: 430px !important;
|
| 462 |
+
height: 430px !important;
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
#mri_upload img,
|
| 466 |
+
#heatmap_preview img {
|
| 467 |
+
width: 100% !important;
|
| 468 |
+
height: 100% !important;
|
| 469 |
+
object-fit: contain !important;
|
| 470 |
+
border-radius: 22px !important;
|
| 471 |
+
background: #020617 !important;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
#mri_upload button,
|
| 475 |
+
#heatmap_preview button {
|
| 476 |
+
width: 100% !important;
|
| 477 |
+
max-width: 100% !important;
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
#mri_upload .empty,
|
| 481 |
+
#heatmap_preview .empty {
|
| 482 |
+
display: flex !important;
|
| 483 |
+
align-items: center !important;
|
| 484 |
+
justify-content: center !important;
|
| 485 |
+
background:
|
| 486 |
+
radial-gradient(circle at 50% 45%, rgba(139,92,246,.13), transparent 38%),
|
| 487 |
+
linear-gradient(180deg, rgba(2,6,23,.98), rgba(8,13,29,.98)) !important;
|
| 488 |
+
border: 1px dashed rgba(148,163,184,.34) !important;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
#mri_upload .upload-text,
|
| 492 |
+
#heatmap_preview .upload-text,
|
| 493 |
+
#mri_upload .center,
|
| 494 |
+
#heatmap_preview .center {
|
| 495 |
+
width: 100% !important;
|
| 496 |
+
text-align: center !important;
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
/* The left card itself should not squeeze its child upload component. */
|
| 500 |
+
.upload-panel,
|
| 501 |
+
.heatmap-panel {
|
| 502 |
+
width: 100% !important;
|
| 503 |
+
min-width: 0 !important;
|
| 504 |
+
overflow: hidden !important;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
.upload-panel .form,
|
| 508 |
+
.heatmap-panel .form {
|
| 509 |
+
width: 100% !important;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
@media (max-width: 900px) {
|
| 513 |
.hero-card { padding: 28px 20px; }
|
| 514 |
.metric-grid { grid-template-columns: 1fr; }
|
|
|
|
| 693 |
|
| 694 |
with gr.Row(equal_height=False):
|
| 695 |
with gr.Column(scale=5, min_width=360):
|
| 696 |
+
with gr.Group(elem_classes=["glass-card", "upload-panel"]):
|
| 697 |
gr.HTML('<h3 class="card-title">Upload MRI Image</h3>')
|
| 698 |
image_input = gr.Image(
|
| 699 |
label="Upload MRI Image",
|
| 700 |
show_label=False,
|
| 701 |
type="pil",
|
| 702 |
+
height=520,
|
| 703 |
sources=["upload", "clipboard"],
|
| 704 |
+
elem_id="mri_upload",
|
| 705 |
)
|
| 706 |
heatmap_toggle = gr.Checkbox(
|
| 707 |
value=False,
|
| 708 |
label="Generate optional heatmap",
|
| 709 |
info=None,
|
| 710 |
+
elem_id="heatmap_checkbox",
|
| 711 |
)
|
| 712 |
run_button = gr.Button("Run Prediction", variant="primary", elem_id="run_button")
|
| 713 |
|
| 714 |
+
with gr.Group(elem_classes=["glass-card", "heatmap-panel"]):
|
| 715 |
gr.HTML('<h3 class="card-title">Optional Heatmap</h3>')
|
| 716 |
heatmap_output = gr.Image(
|
| 717 |
label="Optional Heatmap",
|
| 718 |
show_label=False,
|
| 719 |
type="pil",
|
| 720 |
+
height=430,
|
| 721 |
+
elem_id="heatmap_preview",
|
| 722 |
)
|
| 723 |
|
| 724 |
with gr.Column(scale=7, min_width=420):
|