Skip to content
Pranav-errorPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Mitosis Classifier with RISE Explainability

A deep learning project for mitosis detection in histopathology images with explainable AI using the RISE (Randomized Input Sampling for Explanation) method.

📋 Overview

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.

🎯 Features

  • 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

🏗️ Project Structure

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/

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • TensorFlow 2.x
  • PyTorch (for PyTorch implementation)
  • CUDA-capable GPU (optional, for faster processing)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/rise.git
cd rise
  1. Install required dependencies:
pip install -r requirements.txt

Dependencies

  • tensorflow>=2.8.0
  • torch>=1.10.0
  • torchvision>=0.11.0
  • numpy>=1.21.0
  • pandas>=1.3.0
  • matplotlib>=3.4.0
  • Pillow>=8.3.0
  • scikit-learn>=0.24.0

📊 Usage

Evaluate the Classifier

Evaluate the trained model on test images:

python evaluate_classifier.py

This will output:

  • Model accuracy and loss on test set
  • Detailed classification report with precision, recall, and F1-score

Generate RISE Explanations (TensorFlow)

Generate explainability visualizations using TensorFlow:

python explain_classifier.py

Configuration options in explain_classifier.py:

  • MODEL_PATH: Path to your trained model
  • IMAGE_PATH: Path to the image you want to explain
  • N_MASKS: Number of random masks (default: 4000)
  • IMG_HEIGHT, IMG_WIDTH: Image dimensions (default: 256x256)

Generate RISE Explanations (PyTorch)

Generate explainability visualizations using PyTorch:

python rise_explain.py

Features:

  • GPU acceleration support
  • Batch processing of masks
  • Configurable mask generation parameters

🔬 How RISE Works

RISE (Randomized Input Sampling for Explanation) generates explanations by:

  1. Creating random binary masks
  2. Applying masks to the input image
  3. Feeding masked images through the model
  4. Weighting masks by their prediction scores
  5. Aggregating masks to create a saliency map

The resulting saliency map highlights image regions that most influence the model's prediction.

📈 Dataset

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.

🎨 Visualization

The explanation scripts generate visualizations showing:

  • Original input image
  • Generated saliency map
  • Ground-truth mask (if available)
  • Overlay of saliency map on original image

⚙️ Model Details

  • Architecture: Convolutional Neural Network (CNN)
  • Input Size: 256x256x3 (RGB images)
  • Output: Binary classification (mitosis/no mitosis)
  • Framework: TensorFlow/Keras
  • Model File: mitosis_classifier.h5

📝 Configuration

Key parameters can be adjusted in each script:

Model Evaluation

  • IMG_HEIGHT, IMG_WIDTH: Input image dimensions
  • BATCH_SIZE: Batch size for evaluation

RISE Explanation

  • N_MASKS: Number of random masks (more masks = better quality, slower)
  • BATCH_SIZE: Masks processed per batch
  • p: Probability for mask generation (default: 0.5)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔗 References

👤 Author

Sai Pranav

🙏 Acknowledgments

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages