A deep learning project for mitosis detection in histopathology images with explainable AI using the RISE (Randomized Input Sampling for Explanation) method.
This project implements a binary classifier for detecting mitosis in medical images, enhanced with RISE-based explainability to visualize which regions of the image contribute most to the model's predictions. The project includes both TensorFlow and PyTorch implementations of the RISE explanation method.
- Binary Mitosis Classification: Trained model for detecting mitosis in histopathology images
- RISE Explainability: Generate saliency maps showing important image regions
- Model Evaluation: Comprehensive evaluation metrics and classification reports
- Multiple Implementations: Both TensorFlow and PyTorch versions available
- Visualization: Compare model predictions with ground-truth masks
rise/
├── classifier_labels.csv # Dataset labels mapping
├── mitosis_classifier.h5 # Trained TensorFlow model
├── evaluate_classifier.py # Model evaluation script
├── explain_classifier.py # TensorFlow RISE implementation
├── rise_explain.py # PyTorch RISE implementation
├── original_images/ # Input images
│ ├── train/
│ ├── valid/
│ └── test/
└── bw_masks/ # Ground-truth segmentation masks
├── train/
├── valid/
└── test/
- Python 3.8+
- TensorFlow 2.x
- PyTorch (for PyTorch implementation)
- CUDA-capable GPU (optional, for faster processing)
- Clone the repository:
git clone https://github.com/yourusername/rise.git
cd rise- Install required dependencies:
pip install -r requirements.txttensorflow>=2.8.0torch>=1.10.0torchvision>=0.11.0numpy>=1.21.0pandas>=1.3.0matplotlib>=3.4.0Pillow>=8.3.0scikit-learn>=0.24.0
Evaluate the trained model on test images:
python evaluate_classifier.pyThis will output:
- Model accuracy and loss on test set
- Detailed classification report with precision, recall, and F1-score
Generate explainability visualizations using TensorFlow:
python explain_classifier.pyConfiguration options in explain_classifier.py:
MODEL_PATH: Path to your trained modelIMAGE_PATH: Path to the image you want to explainN_MASKS: Number of random masks (default: 4000)IMG_HEIGHT,IMG_WIDTH: Image dimensions (default: 256x256)
Generate explainability visualizations using PyTorch:
python rise_explain.pyFeatures:
- GPU acceleration support
- Batch processing of masks
- Configurable mask generation parameters
RISE (Randomized Input Sampling for Explanation) generates explanations by:
- Creating random binary masks
- Applying masks to the input image
- Feeding masked images through the model
- Weighting masks by their prediction scores
- Aggregating masks to create a saliency map
The resulting saliency map highlights image regions that most influence the model's prediction.
The dataset consists of:
- Histopathology images (256x256 pixels)
- Binary labels (0: no mitosis, 1: mitosis present)
- Ground-truth segmentation masks
- Train/validation/test splits
Dataset structure is managed through classifier_labels.csv.
The explanation scripts generate visualizations showing:
- Original input image
- Generated saliency map
- Ground-truth mask (if available)
- Overlay of saliency map on original image
- Architecture: Convolutional Neural Network (CNN)
- Input Size: 256x256x3 (RGB images)
- Output: Binary classification (mitosis/no mitosis)
- Framework: TensorFlow/Keras
- Model File:
mitosis_classifier.h5
Key parameters can be adjusted in each script:
IMG_HEIGHT,IMG_WIDTH: Input image dimensionsBATCH_SIZE: Batch size for evaluation
N_MASKS: Number of random masks (more masks = better quality, slower)BATCH_SIZE: Masks processed per batchp: Probability for mask generation (default: 0.5)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- RISE: Randomized Input Sampling for Explanation of Black-box Models
- Original paper: Petsiuk et al., BMVC 2018
Sai Pranav
- RISE paper authors for the explainability method
- Medical imaging dataset providers
- TensorFlow and PyTorch communities
Note: Ensure you have the trained model file (mitosis_classifier.h5) and dataset images in the appropriate directories before running the scripts.