Fix: /20 verdict count, graceful LLM fallback on CPU, AMD badge
Browse files
app.py
CHANGED
|
@@ -515,12 +515,13 @@ def run_gcn(file_path):
|
|
| 515 |
sal_img = None
|
| 516 |
|
| 517 |
# ── Verdict ──
|
|
|
|
| 518 |
if p_mean > 0.6:
|
| 519 |
col, label = "#ef4444", "ASD Indicated"
|
| 520 |
-
detail = f"{consensus}/
|
| 521 |
elif p_mean < 0.4:
|
| 522 |
col, label = "#22c55e", "Typical Control"
|
| 523 |
-
detail = f"{
|
| 524 |
else:
|
| 525 |
col, label = "#f59e0b", "Inconclusive"
|
| 526 |
detail = "Clinical review required"
|
|
@@ -626,14 +627,29 @@ LOSO AUC = 0.7260 · 1,102 held-out subjects · 20 acquisition sites
|
|
| 626 |
<div style="border-top:1px solid #252a35;padding-top:10px;color:#5e6675;font-size:0.74rem;line-height:1.5">
|
| 627 |
AI-assisted screening only · Not a clinical diagnosis · Findings must be integrated with ADOS-2, ADI-R, and full developmental history · Refer to licensed neuropsychologist for formal evaluation.</div></div>"""
|
| 628 |
|
| 629 |
-
# LLM clinical interpretation
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
report += f"""
|
| 632 |
<div style="background:#0f1a1a;border:1px solid #1a3a3a;border-radius:8px;padding:18px 24px;margin-top:12px">
|
| 633 |
-
<div style="
|
| 634 |
-
Qwen2.5-7B Clinical
|
|
|
|
| 635 |
</div>
|
| 636 |
-
|
| 637 |
</div>"""
|
| 638 |
|
| 639 |
return verdict, ensemble, report, sal_img
|
|
|
|
| 515 |
sal_img = None
|
| 516 |
|
| 517 |
# ── Verdict ──
|
| 518 |
+
n_models = len(models)
|
| 519 |
if p_mean > 0.6:
|
| 520 |
col, label = "#ef4444", "ASD Indicated"
|
| 521 |
+
detail = f"{consensus}/{n_models} site-blind models agree"
|
| 522 |
elif p_mean < 0.4:
|
| 523 |
col, label = "#22c55e", "Typical Control"
|
| 524 |
+
detail = f"{n_models - consensus}/{n_models} site-blind models agree"
|
| 525 |
else:
|
| 526 |
col, label = "#f59e0b", "Inconclusive"
|
| 527 |
detail = "Clinical review required"
|
|
|
|
| 627 |
<div style="border-top:1px solid #252a35;padding-top:10px;color:#5e6675;font-size:0.74rem;line-height:1.5">
|
| 628 |
AI-assisted screening only · Not a clinical diagnosis · Findings must be integrated with ADOS-2, ADI-R, and full developmental history · Refer to licensed neuropsychologist for formal evaluation.</div></div>"""
|
| 629 |
|
| 630 |
+
# LLM clinical interpretation (only attempt if GPU is available)
|
| 631 |
+
import os
|
| 632 |
+
_has_gpu = torch.cuda.is_available() or (hasattr(torch, "hip") and torch.hip.is_available() if hasattr(torch, "hip") else False)
|
| 633 |
+
if _has_gpu:
|
| 634 |
+
llm_text = _llm_report(p_mean, per_model, net_saliency=net_saliency)
|
| 635 |
+
llm_block = f'<div style="color:#cbd5e1;font-size:0.85rem;line-height:1.7;white-space:pre-wrap">{llm_text}</div>'
|
| 636 |
+
else:
|
| 637 |
+
llm_block = """
|
| 638 |
+
<div style="color:#8b95a7;font-size:0.84rem;line-height:1.6">
|
| 639 |
+
Qwen2.5-7B LoRA interpreter is active — fine-tuned on AMD Instinct MI300X (192 GB HBM3, ROCm 7.0, bf16).
|
| 640 |
+
GPU inference is required to run it in real-time. The full model is available at
|
| 641 |
+
<span style="color:#fb923c">Yatsuiii/asd-interpreter-lora</span> on Hugging Face.
|
| 642 |
+
<br><br>
|
| 643 |
+
<span style="color:#5e6675">Clinical interpretation pipeline: GCN ensemble → per-network saliency extraction →
|
| 644 |
+
Qwen2.5-7B generates grounded clinical summary referencing only the actual saliency values.</span>
|
| 645 |
+
</div>"""
|
| 646 |
report += f"""
|
| 647 |
<div style="background:#0f1a1a;border:1px solid #1a3a3a;border-radius:8px;padding:18px 24px;margin-top:12px">
|
| 648 |
+
<div style="display:flex;align-items:center;gap:10px;margin-bottom:10px">
|
| 649 |
+
<span style="color:#2dc653;font-size:0.68rem;text-transform:uppercase;letter-spacing:1.5px;font-weight:600">Qwen2.5-7B Clinical Interpreter</span>
|
| 650 |
+
<span style="background:#1f1a10;border:1px solid #fb923c44;color:#fb923c;font-size:0.68rem;padding:2px 8px;border-radius:10px;font-weight:600">Fine-tuned · AMD MI300X · ROCm 7.0</span>
|
| 651 |
</div>
|
| 652 |
+
{llm_block}
|
| 653 |
</div>"""
|
| 654 |
|
| 655 |
return verdict, ensemble, report, sal_img
|