An Enterprise-Grade Vision Transformer (ViT) Architecture for Early Alzheimer's Detection
View Live Deployment (alzdetect.live) • Diagnostic Scanner • Technical Documentation • Clinical Validation
AlzDetect is a production-ready medical technology platform engineered to assist neurologists in the early-stage detection of Alzheimer's disease. Moving beyond conventional diagnostics, the platform leverages state-of-the-art Vision Transformers (ViT-B/32) to extract granular, high-dimensional features from patient MRI sequences.
Designed with enterprise architecture in mind, the system integrates a mathematically rigorous Explainable AI (XAI) engine, real-time clinical protocol generation via LLMs, and stringent HIPAA-aligned data security protocols utilizing Supabase Row Level Security (RLS) and End-to-End Encryption methodologies.
The application is structured as a decoupled microservices environment, ensuring strict separation of concerns, massive horizontal scalability, and adherence to medical data handling standards.
graph TD
Client[Next.js 15 Client] -->|OAuth & Session| Auth[Supabase Auth]
Client -->|HTTPS / REST| Fast[FastAPI Compute Cluster]
Fast -->|Base64 Tensors| ML[Vision Transformer Engine]
ML -->|Rollout Algorithm| XAI[Attention Map Generator]
Client -->|XAI Outputs| Storage[Supabase PostgreSQL RLS]
ML -->|Clinical Signals| OpenAI[GPT-4o Protocol Engine]
- The Presentation Layer (Client): Engineered with Next.js 15 (React 18), featuring a custom glassmorphic UI system, fluid hardware-accelerated animations, and responsive clinical drill-down views.
- The Compute Layer (Backend): A high-concurrency Python ASGI server (FastAPI) deployed via Uvicorn. Handles heavy tensor matrix transformations and AI inference routing.
- The Intelligence Layer (Model): A dynamically loaded Vision Transformer employing a custom manual-rollout script to bypass Keras 3 schema restrictions, enabling pixel-perfect Attention Map visualizations.
- The Persistence Layer (Database): Supabase (PostgreSQL) handling robust authentication, user-scoped data segregation via RLS, and blob storage for diagnostic visual histories.
A core tenet of modern medical software is interpretability. The AlzDetect architecture implements a rigorous Attention Map Rollout.
Instead of treating the AI as a "black box," the system manually intercepts the neural network's internal Multi-Head Self-Attention layers block-by-block. It projects these highly activated weights backward to the input space, generating a high-contrast heatmap overlay on the original MRI. This mathematically demonstrates exactly which anatomical regions (e.g., Hippocampus, Ventricles) the network analyzed to output its prediction.
| Model / Evaluation Configuration | Partition / Cohort | Test Accuracy | Balanced Acc | Macro F1 | Macro ROC-AUC |
|---|---|---|---|---|---|
| Fine-Tuned ViT-B/32 (Primary Locked Model) | Primary Held-Out Test (n = 6,400) |
98.84% | 99.31% | 99.24% | 1.0000 |
| Fine-Tuned ViT-B/32 (External Evaluation) | Secondary Test Set (n = 1,279) |
97.73% | 98.77% | 98.59% | 0.9994 |
| Controlled 3-Seed Full Fine-Tuning (Mean ± SD) | Seeds 42, 123, 2024 (n = 6,400) |
98.47% ± 0.53% | 98.89% | 98.84% ± 0.43% | 0.9995 |
| Baseline Custom CNN | Primary Held-Out Test (n = 6,400) |
64.20% | 72.00% | 68.75% | 0.8640 |
| Baseline Unadapted ViT | Primary Held-Out Test (n = 6,400) |
54.00% | 61.25% | 44.50% | 0.7810 |
- Quantitative Attention Faithfulness (
n = 80Test MRIs, 2,000 Bootstrap Resamples): Statistically significant positive deletion AUC advantage (+0.12455, 95% CI[0.08904, 0.16481]) and insertion AUC advantage (+0.15387, 95% CI[0.10233, 0.20219]) over random patch perturbation. - Live Production Platform: https://www.alzdetect.live/
- Role-Based Access Control (RBAC): Enforced at the database level via Supabase.
- Data Segregation: PostgreSQL Row Level Security (RLS) guarantees that individual clinical sessions and diagnostic logs are completely isolated and inaccessible across accounts.
- Stateless Inference: The diagnostic compute cluster immediately purges MRI buffers post-inference. History is permanently archived only if the user explicitly saves the validated sequence to their secure Vault.
- Node.js (v18+)
- Python (v3.12, strict requirement for legacy
tf-kerascompatibility) - pip / pnpm
cd client
pnpm install
# Ensure .env contains NEXT_PUBLIC_SUPABASE_URL and ANON_KEY
pnpm devClient will mount at http://localhost:3000
cd server
python -m venv .venv_prod
source .venv_prod/Scripts/activate # Windows
pip install -r requirements.txt
# TF_USE_LEGACY_KERAS=1 is strictly required in .env
python -m uvicorn src.server:app --host 0.0.0.0 --port 8000 --reloadEngine will mount at http://localhost:8000
Bassey Riman
Lead Architect & AI Engineer
Integrating cutting-edge machine learning into scalable, beautifully-engineered consumer health interfaces.