How biki989/mri-brain-tumour-detection works
This is a PyTorch brain-MRI pipeline and local Flask interface for detecting LGG tumors, segmenting positive slices, and presenting model explanations. The user workflow is upload a TIFF, classify it, conditionally segment it, then display confidence and XAI maps. Separate training and evaluation workflows support the classifier and segmentation ensembles. The README documents model families and XAI capabilities; links below follow sampled source, while unsampled subsystem wiring is omitted.
Main entry points: app.py Flask app · compare.py Explanation coordinator · inference.py Inference orchestration · dataset.py MRI transforms
Components 17
Clinical interface
- Flask app
app.py - Web interface
templates/index.html - Uploaded scans
static/uploads - XAI images
static/xai
Inference pipeline
- Inference orchestration
src/inference.py - MRI transforms
src/dataset.py - Classifier ensemble
src/ensemble.py - Segmentor ensemble
src/ensemble.py
Modeling and training
- Classifier models
src/models/classifier.py - Segmentation models
src/models/segmentor.py - Classifier training
src/train_classifier.py - Segmentor training
src/train_segmentor.py
Evaluation and XAI
- Ensemble evaluation
src/evaluate.py - Explanation coordinator
src/explainability/compare.py - Grad-CAM
src/explainability/gradcam.py - Segmentation XAI
src/explainability/segmentation_xai.py
Other components
- MRI user
Connections 24
- MRI user → Flask app: uploads TIFF
- Flask app → Uploaded scans: saves scan
- Flask app → Inference orchestration: runs inference
- Flask app → Explanation coordinator: requests explanations
- Flask app → Web interface: renders results
- Flask app → XAI images: writes maps
- Inference orchestration → MRI transforms: transforms image
- Inference orchestration → Classifier ensemble: classifies slice
- Inference orchestration → Segmentor ensemble: segments positive
- Classifier ensemble → Classifier models: dispatches models
- Segmentor ensemble → Segmentation models: dispatches models
- Classifier training → MRI transforms: loads samples
- Classifier training → Classifier models: trains model
- Segmentor training → MRI transforms: loads samples
- Segmentor training → Segmentation models: trains model
- Ensemble evaluation → MRI transforms: loads evaluation data
- Ensemble evaluation → Inference orchestration: loads ensembles
- Ensemble evaluation → Classifier ensemble: measures classification
- Ensemble evaluation → Segmentor ensemble: measures segmentation
- Explanation coordinator → MRI transforms: transforms image
- Explanation coordinator → Grad-CAM: generates heatmap
- Explanation coordinator → Segmentation XAI: generates maps
- Explanation coordinator → Classifier ensemble: explains classifier
- Explanation coordinator → Segmentor ensemble: explains segmentors