A comprehensive deep learning solution for automated brain tumor classification using MRI scans. This project leverages a state-of-the-art EfficientNet architecture to accurately detect and classify three types of brain tumors: glioma, meningioma, and pituitary tumors.
The system is deployed as a production-ready web application that allows medical professionals to upload MRI scans and receive instant predictions with visualization of the model's decision process using GradCAM technology.
Built with modern MLOps practices, the pipeline includes containerized deployment on AWS cloud infrastructure, managed through infrastructure-as-code principles.
Key features:
- Real-time tumor classification with confidence scores
- Advanced visualization of model attention using GradCAM
- Scalable cloud deployment using AWS EC2 and ECR
- Infrastructure automation with Terraform
- Interactive web interface built with Streamlit
- Deep Learning: PyTorch, torchvision
- Cloud Services: AWS (EC2, ECR)
- Infrastructure: Terraform
- Containerization: Docker
- Web Interface: Streamlit
- Development: Python, Git
root_directory/
│
├── app.py
├── Dockerfile
├── data/
├── models/
├── notebooks/
├── terraform/
├── utils/
├── README.md
└── requirements.txt
-
Install AWS CLI if not installed
brew install awscli -
Configure AWS credentials
aws configure -
Create ECR repository
aws ecr create-repository --repository-name <repository-name> -
Get ECR login credentials and login
aws ecr get-login-password --region <aws-region> | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com -
Tag image for ECR
docker tag <docker-image-name>:<tag> <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com/<docker-image-name>:<tag> -
Push image to ECR
docker push <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com/<docker-image-name>:<tag>
-
Provision infrastructure with Terraform
terraform -chdir=terraform apply
-
Download the
.pemfile and set permissions:chmod 400 <your-key-file.pem>
-
Connect to the EC2 via SSH
ssh -i </path/to/key-file.pem> ec2-user@<instance-public-ip>
-
Install Docker
sudo yum install docker -y sudo service docker start sudo usermod -a -G docker ec2-user newgrp docker
-
Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
-
Configure AWS region
aws configure -
aws ecr get-login-password --region <aws-region> | docker login --username AWS --password-stdin <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com -
Pull container
docker pull <aws-account-id>.dkr.ecr.<aws-region>.amazonaws.com/<docker-image-name>:<tag> -
Run container
docker run -d -p 8501:8501 <aws-account-id>.dkr.ecr.us-east-1.amazonaws.com/<docker-image-name>:<tag> -
Access the Stramlit app using the EC2 public IP address:
http://<ec2-public-ip>:8501
-
To destory the infrastructure provisioned
terraform -chdir=terraform destroy
- Headstarter.co
- Matteo Pilotto
