Pneumonia Classification Made Accessible: A Web-Based ML Application

This project focuses on developing a simple yet effective web application to classify chest X-ray images as either “Pneumonia” or “Normal.” Using Python and StreamLit, the application is designed to provide seamless integration of machine learning into a user-friendly web interface.

The application of machine learning in health tech is an invaluable tool, offering the potential to assist medical professionals with accurate, data-driven insights. While this project does not aim to replace medical expertise, it highlights how technology can complement healthcare efforts by providing accessible and efficient diagnostic support.

Pneumonia Classifier Web App

You can see the application in action above (double-click for full screen).

If you have any x-ray images laying around, that you want to test yourself, you can do so here: https://mbm-pneumonia-classifier.streamlit.app/

Technical Details

Objective

Train a convolutional neural network (CNN) to classify chest X-rays and deploy it through a web application using Streamlit.

Tools & Technologies:

  • Programming Languages:

    • Python

  • Libraries and Frameworks:

    • TensorFlow: Model architecture, training, and prediction.

    • Streamlit: Web application framework for deployment.

    • Pillow (PIL): Image preprocessing.

    • NumPy: Image normalisation and data manipulation.

Steps Implemented

  1. Training the Model: A CNN was trained on a dataset of labeled chest X-ray images to differentiate between “Pneumonia” and “Normal” cases.

  2. Evaluation: A confusion matrix was generated to analyse the accuracy of the model for each category.

  3. Preprocessing: Uploaded images are resized to 224x224 pixels and normalised for compatibility with the trained model.

  4. Classification: Predictions are displayed allowing users to evaluate results directly within the web application.

Balancing Accuracy Across Categories

Initial model predictions showed an imbalance, with higher accuracy for “Pneumonia” at the expense of “Normal” classifications.

Solution: Implemented a confidence-based classification threshold to refine predictions. This approach improved overall performance, particularly for the “Normal” category, without compromising accuracy for “Pneumonia.”

Takeaways

This project demonstrates the technical intricacies of building and deploying a machine learning model while addressing challenges in balancing model accuracy. By integrating these elements into a functional web application, the classifier offers a glimpse into the potential of accessible machine learning solutions.

The project also underscores the transformative potential of machine learning in health tech. With careful implementation and collaboration with medical professionals, tools like these can provide timely and accurate insights to enhance healthcare outcomes. While this classifier serves as a demonstration, it highlights the exciting opportunities for future advancements at the intersection of technology and medicine.

Acknowledgment

This project was part of the Computer Vision in 30 Days Coding Challenge, led by Felipe (Computer Vision Engineer on YouTube). His tutorials provided invaluable guidance on structuring the application and troubleshooting common pitfalls.

Next
Next

Image Classification with Scikit-Learn and Feature Extraction