Deep Learningβbased pneumonia detection from chest X-rays with Grad-CAM interpretability
Pneumonia is a lung infection causing inflammation in the air sacs, making early detection critical. Manual diagnosis using chest X-rays can be slow and error-prone. PulmoVision Pro automates this process using CNNs to classify Normal vs Pneumonia X-ray images, providing interpretable results with Grad-CAM heatmaps. Goals:
- Automate pneumonia detection from chest X-rays πΌοΈ
- Provide interpretable results for clinicians π₯
- Deploy predictions on a professional Streamlit dashboard π»
- Preprocess chest X-ray images πΌοΈ
- Train & fine-tune CNNs (DenseNet121, ResNet50) π§
Evaluate models using:
- Accuracy β
- Precision π―
- Recall π
- AUC π
πVisualize results:
- Training/Validation curves
- Confusion Matrix heatmaps
- ROC curves
- Grad-CAM overlays π
- Compare DenseNet vs ResNet performance βοΈ
- Deploy predictions on interactive Streamlit dashboard
- Kermany Chest X-Ray Pneumonia Dataset (~5 GB)
- Balanced classes: Normal & Pneumonia βοΈ
- Preprocessed and ready for CNN training/testing
Kaggle link: Chest X-Ray Images (Pneumonia) Folder Structure Example:
chest_xray/
train/
NORMAL/
PNEUMONIA/
val/
NORMAL/
PNEUMONIA/
test/
NORMAL/
PNEUMONIA/
Model Description
- DenseNet121 πΉ Dense connections for feature reuse; excellent for detecting X-ray textures
- ResNet50 πΉ Residual connections prevent vanishing gradients; performs well on smaller datasets
Custom Classifier:
GlobalAveragePooling2D β Dense(128, ReLU) β Dense(1, Sigmoid)
Upload single or multiple X-ray images Select DenseNet121 / ResNet50 models Display prediction label + probability Grad-CAM heatmap overlay for interpretability π₯ Batch prediction with CSV download Interactive training/validation curves, ROC curve, confusion matrix Export predictions & heatmaps as PDF reports π
- Model Accuracy Precision Recall AUC
- ResNet50 92β95% High High 0.95+
- DenseNet121 95β97% Very High Very High 0.97+
Notes:
- DenseNet121 generally outperforms ResNet50 due to better feature reuse
- Grad-CAM provides visual interpretability π₯
- Training & Validation Curves β Monitor overfitting/underfitting π
- Confusion Matrix Heatmap β Professional view of True vs Predicted β
- ROC Curve & AUC β Evaluate model performance π
- Grad-CAM Overlay β Highlights regions contributing most to predictions π
- Sample Prediction Gallery β Multiple images with predicted labels πΌοΈ
π₯ Demo (GIF)
> Replace the GIF URL above with your **actual Streamlit app recording** for portfolio-ready visualization.1οΈβ£ Clone repository
git clone https://github.com/ayush13-0/PulmoVision-Pro-AI-Powered-Pneumonia-Detection/tree/main
cd PulmoVision-Pro
2οΈβ£ Create virtual environment
python -m venv venv
# Linux/Mac
source venv/bin/activate
# Windows
venv\Scripts\activate
3οΈβ£ Install dependencies
pip install -r requirements.txt
4οΈβ£ Run Streamlit App
streamlit run PulmoVision-Pro.py
5οΈβ£ Download Dataset
- Kaggle Chest X-Ray Pneumonia
- Organize folder structure as shown above
π Pre-trained Models
- DenseNet121: models/densenet_pulmovision.h5 - ResNet50: models/resnet_pulmovision.h5 - Pre-trained on Kermany X-Ray Pneumonia dataset
:- Ready for inference & Grad-CAM visualization π₯
PulmoVision Pro demonstrates:
- Automated pneumonia detection using CNNs π§
- Transfer learning improves medical imaging performance π
- Professional evaluation using accuracy, precision, recall, F1-score, AUC π
- Grad-CAM visualization for clinician-friendly interpretability π₯
- Fully professional, interactive Streamlit dashboard for deployment π©Ί
Kermany Chest X-Ray Pneumonia Dataset β Kaggle
- He, K. et al. "Deep Residual Learning for Image Recognition", 2015
- Huang, G. et al. "Densely Connected Convolutional Networks", 2017
Aspiring Data Scientist & Analyst
- π« Email: bhanuseenu914@gmail.com
- π GitHub: https://github.com/ayush13-0
- βΉοΈ LinkedIn: www.linkedin.com/in/ayush130
- This project is licensed under the MIT License.
