This repository contains the code and resources for a Brain Tumor Detection project using Convolutional Neural Networks (CNN) with PyTorch. The project involves analyzing CT images of the brain to differentiate between healthy and tumor-affected images.
- Introduction
- Dataset
- Project Structure
- Installation
- Usage
- Model Development
- Training and Evaluation
- Web Application
- Results
- Contributing
The Brain Tumor Detection project aims to accurately classify brain CT images as either healthy or tumor-affected. This project leverages deep learning techniques using PyTorch to build and train a CNN model. The trained model is then deployed in a Flask-based web application to provide real-time classification of brain CT images.
The dataset used for this project consists of CT images of the brain, sourced from Kaggle. It includes images of both healthy and tumor-affected brains.
brain-tumor-detection/ ├── pycache/ ├── model/ │ └── model.pth ├── static/ │ ├── css/ │ └── uploads/ ├──templates/ │ ├── detect.html │ └── index.html ├── README.md ├── tumor.py ├── app.py ├──Brain Tumor Detection.pptx └──Tumor Detector.ipynb
-
Clone the repository:
git clone https://github.com/yourusername/brain-tumor-detection.git cd brain-tumor-detection
-
Install the required packages:
requirements:
python
pyTorch(visual) (checkout from their website for others libraries)
numpy
pandas
sklearn
matplotlib
seaborn
flask
sh
pip install -r requirements.txt
-
Preprocess the data:
cd notebooks jupyter Tumor Detector.ipynb.ipynb
-
Train the model:
jupyter Tumor Detector.ipynb.ipynb
-
Run the web application: flask run
The CNN model is built using PyTorch. Key components include:
- Data preprocessing using NumPy and Pandas for resizing and format standardization.
- Custom dataset and dataloader classes to manage image data.
- A CNN model for classifying brain images.
The model is trained over approximately 600 epochs. The training process involves:
- Splitting the dataset into training and validation sets.
- Using data augmentation techniques to improve model generalization.
- Monitoring the model's performance and checking for overfitting.
The trained model is deployed in a Flask-based web application. The web app allows users to upload brain CT images and receive real-time classification results, indicating whether the image depicts a healthy brain or one with a tumor.
The model's performance is evaluated based on metrics such as accuracy, precision, recall, and F1-score. Graphical representations of the results are provided using Matplotlib and Seaborn.
Contributions are welcome.