Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -115,12 +115,22 @@ def run_gcn(file_path: str | None) -> tuple[str, str]:
|
|
| 115 |
p = torch.softmax(logits, -1)[0, 1].item()
|
| 116 |
per_model.append((site, p))
|
| 117 |
|
| 118 |
-
p_mean
|
| 119 |
-
label = "ASD" if p_mean > 0.5 else "Typical Control"
|
| 120 |
-
conf = max(p_mean, 1 - p_mean) * 100
|
| 121 |
consensus = sum(1 for _, p in per_model if p > 0.5)
|
|
|
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
gcn_out += f"Confidence : {conf:.1f}% (p_ASD = {p_mean:.3f})\n"
|
| 125 |
gcn_out += f"Consensus : {consensus}/4 site models\n\n"
|
| 126 |
gcn_out += "Per-model breakdown:\n"
|
|
@@ -129,7 +139,6 @@ def run_gcn(file_path: str | None) -> tuple[str, str]:
|
|
| 129 |
lbl = "ASD" if p > 0.5 else "TC "
|
| 130 |
gcn_out += f" {site:>4} {lbl} {bar} {p:.3f}\n"
|
| 131 |
|
| 132 |
-
# Clinical interpretation stub — replaced by fine-tuned Qwen2.5-7B on AMD MI300X
|
| 133 |
asd_features = [
|
| 134 |
"Reduced DMN coherence (mPFC ↔ PCC)",
|
| 135 |
"Atypical salience network lateralization",
|
|
@@ -145,8 +154,9 @@ def run_gcn(file_path: str | None) -> tuple[str, str]:
|
|
| 145 |
"Cerebellar–cortical coupling within expected range",
|
| 146 |
]
|
| 147 |
|
| 148 |
-
report
|
| 149 |
report += f"**Overall**: {label} ({conf:.1f}% confidence, {consensus}/4 site consensus)\n\n"
|
|
|
|
| 150 |
if p_mean > 0.6:
|
| 151 |
report += "**Key Findings**:\n"
|
| 152 |
for f in asd_features[:3]:
|
|
@@ -161,8 +171,12 @@ def run_gcn(file_path: str | None) -> tuple[str, str]:
|
|
| 161 |
report += "\n**Cross-Site Consistency**: Typical connectivity profile confirmed "
|
| 162 |
report += f"by {4 - consensus}/4 independent site models.\n\n"
|
| 163 |
else:
|
| 164 |
-
report += "**
|
| 165 |
-
report += "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
report += "*This report is AI-assisted and does not constitute a diagnosis. "
|
| 168 |
report += "Full clinical assessment required.*\n\n"
|
|
|
|
| 115 |
p = torch.softmax(logits, -1)[0, 1].item()
|
| 116 |
per_model.append((site, p))
|
| 117 |
|
| 118 |
+
p_mean = float(np.mean([p for _, p in per_model]))
|
|
|
|
|
|
|
| 119 |
consensus = sum(1 for _, p in per_model if p > 0.5)
|
| 120 |
+
conf = max(p_mean, 1 - p_mean) * 100
|
| 121 |
|
| 122 |
+
if p_mean > 0.6:
|
| 123 |
+
label = "ASD"
|
| 124 |
+
status = "HIGH CONFIDENCE"
|
| 125 |
+
elif p_mean < 0.4:
|
| 126 |
+
label = "Typical Control"
|
| 127 |
+
status = "HIGH CONFIDENCE"
|
| 128 |
+
else:
|
| 129 |
+
label = "Inconclusive"
|
| 130 |
+
status = "LOW CONFIDENCE — CLINICAL REVIEW RECOMMENDED"
|
| 131 |
+
|
| 132 |
+
gcn_out = f"Prediction : {label}\n"
|
| 133 |
+
gcn_out += f"Status : {status}\n"
|
| 134 |
gcn_out += f"Confidence : {conf:.1f}% (p_ASD = {p_mean:.3f})\n"
|
| 135 |
gcn_out += f"Consensus : {consensus}/4 site models\n\n"
|
| 136 |
gcn_out += "Per-model breakdown:\n"
|
|
|
|
| 139 |
lbl = "ASD" if p > 0.5 else "TC "
|
| 140 |
gcn_out += f" {site:>4} {lbl} {bar} {p:.3f}\n"
|
| 141 |
|
|
|
|
| 142 |
asd_features = [
|
| 143 |
"Reduced DMN coherence (mPFC ↔ PCC)",
|
| 144 |
"Atypical salience network lateralization",
|
|
|
|
| 154 |
"Cerebellar–cortical coupling within expected range",
|
| 155 |
]
|
| 156 |
|
| 157 |
+
report = "## Clinical Connectivity Summary\n\n"
|
| 158 |
report += f"**Overall**: {label} ({conf:.1f}% confidence, {consensus}/4 site consensus)\n\n"
|
| 159 |
+
|
| 160 |
if p_mean > 0.6:
|
| 161 |
report += "**Key Findings**:\n"
|
| 162 |
for f in asd_features[:3]:
|
|
|
|
| 171 |
report += "\n**Cross-Site Consistency**: Typical connectivity profile confirmed "
|
| 172 |
report += f"by {4 - consensus}/4 independent site models.\n\n"
|
| 173 |
else:
|
| 174 |
+
report += "**Inconclusive — Clinical Review Required**\n\n"
|
| 175 |
+
report += "Connectivity pattern falls near the ASD–Typical Control boundary. "
|
| 176 |
+
report += f"Model disagreement ({consensus}/4 site models predict ASD) indicates "
|
| 177 |
+
report += "insufficient confidence for an automated call.\n\n"
|
| 178 |
+
report += "**Recommended action**: Refer for full neuropsychological evaluation "
|
| 179 |
+
report += "(ADOS-2, ADI-R) and structural MRI review.\n\n"
|
| 180 |
|
| 181 |
report += "*This report is AI-assisted and does not constitute a diagnosis. "
|
| 182 |
report += "Full clinical assessment required.*\n\n"
|