-
This pneumonia classifier application takes a chest X-ray image as input and classifies it as either
pneumonia
ornormal
. -
The frontend of the application is created with the Python open-source library Streamlit.
-
For classification, we use Resnet18, a deep learning model known for image recognition tasks, which has an accuracy of 80% on our test dataset.
-
We selected this model after experimenting with conventional machine learning model, custom cnn architecture, vision transformer pretrained model, and various deep learning pretrained models.
-
We achieved the highest accuracy of 86% with the Vision Transformer (ViT), but we selected Resnet18 to balance performance and complexity, Resnet18 is generally faster and more lightweight compared to ViT.
-
The application is deployed to Hugging Face Spaces and is now live. You can access it here: Pneumonia Classifier
- The dataset used are Chest X-Ray Images (Pneumonia).
- It have total 5,863 X-Ray images (JPEG).
- The dataset is organized into three main folders:
train
,val
andtest
. - The dataset consist of two categories:
PNEUMONIA
: 3875 imagesNORMAL
: 1341 images
Model | Accuracy (%) |
---|---|
Conventional Machine Learning (SVM) | 0.75 |
Custom CNN | 0.80 |
VGG16 | 0.79 |
EfficientNet-B0 | 0.80 |
Resnet18 | 0.80 |
ViT | 0.86 |
-
Clone the Repository:
git clone https://github.com/ImranNawar/pneumonia-classifier.git
-
Navigate to the Directory:
cd pneumonia-classifier
-
Install Dependencies:
pip install requirements.txt
-
Train the Models:
- Open the notebook
pneumonia-classifer.ipynb
- Run all the cells to train all the models or just specific cells, if you want to train or finetune a specific model.
- Open the notebook
-
Run the Application:
cd src streamlit run main.py
pneumonia-classifier/
├── content/
│ ├── plots/
│ ├── app_interface.png
│ └── background.jpg
├── data/ # ignored in .gitignore
│ ├── test/
│ │ ├── NORMAL/
│ │ └── PNEUMONIA/
│ ├── train/
│ │ ├── NORMAL/
│ │ └── PNEUMONIA/
│ └── val/
│ ├── NORMAL/
│ └── PNEUMONIA/
├── model/
│ ├── label.txt
│ └── resnet18.pth # ignored in .gitignore
├── src/
│ ├── main.py
│ └── util.py
├── training/
│ └── pneumonia-classifier.ipynb
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt
This project is licensed under the MIT License.