Are you sure you want to delete this access key?
This repository contains a machine learning project for classifying brain tumors using MRI images. The model is trained to detect and categorize four types of brain conditions from axial brain scan images.
Brain tumors pose a serious health challenge, requiring timely and accurate diagnosis to improve treatment outcomes. Magnetic Resonance Imaging (MRI), especially T1-weighted contrast-enhanced scans, is widely used for brain tumor detection. However, manual interpretation of MRI scans is time-consuming and can be subject to inter-observer variability.
This project aims to automate the classification of brain tumors from MRI images using a machine learning model. The objective is to accurately categorize axial brain scans into one of four classes โ glioma, meningioma, pituitary tumor, or no tumor โ thereby assisting radiologists in diagnosis and reducing diagnostic delays.
The dataset used in this project is sourced from the Kaggle Brain Tumor MRI Dataset. It consists of T1-weighted contrast-enhanced MRI images captured in the axial plane. The images are grouped into four categories, each representing a distinct medical condition:
Each category is stored in a separate subdirectory, and the images are in JPEG format. The dataset is balanced and suitable for supervised image classification tasks.
This project is built using a modern MLOps stack and requires the following tools and libraries:
git clone https://github.com/Danselem/brain_mri.git
cd brain_mri
The project makes use of Makefile
and Astral uv. Click the Astral link to see the details of the package and how to install it.
To create and activate an environment:
make init
make install
make fetch-data
This will fetch the data from Kaggle and store it in the data repo. Ensure you have a Kaggle account and set up your API key.
There are two options to set up MLflow
Use AWS EC2 and S3
Ensure terraform is installed on your PC and you have AWS credentials set up on your PC with aws configure
. Next, cd infra
then follow the instructions in infra for a complete set up of AWS resources including EC2
, RDS
, S3
, Kinesis
, Lambda
, etc.
Use DagsHub
Sign up at Dagshub and obtain an API key and create a project repo. After that, run the command to create a .env
file:
make env
Next, fill the .env
file with the right information.
This project uses Prefect
for running the ML pipeline. To start the prefect server, run the command:
make prefect
This will start a prefect server running at https://127.0.0.1/4200.
To run the pipeline,
make pipeline
This will proceed to load the data, transform it and start the parameter tuning. See image below for the prefect modeling pipeline
It will also log the ML experiments in Dagshub and also register the best model. For example, see below.
.
All experiments ran for this project can be accessed in Dagshub.
fetch-best-model
The above command will fetch the registered model from the Dagshub MLFlow server and save it in the models repo. With this, we are ready to serve the model.
Test the local deployment
make serve_local
Docker
containermake build
make run
make ecr
This uses the ecr bash script to create and container and push to AWS ECR. Here is the sample below:
make ecs
This uses the ecs bash script and deploy the container to AWS ECS. Here is the sample below:
To test your setup or add unit tests:
make test
Performance metrics are saved in the MLFlow server.
This project is for educational and research purposes only. Please refer to the dataset's license on Kaggle for usage terms. This project is licensed under the MIT License.
Made with ๐ป by Daniel Egbo. Feel free to reach out with questions, issues, or suggestions.
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?