This repository implements a Convolutional Neural Network (CNN) to classify chest X-ray images into NORMAL or PNEUMONIA.
The project follows a structured deep learning workflow, including dataset preparation, preprocessing, training, evaluation, and visualization of results.
We use the Chest X-Ray Images (Pneumonia) dataset from Kaggle.
📥 Dataset link: Chest X-Ray Dataset (Kaggle)
data/chest_xray/
├── train/
│ ├── NORMAL/
│ └── PNEUMONIA/
├── val/
│ ├── NORMAL/
│ └── PNEUMONIA/
└── test/
├── NORMAL/
└── PNEUMONIA/
- Train: used for training the CNN
- Validation: used for tuning hyperparameters
- Test: used for final evaluation
Before training, the dataset undergoes image preprocessing and augmentation to improve generalization:
- ✅ Resizing images to 150×150 pixels
- ✅ Normalizing pixel values to range [0, 1]
- ✅ Data augmentation:
- Random rotations
- Width/height shifts
- Zoom operations
- Horizontal flips
This ensures the model is robust and reduces overfitting.
The end-to-end workflow of the project:
- Dataset Loading → Load train/val/test splits
- Preprocessing & Augmentation → Resize, normalize, and augment images
- Training → Early stopping and checkpointing for best model
- Evaluation → Classification metrics & confusion matrix
- Visualization → Training curves and prediction samples
- Python 3.8+
- TensorFlow / Keras (Deep Learning Framework)
- NumPy, scikit-learn (Data Handling & Metrics)
- ✅ Model achieves high accuracy in distinguishing NORMAL vs PNEUMONIA X-rays
- ✅ Confusion matrix & classification report included
- ✅ Visualization of training curves and sample predictions
- Accuracy and loss plots for training & validation
- Example predictions with true vs predicted labels
🚀 Try the model here: Live Demo Link
xray_classification/
├── data/ # Chest X-ray dataset
├── models/ # Saved trained models
├── results/ # Training history, plots, evaluation
├── src/ # Source code
│ ├── data_loader.py # Data loading & augmentation
│ ├── xray_classifier.py # CNN model architecture
│ ├── evaluate.py # Evaluation metrics
├── train.py # Training script
├── run.py # Run evaluation & predictions
├── requirements.txt # Dependencies
├── README.md # Project documentation
└── LICENSE # MIT License
# Clone the repository
git clone https://github.com/Vedag812/Image_Classification
cd xray_classification
# Install dependencies
pip install -r requirements.txt
# Train the model
python train.py
# Run evaluation & predictions
python run.pyThis project is licensed under the MIT License.
🔬 Built with Deep Learning to advance healthcare AI solutions.