How andykimdev/alzheimer-mri-classification works
Purpose and execution entry points
This is a Python/TensorFlow pipeline for four-class Alzheimer’s MRI severity classification using transfer learning. The operational path is dataset splitting, model-specific image preprocessing, then standalone model training scripts. Primary entry points are preprocessing/split_images.py, preprocessing/xception_and_resnet/x_n_r_preprocess_images.py, model/xception/model_architecture/xception_train2.py, and model/inceptionresnetv2/model_architecture/inceptionresnetv2_train.py.
Dataset partitioning and path boundary
Raw Kaggle “Augumented Data” images are first organized into train/validation/test subsets by preprocessing/split_images.py. Shared/dynamic directory naming is centralized in preprocessing/directories.py, forming the filesystem contract between download/splitting, preprocessing, and training. The classifier targets NonDemented, VeryMildDemented, MildDemented, and ModerateDemented.
Model-specific preprocessing
Preprocessing creates disk-backed .npy image data rather than loading the full augmented dataset into RAM. Xception and InceptionResNetV2 consume 299×299 inputs through preprocessing/xception_and_resnet/x_n_r_preprocess_images.py. VGG-family inputs have a separate 224×224 path in preprocessing/vgg16_and_vgg19/v_n_v_preprocess_images.py. This size-specific preprocessing is a hard boundary: training scripts must use artifacts compatible with their backbone.
Xception training pipeline
The Xception implementation separates model construction from training orchestration: model/xception/model_architecture/xception_model.py and model/xception/model_architecture/xception_train2.py. The pipeline uses ImageNet-pretrained Xception as a mostly frozen feature extractor, adds a trainable classification head, and trains through sequential custom data generation. xception_train.py is an additional/earlier training entry point; the README designates xception_train2.py as the active command.
InceptionResNetV2 training pipeline
InceptionResNetV2 follows the same architecture/training split in model/inceptionresnetv2/model_architecture/inceptionresnetv2_model.py and model/inceptionresnetv2/model_architecture/inceptionresnetv2_train.py. It uses a larger pretrained backbone with frozen ImageNet weights and a trainable final classifier. Per-model parameters and paths are defined in model/inceptionresnetv2/config.py; Xception equivalents are in model/xception/config.py.
Training control and outputs
Both training flows use Adam, early stopping, and learning-rate reduction on plateau. Each run emits model artifacts and evaluation material into model-local output directories, with retained comparison data such as model/xception/model_output/comparison_metrics.csv and model/inceptionresnetv2/model_output/comparison_metrics.csv. Existing Run_* folders demonstrate repeated-run result aggregation, though trained .h5 weights are not present in this tree.
Other model branches and runtime
VGG16 and VGG19 are scaffolded with configs and train scripts—model/vgg16/model_architecture/vgg16_train.py and model/vgg19/model_architecture/vgg19_train.py—but are not trained result branches. Runtime is Python 3.13 with TensorFlow 2.20 and dependencies in requirements.txt. The documented execution environment is Google Cloud Platform on an n1-standard-8 VM with one NVIDIA T4 GPU; external data originates from Kaggle’s Multidisease Dataset.
Main entry points: xception_train2.py Xception training · inceptionresnetv2_train.py InceptionResNetV2 training · split_images.py Split images · x_n_r_preprocess_images.py 299×299 preprocessing
Components 18
Dataset preparation
- Kaggle augmented MRI data · Four severity classes.
- Directory contract · Shared dynamic dataset directory naming.
preprocessing/directories.py - Split images · Creates train, validation, and test partitions.
preprocessing/split_images.py - Image partitions · Train/validation/test image hierarchy.
Preprocessing
- 299×299 preprocessing · Disk-backs Xception and InceptionResNetV2 arrays.
preprocessing/xception_and_resnet/x_n_r_preprocess_images.py - 299×299 .npy artifacts · Backbone-compatible disk-backed image arrays.
- 224×224 preprocessing · Separate VGG-family preprocessing path.
preprocessing/vgg16_and_vgg19/v_n_v_preprocess_images.py - 224×224 .npy artifacts
Xception branch
- Xception configuration
model/xception/config.py - Xception model builder · Mostly frozen ImageNet backbone plus trainable classifier head.
model/xception/model_architecture/xception_model.py - Xception training · Sequential custom generation with Adam and callbacks.
model/xception/model_architecture/xception_train2.py - Xception run outputs · Includes retained comparison metrics across runs.
model/xception/model_output/comparison_metrics.csv
InceptionResNetV2 branch
- InceptionResNetV2 configuration
model/inceptionresnetv2/config.py - InceptionResNetV2 builder · Frozen ImageNet backbone with trainable final classifier.
model/inceptionresnetv2/model_architecture/inceptionresnetv2_model.py - InceptionResNetV2 training · Uses Adam, early stopping, and learning-rate reduction.
model/inceptionresnetv2/model_architecture/inceptionresnetv2_train.py - InceptionResNetV2 outputs · Includes retained comparison metrics across runs.
model/inceptionresnetv2/model_output/comparison_metrics.csv
VGG scaffold
- VGG16 training scaffold · Scaffolded branch without trained results.
model/vgg16/model_architecture/vgg16_train.py - VGG19 training scaffold · Scaffolded branch without trained results.
model/vgg19/model_architecture/vgg19_train.py
Connections 18
- Kaggle augmented MRI data → Split images: raw images
- Directory contract → Split images: partition paths
- Split images → Image partitions: train / validation / test
- Directory contract → 299×299 preprocessing: input paths
- Image partitions → 299×299 preprocessing: images
- 299×299 preprocessing → 299×299 .npy artifacts: .npy arrays
- Image partitions → 224×224 preprocessing: images
- 224×224 preprocessing → 224×224 .npy artifacts: .npy arrays
- Xception configuration → Xception training: parameters and paths
- Xception model builder → Xception training: constructs model
- 299×299 .npy artifacts → Xception training: compatible inputs
- Xception training → Xception run outputs: models and metrics
- InceptionResNetV2 configuration → InceptionResNetV2 training: parameters and paths
- InceptionResNetV2 builder → InceptionResNetV2 training: constructs model
- 299×299 .npy artifacts → InceptionResNetV2 training: compatible inputs
- InceptionResNetV2 training → InceptionResNetV2 outputs: models and metrics
- 224×224 .npy artifacts → VGG16 training scaffold: compatible inputs
- 224×224 .npy artifacts → VGG19 training scaffold: compatible inputs