Use demo cache immediately and memoize results
Browse files298 unmodified lines299300301302303304305221 unmodified lines527528529530531532533534535536537225 unmodified lines76376476576076176276376676776876977077177213 unmodified lines786787788783789790791792793794298 unmodified lines# ── model loading ──────────────────────────────────────────────────────────
_model_cache: dict[str, list] = {}_result_cache: dict[str, tuple[str, str, str, object]] = {}
def get_models(atlas: str = "cc200"): global _model_cache221 unmodified lines return "", "", "", None
path = Path(file_path) cache_key = str(path) if cache_key in _result_cache: return _result_cache[cache_key]
demo_key = path.name atlas_key = "cc200" # default; overridden below for .1D files try: if path.suffix == ".npz":225 unmodified lines
# LLM clinical interpretation via AMD MI300X vLLM endpoint # Fall back to demo cache for known subjects if endpoint is down _demo_key = os.path.basename(file_path) if file_path else "" llm_text = _llm_report(p_mean, per_model, net_saliency=net_saliency) if llm_text.startswith("[LLM unavailable") and _demo_key in _DEMO_LLM_CACHE: llm_text = _DEMO_LLM_CACHE[_demo_key] if demo_key in _DEMO_LLM_CACHE: llm_text = _DEMO_LLM_CACHE[demo_key] else: llm_text = _llm_report(p_mean, per_model, net_saliency=net_saliency) import re as _re def _md_to_html(txt): txt = _re.sub(r'^#{1,3}\s*(.+)$', r'<h4 style="color:#94a3b8;margin:1em 0 0.3em;font-size:0.9rem">\1</h4>', txt, flags=_re.MULTILINE)13 unmodified linesAI-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>"""
return verdict, ensemble, report, sal_img result = (verdict, ensemble, report, sal_img) _result_cache[cache_key] = result return result
# ── Static HTML sections ───────────────────────────────────────────────────app.py+13-5