A deep learning system that classifies brain MRI scans into four stages of Alzheimer's-related cognitive decline using a lightweight Convolutional Neural Network, paired with a web-based clinical decision-support interface and an AI chatbot for patient-friendly result interpretation.
- 🟢 No Impairment — Cognitively healthy
- 🟡 Very Mild Impairment — Earliest signs of decline
- 🟠 Mild Impairment — Moderate atrophy patterns
- 🔴 Moderate Impairment — Advanced neurodegeneration
| Metric | Value |
|---|---|
| Test Accuracy | 98.83% |
| Inference Speed | ~2.4 ms/image |
| Epochs Trained | 94 (EarlyStopping) |
| Model Size | ~10 MB |
alzheimer_detection/
├── app.py # Flask web app + chatbot API
├── train.py # Model training pipeline
├── test.py # Model evaluation & metrics export
├── generate_figures.py # Academic figure generation (11 figures)
├── setup_dataset.py # Kaggle dataset downloader
├── trained_model.keras # Saved CNN model
├── requirements.txt # Python dependencies
├── LICENSE
│
├── static/ # Frontend assets
│ ├── style.css
│ └── script.js
│
├── templates/
│ └── index.html # Web UI with chatbot widget
│
├── data/ # Generated JSON (gitignored)
│ ├── training_history.json
│ └── evaluation_results.json
│
├── figures/ # Generated paper figures (gitignored)
│ ├── training_curves.png
│ ├── confusion_matrix.png
│ ├── cnn_architecture.png
│ ├── system_pipeline.png
│ ├── metrics_table.png
│ ├── sample_scans.png
│ ├── dataset_distribution.png
│ ├── per_class_accuracy.png
│ ├── flowchart.png
│ ├── prototype_ui.png
│ ├── learning_rate.png
│ └── screenshots/ # Manual screenshots
│
└── mri_images/ # Dataset (gitignored, auto-downloaded)
├── train/
└── test/
graph TB
subgraph DataPrep["1. Data Preparation"]
A["Input: Alzheimer MRI Scans<br/>11,519 images 128x128px"] --> B["Train-Test Split<br/>80% Train / 20% Test"]
B --> C["Image Normalization<br/>Rescaling 1/255"]
end
subgraph ModelArch["2. Model Architecture"]
D["CNN Definition<br/>Keras Sequential"]
subgraph Layers["Network Layers"]
E["Conv2D Block 1<br/>64 filters, 3x3, ReLU + MaxPool"] --> F["Conv2D Block 2<br/>32 filters, 3x3, ReLU + MaxPool"]
F --> G["Conv2D Block 3<br/>32 filters, 2x2, ReLU + MaxPool"]
G --> H["Dropout<br/>0.20 / 0.25"]
H --> I["Flatten<br/>8192"]
I --> J["Dense 100 + Dense 50<br/>Softmax 4 classes"]
end
D --> E
end
subgraph Training["3. Training Pipeline"]
K["Model Compilation<br/>Adam Optimizer<br/>Categorical Crossentropy"] --> L["Model Training<br/>94 Epochs (EarlyStopping)<br/>ReduceLROnPlateau"]
end
subgraph Evaluation["4. Evaluation and Output"]
M["Model Evaluation"]
subgraph Metrics["Performance Metrics"]
N["Accuracy: 98.83%<br/>Loss Plots"]
O["Classification Report<br/>Precision, Recall, F1"]
P["Confusion Matrix"]
end
M --> N
M --> O
M --> P
Q["Output: Saved Model<br/>.keras file<br/>Inference: ~2.4ms/image"]
end
DataPrep --> ModelArch
ModelArch --> Training
Training --> Evaluation
Training -. "Backpropagation" .-> ModelArch
git clone https://github.com/Bugaddr/alzheimer_detection.git
cd alzheimer_detection
python -m venv venv && source venv/bin/activate
pip install -r requirements.txtThe dataset is auto-downloaded from Kaggle on first run.
# Train the model
python train.py
# Evaluate on test set
python test.py
# Generate paper figures (11 figures from real data)
python generate_figures.py
# Run web app
python app.py
# Open http://localhost:9000The Flask web app lets clinicians upload MRI scans and get instant predictions with confidence scores, clinical recommendations, and a patient-friendly chatbot that explains results in simple language.
API Endpoints:
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Frontend UI |
GET |
/api/health |
Health check |
POST |
/api/predict |
Analyze an MRI image |
POST |
/api/chat |
Chatbot — interprets results for patients |
After a scan result is displayed, a floating chat widget appears. Patients can ask questions like:
- "What does my result mean?"
- "What should I do next?"
- "What lifestyle changes can help?"
- "How accurate is this test?"
- "Should I be worried?"
The chatbot uses a rule-based knowledge system (no external API) tailored to each of the 4 diagnosis levels.
⚠️ Disclaimer: This is a research prototype and clinical decision-support tool, not a standalone diagnostic instrument. All results must be validated by qualified healthcare professionals.