File size: 5,679 Bytes
6fe482b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
"""EyeQC clinical theme + custom CSS."""

import gradio as gr

THEME = gr.themes.Soft(
    primary_hue=gr.themes.colors.teal,
    secondary_hue=gr.themes.colors.cyan,
    neutral_hue=gr.themes.colors.slate,
    font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
    font_mono=[gr.themes.GoogleFont("IBM Plex Mono"), "monospace"],
).set(
    body_background_fill="#070d11",
    block_background_fill="#0e1a20",
    block_border_width="1px",
    block_border_color="#1b2c34",
    block_radius="16px",
    block_label_text_color="#7fb8c4",
    block_title_text_color="#d7e2e6",
    button_primary_background_fill="linear-gradient(92deg,#0b6b7d,#22a5b8)",
    button_primary_background_fill_hover="linear-gradient(92deg,#0b7c90,#2bbad0)",
    button_primary_text_color="#ffffff",
    body_text_color="#cdd9dd",
)

CSS = """
:root { --ink:#eaf2f4; --teal:#2aa5b8; --deep:#0b3c49; --muted:#7f97a0;
        --line:#1b2c34; --panel:#0e1a20; }
.gradio-container { max-width: 1440px !important; margin: 0 auto !important; }
#hero {
  background:
    radial-gradient(900px 240px at 88% -30%, rgba(42,165,184,.22), transparent 60%),
    linear-gradient(120deg, #0f4a58 0%, #0a3a45 40%, #082730 75%, #061a20 100%);
  border:1px solid #14343d; border-radius:22px; padding:28px 32px; margin-bottom:14px;
  box-shadow:0 14px 50px rgba(0,0,0,.45);
}
#hero .brand { display:flex; align-items:center; gap:14px; }
#hero .logo { width:44px; height:44px; border-radius:12px; flex:none;
  background:linear-gradient(135deg,#22a5b8,#0b6b7d);
  box-shadow:0 6px 18px rgba(34,165,184,.4);
  display:flex; align-items:center; justify-content:center; font-size:24px; }
#hero h1 { font-size:32px; font-weight:800; letter-spacing:-.6px; margin:0; color:#fff; }
#hero .tag { font-size:12px; color:#8fd0da; letter-spacing:2px; text-transform:uppercase;
  margin:3px 0 0 0; font-weight:600; }
#hero .sub { color:#9fc2c8; font-size:14px; margin:12px 0 0 0; max-width:980px; line-height:1.55; }
#hero .pill { display:inline-block; background:rgba(42,165,184,.10);
  border:1px solid rgba(42,165,184,.28); color:#bfe4ea; font-size:11.5px;
  padding:5px 12px; border-radius:999px; margin:12px 8px 0 0; }
.section-title { font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:1.4px; color:var(--teal); margin:8px 0 4px 2px; }
.verdict-card { border-radius:16px; padding:18px 20px; color:#fff; font-weight:700;
  text-align:center; box-shadow:0 8px 24px rgba(0,0,0,.3); }
.verdict-PASS { background:linear-gradient(135deg,#1f9d61,#0f6b43); }
.verdict-ACCEPTABLE { background:linear-gradient(135deg,#d69e2e,#9c7012); }
.verdict-FAIL { background:linear-gradient(135deg,#e05252,#a82f2f); }
.verdict-card .big { font-size:36px; line-height:1; }
.verdict-card .sm { font-size:12px; font-weight:500; opacity:.92; }
.chip { display:inline-block; padding:6px 12px; border-radius:999px; font-size:12px;
  font-weight:600; margin:6px 6px 0 0; border:1px solid var(--line); }
.chip-g { background:rgba(40,192,127,.14); color:#7fe3b3; border-color:rgba(40,192,127,.4);}
.chip-u { background:rgba(224,82,82,.14); color:#f2a3a3; border-color:rgba(224,82,82,.4);}
.chip-q { background:rgba(224,178,60,.14); color:#f0d38a; border-color:rgba(224,178,60,.4);}
.reason { background:#0c161b; border:1px solid var(--line); border-left:4px solid var(--teal);
  border-radius:12px; padding:14px 16px; color:var(--ink); font-size:13.5px; line-height:1.55; }
.reason table { width:100%; border-collapse:collapse; margin-top:6px; }
.reason th { color:var(--muted); text-align:left; font-weight:600; padding:2px 6px; }
.reason td { padding:2px 6px; }
.footer-note { color:var(--muted); font-size:12px; text-align:center; margin-top:16px;
  line-height:1.6; }
.md-note { color:var(--muted); font-size:12.5px; }
table td, table th { font-size:12.5px !important; }
"""


def hero_html():
    return """
    <div id="hero">
      <div class="brand">
        <div class="logo">&#128065;</div>
        <div>
          <h1>EyeQC</h1>
          <div class="tag">Retinal image quality &amp; foundation-model bench</div>
        </div>
      </div>
      <p class="sub">EyeQC helps you trust what you're looking at. It checks whether a
      retinal photo is clear enough to read, shows you exactly where and why an image
      falls short, and evens out the differences between cameras and sites so a cohort
      is comparable. It also asks a harder question of AI models: is a diagnosis
      picking up real disease, or just reacting to a blurry, poorly-lit image?</p>
      <span class="pill">Vessel-aware gradability</span>
      <span class="pill">Conformal verdicts</span>
      <span class="pill">Failure localisation</span>
      <span class="pill">ComBat harmonisation</span>
      <span class="pill">Degradation-sensitivity probe</span>
      <span class="pill">Spatial disentanglement</span>
      <span class="pill">FLAIR VQA</span>
    </div>
    """


def verdict_card_html(summary):
    v = summary["verdict"]
    return f"""
    <div class="verdict-card verdict-{v}">
      <div class="big">{summary['composite']:.0f}<span style="font-size:16px">/100</span></div>
      <div style="font-size:19px;margin-top:2px">{v}</div>
      <div class="sm">clinical band: {summary['band']}</div>
    </div>
    """


def conformal_chip_html(pred):
    lab = pred["label"]
    cls = {"gradable": "chip-g", "ungradable": "chip-u"}.get(lab, "chip-q")
    cov = pred.get("coverage")
    cov_txt = f" &middot; {int(cov*100)}% coverage" if cov else ""
    src = pred.get("source", "")
    return (f'<span class="chip {cls}">conformal: {lab}{cov_txt}</span>'
            f'<span class="md-note"> &nbsp;({src})</span>')