Copied from the ML-Capsule repository, where I had contributed as a GSSoC'24 participant.
This project implements different ways of pneumonia prediction from Chest X-Ray images. Used custom built CNN model as well as various pre-trained models. The details of the performances of the above models can be found in the Models directory. The best-fitting model is used for prediction in the web app.
Dataset Kaggle Link, by Paulo Breviglieri
*Adapted version of Paul Mooney's 'Chest X-Ray Images (Pneumonia)' dataset, where the amount of observations for training and validation purposes was redistributed to allow for a more balanced machine learning exercise.
-
Data Augmentation: Used
ImageDataGeneratorclass for augmenting images with the following params whose ranges were supplied:-
brightness_range : Varies brightness
-
height_shift_range : Shifts the image vertically to a random value
-
width_shift_range : Shifts the image horizontally to a random value
-
rotation_range : Rotates the image to a random degree
-
zoom_range : Zooms the image to a random degree
-
preprocessing_function : Passed the preprocessing function of the respective pretrained model being used.
-
-
Built custom CNN model
-
Transfer Learning Techniques: VGG-16, ResNet50V2, MobileNet and Xception
-
Model Evaluation: Used classification metrics and graphs for visualization
- For running on localhost : Prepare the environment by installing all the requirements from
requirements.txtThen type the following command in the terminal :streamlit run app.py
-
tensorflow~=2.15.0
-
keras~=2.15.0
-
matplotlib
-
opencv-python
-
pillow
-
numpy
-
scikit-learn
-
seaborn
Available in the
requirements.txtfile
VGG 16 was performing the best among the other pre-trained models.
VGG 16 classification metrics with graphs :
![]() |
|---|
| Loss and Accuracy curves |
![]() |
![]() |
|---|---|
| Confusion matrix | Classification report |
-
I have originally used Python version
3.11for this project. -
Install the required packages from the
requirements.txtfile by using one of the following commands in the terminal: -
pip install -r requirements.txt(forpipenvironment) -
conda install --yes --file requirements.txt(forcondaenvironment)
The model accuracy could be improved so as to become fairly acceptable for clinical trials and real-life usage.
The Pneumonia class can be further classified into Bacterial Pneumonia or Viral Pneumonia.
Subhranil Nandy GSSoC 2024 contributor
Connect with me :)
-
LinkedIn: subhranil-nandy -
GitHub: Subhranil2004





