Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A healthcare-focused AI tool that analyzes chest X-ray images to assist in identifying signs of pneumonia. Designed to support early diagnosis and streamline clinical workflows with fast, image-based insights.

License

Notifications You must be signed in to change notification settings

Im-Mohammed/PneumoniaDetectionModel

Repository files navigation

🩺 Pneumonia Detection from Chest X-rays

Deep Learning For Early Diagnosis

Pneumonia is a serious respiratory condition that demands timely and accurate diagnosis. This project introduces an intelligent system that analyzes chest X-ray images to detect signs of pneumonia using deep learning. By fine-tuning a pre-trained VGG16 model, the solution offers fast, reliable classification of X-rays as either Normal or Pneumonia, supporting healthcare professionals in early intervention.

Built with clarity, precision, and real-world utility in mind, this tool demonstrates how AI can enhance diagnostic workflows and reduce the burden on clinical staff.


🧬 Dataset

The model is trained on the Chest X-Ray Images (Pneumonia) dataset, which contains 5,863 labeled images:

  • Normal: 1,583 images
  • Pneumonia: 4,273 images

All images are resized to 224×224 pixels to match the input requirements of the VGG16 architecture.


🧠 Model Highlights

This Pneumonia Detection model is built using transfer learning with VGG16 and fine-tuned for binary classification of chest X-ray images. Key architectural and training features include:

  • Architecture:

    • Base: VGG16 (pre-trained on ImageNet)
    • Top Layers: Flatten + Dense(2) with softmax activation
    • Output: Two classes — Normal and Pneumonia
  • Input Configuration:

    • Image size: 224×224 pixels
    • Color channels: RGB (3-channel input)
  • Training Strategy:

    • Frozen convolutional layers to retain learned features
    • Augmented training data using shear, zoom, and horizontal flip
    • Rescaled pixel values for both training and test sets
    • Optimizer: Adam
    • Loss Function: Categorical Crossentropy
    • Epochs: 5 (configurable for deeper training)
  • Batch Processing:

    • Batch size: 32
    • Directory-based image loading with categorical labels
  • Model Output:

    • Trained model saved as chest_xray.h5
    • Ready for deployment or integration into prediction pipelines

⚙️ Installation & Setup

Clone the repository and install dependencies:

git clone https://github.com/Im-Mohammed/PneumoniaDetectionModel.git
cd PneumoniaDetectionModel
pip install -r requirements.txt

Download the dataset from Kaggle and place it in:

./data/chest_xray/

🔧 Training the Model

To begin training:

python train.py

You can adjust key hyperparameters such as batch size, learning rate, and number of epochs:

optimizer = Adam(learning_rate=0.0001)

Modify the model.fit() call to experiment with different training durations.


📈 Performance

The model achieves a training accuracy of 82%, offering a strong baseline for pneumonia detection. With further tuning and data augmentation, this performance can be improved for deployment-ready use cases.


🎥 Demo Video

Experience the model in action:

pnemonia.git.1.mp4

Predicting New Images

Once trained, you can run predictions on new chest X-ray images:

python predict.py --image path/to/image.jpg

The output will classify the image as either:

  • Normal
  • Pneumonia

🤝 Collaboration

This project welcomes contributions from researchers, developers, and healthcare innovators. If you’d like to improve the model, add new features, or adapt it for broader use cases, feel free to fork the repo and submit a pull request:

git checkout -b feature-branch
git commit -m "Add new feature"
git push origin feature-branch

📬 Contact

For questions, feedback, or collaboration opportunities:
📮 Open an Issue


📄 License

This project is licensed under the MIT License.
You’re free to use, modify, and distribute it with attribution.

About

A healthcare-focused AI tool that analyzes chest X-ray images to assist in identifying signs of pneumonia. Designed to support early diagnosis and streamline clinical workflows with fast, image-based insights.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published