This project involves building a deep learning model for classifying tuberculosis (TB) images using a Bayesian Convolutional Neural Network (CNN). The model leverages Monte Carlo Dropout for uncertainty estimation and SMOTE (Synthetic Minority Over-sampling Technique) to address class imbalance. The project is implemented using Streamlit for the user interface and integrates key tools and techniques for medical image classification.
- Bayesian CNN with Monte Carlo Dropout: Provides uncertainty estimation for model predictions.
- Class Imbalance Handling: Uses SMOTE for oversampling minority classes, improving the model's robustness.
- Streamlit UI: Intuitive and interactive interface for users to upload and classify TB images.
- Preprocessing and Visualization: Includes image preprocessing and visualization for better interpretability.
- Metrics and Evaluation: Supports performance evaluation using metrics such as accuracy, Dice Score, and IoU (Intersection over Union).
-
Data Preprocessing:
- Images are resized, normalized, and augmented.
- SMOTE is applied to address class imbalance.
-
Model Architecture:
- Bayesian CNN is used to incorporate Monte Carlo Dropout during inference for uncertainty estimation.
- TensorFlow is used for model implementation.
-
Loss Functions:
- Dice Loss
- Binary Cross-Entropy
- Intersection over Union (IoU)
-
User Interface:
- Built using Streamlit for easy image upload and classification.
- Displays predictions along with confidence scores and uncertainty estimates.
-
Evaluation:
- Metrics include accuracy, Dice Score, IoU, and F1-score.
-
Clone the repository:
git clone https://github.com/your-username/tuberculosis-bayesian-cnn.git cd tuberculosis-bayesian-cnn
-
Install dependencies: Create a virtual environment and activate it (optional but recommended):
python -m venv venv source venv/bin/activate # For Linux/Mac venv\Scripts\activate # For Windows
Install the required packages:
pip install -r requirements.txt
-
Run the application:
streamlit run app.py
Key dependencies for the project include:
streamlit==1.24.1
tensorflow>=2.12.0
opencv-python==4.8.0.76
pandas==1.5.3
scikit-learn==1.2.2
matplotlib==3.6.3
protobuf==3.20.3
For a full list, see requirements.txt
.
- Upload a chest X-ray image using the Streamlit interface.
- The model processes the image and predicts the likelihood of tuberculosis.
- View the classification result along with the confidence score and uncertainty estimate.
- Analyze the performance metrics and uncertainty visualization.
.
├── app.py # Streamlit UI implementation
├── model.py # Bayesian CNN model definition
├── preprocessing.py # Data preprocessing and augmentation
├── utils.py # Utility functions for metrics and visualization
├── requirements.txt # List of dependencies
├── README.md # Project documentation
└── datasets/ # Contains training and testing data
- Integration of Additional Models: Explore architectures like U-Net or Mask R-CNN for enhanced segmentation capabilities.
- Automated Hyperparameter Tuning: Incorporate tools like Optuna or Ray Tune.
- Deployment: Deploy the application on platforms like AWS, Heroku, or Google Cloud for broader accessibility.
- Advanced Visualizations: Add Grad-CAM or saliency map visualizations to improve interpretability.
Contributions are welcome! If you'd like to contribute, please:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
This project is licensed under the MIT License.
- TensorFlow for the deep learning framework.
- Streamlit for providing a seamless user interface.
- Scikit-learn for data preprocessing and evaluation metrics.
- Open-source resources and datasets for tuberculosis classification.