Instructions to use Sudheer17/XRay-Classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Sudheer17/XRay-Classifier with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://Sudheer17/XRay-Classifier") - Notebooks
- Google Colab
- Kaggle
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- π©Ί Chest X-Ray Pneumonia Detection using Deep Learning
- π Project Overview
- π Features
- π§ Problem Statement
- π Dataset
- βοΈ Tech Stack
- π Complete Project Architecture
- π End-to-End Workflow
- π§Ή Image Preprocessing Pipeline
- π€ Model 1
- π€ Model 2
- π€ Model 3
- π§ Why VGG16?
- π Saved Models
- π Training Strategy
- π Prediction Pipeline
- π Deployment Architecture
- π Project Structure
- βΆοΈ Installation
- π₯ Example Prediction
- π Future Improvements
- π¨βπ» Author
- β If you found this project helpful
π©Ί Chest X-Ray Pneumonia Detection using Deep Learning
π Project Overview
This project is an AI-powered Chest X-Ray Pneumonia Detection System that automatically classifies chest X-ray images into:
- β NORMAL
- π¦ PNEUMONIA
The project demonstrates multiple Deep Learning approaches and compares their performance using:
- Custom CNN (10 Epochs)
- Improved CNN (20 Epochs)
- Transfer Learning (VGG16)
The trained models are deployed using Flask, while the frontend is developed using Streamlit, creating a complete end-to-end AI medical imaging application.
π Features
β Binary Classification
β Three Deep Learning Models
β Custom CNN Architecture
β Improved CNN Architecture
β Transfer Learning using VGG16
β Real-time Image Prediction
β Flask REST Backend
β Streamlit Interactive UI
β Hugging Face Model Hosting
β GPU Training Support
β Model Comparison
β Confidence Score Prediction
β Production Ready
π§ Problem Statement
Pneumonia is one of the leading causes of death worldwide.
Radiologists inspect Chest X-rays manually which is:
- Time Consuming
- Error Prone
- Expensive
This project automates the diagnosis process using Deep Learning.
π Dataset
Chest X-Ray Dataset
Dataset
β
βββ train
β βββ NORMAL
β βββ PNEUMONIA
β
βββ validation
β βββ NORMAL
β βββ PNEUMONIA
β
βββ test
βββ NORMAL
βββ PNEUMONIA
Image Format
- JPG
- JPEG
- PNG
Classes
| Label | Description |
|---|---|
| NORMAL | Healthy Lung |
| PNEUMONIA | Infected Lung |
βοΈ Tech Stack
Programming
- Python
Deep Learning
- TensorFlow
- Keras
Computer Vision
- OpenCV
- NumPy
- Matplotlib
Backend
- Flask
Frontend
- Streamlit
Deployment
- Hugging Face
- Render
Version Control
- Git
- GitHub
π Complete Project Architecture
Chest X-Ray Image
β
βΌ
Upload Image (UI)
β
βΌ
Streamlit Frontend
β
βΌ
Flask REST API
β
βΌ
Image Preprocessing
β
ββββββββββββββββββββΌββββββββββββββββββββ
β β β
βΌ βΌ βΌ
CNN Model CNN 20 Model VGG16 Model
β β β
ββββββββββββββββββββΌββββββββββββββββββββ
β
βΌ
Prediction Probability
β
βΌ
NORMAL / PNEUMONIA Result
β
βΌ
Display Prediction
π End-to-End Workflow
Dataset
β
βΌ
Image Loading
β
βΌ
Image Preprocessing
β
βΌ
Resize Images (100x100)
β
βΌ
Convert to Array
β
βΌ
Normalize Images
β
βΌ
Train / Validation Split
β
βΌ
Model Training
β
βΌ
Model Evaluation
β
βΌ
Save Best Model
β
βΌ
Deploy Model
β
βΌ
User Upload Image
β
βΌ
Prediction
π§Ή Image Preprocessing Pipeline
Each X-Ray undergoes the following preprocessing steps:
Step 1
Load Image
β
Step 2
Convert to Grayscale (CNN Models)
β
Step 3
Convert to RGB (VGG16)
β
Step 4
Resize
100 Γ 100
β
Step 5
Convert to NumPy Array
β
Step 6
Normalize Pixel Values
0 β 255
β
0 β 1
β
Step 7
Feed into Model
π€ Model 1
Custom CNN (10 Epochs)
Architecture
Input (100Γ100Γ1)
β
Conv2D (64)
β
MaxPooling
β
Dropout
β
Conv2D (128)
β
MaxPooling
β
Dropout
β
Conv2D (256)
β
MaxPooling
β
Dropout
β
Flatten
β
Dense (64)
β
Dropout
β
Dense (1)
β
Sigmoid
Loss
Binary Crossentropy
Optimizer
Adam
Epochs
10
π€ Model 2
Improved CNN (20 Epochs)
Architecture
Input
β
Conv2D (64)
β
ReLU
β
MaxPooling
β
Dropout
β
Conv2D (128)
β
ReLU
β
MaxPooling
β
Dropout
β
Conv2D (256)
β
ReLU
β
MaxPooling
β
Dropout
β
Flatten
β
Dense (64)
β
Dropout
β
Dense (1)
β
Sigmoid
Epochs
20
Optimizer
Adam
Loss
Binary Crossentropy
π€ Model 3
Transfer Learning (VGG16)
Pretrained
ImageNet
Frozen Layers
All VGG16 Convolution Layers
Custom Head
Flatten
β
Dense (256)
β
Dense (128)
β
Dense (64)
β
Dense (1)
β
Sigmoid
Callbacks
- ModelCheckpoint
- EarlyStopping
π§ Why VGG16?
Instead of training from scratch,
VGG16 already knows how to detect
- Edges
- Shapes
- Textures
- Patterns
Only the classifier is trained on Chest X-rays.
This greatly improves performance while reducing training time.
π Saved Models
model_xray.h5
Custom CNN
model_pre.h5
Improved CNN
best_model.keras
Best Transfer Learning Model
π Training Strategy
- GPU Training
- Batch Size = 4 (CNN)
- Batch Size = 32 (VGG16)
- Validation Dataset
- Binary Crossentropy
- Adam Optimizer
- Early Stopping
- Model Checkpoint
π Prediction Pipeline
Upload Image
β
Read Image
β
Resize
β
Preprocess
β
Load Model
β
Predict Probability
β
Threshold = 0.5
β
NORMAL
or
PNEUMONIA
π Deployment Architecture
User
β
βΌ
Streamlit Frontend
β
βΌ
Flask Backend
β
βΌ
Load Selected Model
β
βββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
CNN10 CNN20 VGG16
β β β
βββββββββββββΌβββββββββββββ
βΌ
Prediction Engine
β
βΌ
Display Result
π Project Structure
Chest-XRay-Pneumonia-Detection
β
βββ app.py
βββ config.py
βββ predictor.py
βββ utils.py
βββ requirements.txt
βββ README.md
β
βββ models
β βββ model_xray.h5
β βββ model_pre.h5
β βββ best_model.keras
β
βββ static
β
βββ templates
β
βββ css
β
βββ dataset
β
βββ screenshots
βΆοΈ Installation
Clone Repository
git clone https://github.com/yourusername/Chest-XRay-Pneumonia-Detection.git
Install Dependencies
pip install -r requirements.txt
Run Flask
python app.py
Run Streamlit
streamlit run app.py
π₯ Example Prediction
Input
Chest X-Ray Image
β
Model Prediction
Probability : 0.9821
Prediction :
π¦ PNEUMONIA
π Future Improvements
- EfficientNet
- ResNet50
- DenseNet121
- Grad-CAM Heatmaps
- Multi-Class Disease Detection
- DICOM Support
- Cloud Deployment
- Docker
- CI/CD Pipeline
- REST API Authentication
π¨βπ» Author
Sudheer Muthyala
B.Tech β Electronics and Communication Engineering
Machine Learning | Deep Learning | Computer Vision | Python | Flask | Streamlit
GitHub: https://github.com/M-Sudheer18
β If you found this project helpful
Please consider giving this repository a β on GitHub. It motivates future improvements and helps others discover the project.
- Downloads last month
- 61