An AI-powered system for detecting brain aneurysms in CT scan images using PyTorch and AWS SageMaker.
This project implements a deep learning model that analyzes brain CT scans to detect potential aneurysms. It uses a VGG16-based architecture and can be deployed as a serverless endpoint on AWS SageMaker.
- Python 3.9+
- AWS Account with SageMaker access
- Docker (for local testing)
- Required Python packages (see
requirements.txt)
- Create and activate virtual environment:
./setup_venv.sh- Install dependencies:
pip install -r requirements.txt- Setup AWS infrastructure:
./setup_aws_infrastructure.sh.
├── my_model/
│ ├── model.pth # Your trained model weights
│ └── code/
│ ├── inference.py # Model inference code
│ └── requirements.txt # Inference dependencies
├── test-local.ipynb # Local testing notebook
├── final.ipynb # Deployment notebook
├── setup_aws_infrastructure.sh
├── setup_venv.sh
├── requirements.txt
└── Dockerfile
- Architecture: Modified VGG16
- Input: Brain CT scan images (224x224 RGB)
- Output: Binary classification (Aneurysm/Non-aneurysm)
- Framework: PyTorch 2.1.0
- Package your trained model:
# Ensure your model.pth is in the my_model/ directory
tar -czf model.tar.gz my_model/-
Open
final.ipynbin Jupyter and follow the deployment steps. -
The deployment will create a serverless SageMaker endpoint.
-
Local testing:
- Use
test-local.ipynbto verify model functionality
- Use
-
Endpoint testing:
- Use the provided test functions in
final.ipynb - Test with sample CT scan images via URLs
- Use the provided test functions in
import boto3
import json
def invoke_endpoint(endpoint_name, image_url):
runtime = boto3.client('sagemaker-runtime')
response = runtime.invoke_endpoint(
EndpointName=endpoint_name,
ContentType='application/json',
Body=json.dumps({"url": image_url})
)
return json.loads(response['Body'].read().decode())Required AWS environment variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGION
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- VGG16 architecture from torchvision
- AWS SageMaker team for serverless inference capabilities
Remember to bring your own trained model (model.pth). This repository does not include pretrained weights.