Skip to content

This project contains the production ready Machine Learning(Deep Learning) solution for detecting and classifying the brain tumor in medical images

License

Notifications You must be signed in to change notification settings

Hassi34/brain-tumor-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Brain Tumor Classification

Typing SVG

Typing SVG

License Build Last Commit Code Size Repo Size License Issue Tracking Open Issues

Following are the main contents to follow, you can jump to any section:

Introduction

Brain tumor detection is a critical task in the field of medical imaging, as it plays a crucial role in diagnosing and treating brain tumors, which can be life-threatening. With the advancement of machine learning and artificial intelligence (AI), vision AI has emerged as a promising approach for accurate and efficient brain tumor detection from medical images. In this project, we aim to develop a vision AI system for brain tumor detection using a level 2 MLOps (Machine Learning Operations) architecture, which includes a robust dvc (Data Version Control) pipeline and a Docker image for seamless production deployment.

MLOps, also known as DevOps for machine learning, is an iterative and collaborative approach that integrates machine learning models into the software development process, ensuring the reliability, scalability, and maintainability of ML models in production. Level 2 MLOps architecture focuses on advanced versioning and reproducibility, ensuring that the ML pipeline is well-documented and can be easily replicated in different environments.

The ultimate goal of our vision AI project is to develop a robust and scalable brain tumor detection system that can be easily deployed in production environments. By leveraging the level 2 MLOps architecture. It will help to minimize the healthcare operational cost and increase the effectiveness of the services by assisting the healthcare provider in accurate decision-making.

Class Activation Map

image

System Design

image

CICD on Circleci

image

DagsHub Data Pipeline

image
Complete Project Data Pipeline is available at DagsHub Data Pipeline

Train Model Locally

Dataset              : Brain Tumor MRI Dataset  
Jupyter Notebooks    : Model Traninig Notebooks                  

The sample images of Glioma, Meningioma, Pituitary and Normal patients are shown in figure below: Image of Brain MRI

Dataset Details

Dataset Name            : Brain Tumor MRI Dataset (Glioma vs Meningioma vs Pituitary vs Normal)
Number of Class         : 4
Number/Size of Images   : Total      : 7023 (151 MB)
                          Training   : 5712 
                          Testing    : 1311 
                         

Results (Performance Metrics)

We have achieved following results with DenseNet121 model for detection of Glioma, Meningioma, Pituitary and Normal patients from Brain MRI images.

 Performance Metrics 
Test Accuracy                                    : 98.9%
Precision                                        : 99.00%
Sensitivity (Glioma)                             : 100% 
Sensitivity (Meningioma)                         : 99% 
Sensitivity (Pituitary)                          : 100% 
Sensitivity (Normal)                             : 99% 
F1-score                                         : 99.00%
AUC                                              : 1.0

Tech Stack Used

1. Python 
2. Data Version Control (DVC) 
3. Docker
4. Machine learning algorithms
5. MLFlow
6. Cloud Computing
7. SMTP Server

Infrastructure

1. DockerHub
2. Google Cloud Storage (GCS)
3. Google Artifact Registry
4. GitHub
5. DaghsHub
6. CircleCI
7. Google App Engine

Run Locally

  • Ensure you have Python 3.7+ installed.

  • Create a new Python Conda environment:

conda create -n venv python=3.10  
conda activate venv 

OR

  • Create a new Python virtual environment with pip:
virtualenv venv
source venv/Scripts/activate

Install dependencies

  pip install -r requirements.txt

Clone the project

  git clone https://github.com/Hassi34/brain-tumor-classification.git

Go to the project directory

  cd brain-tumor-classification

Export the environment variable

# MLFlow
MLFLOW_TRACKING_URI=""
MLFLOW_TRACKING_USERNAME=""
MLFLOW_TRACKING_PASSWORD=""

#DockerHub 
DOCKERHUB_ACCESS_TOKEN=""
DOCKERHUB_USERNAME=""

#GCP
JSON_DCRYPT_KEY=""
GCLOUD_SERVICE_KEY=""
CLOUDSDK_CORE_PROJECT=""
GOOGLE_COMPUTE_REGION=""
GOOGLE_COMPUTE_ZONE=""

#Alerts
EMAIL_PASS=""
SERVER_EMAIL=""
EMAIL_RECIPIENTS=""

Run Pipeline

  dvc repro

REST API with Docker

To run the following commands, ensure you have the docker installed on your system.

Pull Image from Docker Hub

In case you have not already pulled the image from the Docker Hub, you can use the following command:

docker pull hassi34/brain-tumor-classification

Docker Container

Now once you have the docker image from the Docker Hub, you can now run the following commands to test and deploy the container to the web

  • Run a Docker Container
    Check all the available images:
docker images

Use the following command to run a docker container on your system:

docker run --name <CONTAINER NAME> -p 80:8080 -d <IMAGE NAME OR ID>

Check if the container is running:

docker ps

If the container is running, then the API services will be available on all the network interfaces
To access the API service, type localhost in the browser.

Conclusion

This project is production ready for similar use cases and will provide the automated and orchestrated pipeline.

πŸ‘‰πŸ»Thank you for visiting πŸ™ Your feedback would be highly appreciated πŸ’―πŸ˜Š

πŸ‘‰πŸ»If you find this project useful then don't forget to star the repo βœ¨β­πŸ€–

πŸ“ƒ License

MIT Β© Hasanain

Let's connect on LinkedIn

About

This project contains the production ready Machine Learning(Deep Learning) solution for detecting and classifying the brain tumor in medical images

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published