This repository contains code and experiments for automated brain tumor segmentation using deep learning, implemented with PyTorch Lightning and Segmentation Models PyTorch (SMP).
The dataset used is BraTS2020, available on Kaggle.
The included Jupyter Notebook (code.ipynb) covers the entire pipeline:
- Data preprocessing and augmentation
- Model setup and training
- Evaluation and visualization
This project uses Python 3.8+ and the following core libraries:
import numpy as np
import os
import h5py
import segmentation_models_pytorch as smp
import pytorch_lightning as pl
from torch.optim import lr_scheduler
import torch
from torch.utils.data import Dataset, DataLoader
import torch.nn.functional as F
from collections import OrderedDict
import random
from tqdm import tqdm
import matplotlib.pyplot as plt
import pickle
from tabulate import tabulate
from PIL import Image
import albumentations as AYou can install everything with:
pip install numpy h5py segmentation-models-pytorch pytorch-lightning torch tqdm matplotlib tabulate pillow albumentationsOr install the dependencies using the requirements.txt
pip install -r requirements.txtThis project uses the BraTS 2020 dataset, a benchmark dataset for brain tumor MRI segmentation tasks.
π¦ Download here:
π BraTS 2020 on Kaggle
-
Clone the repository:
git clone https://github.com/yourusername/ResearchProject.git cd ResearchProject -
(Optional) Create a virtual environment:
python -m venv venv source venv/bin/activate # On Linux/Mac venv\Scripts\activate.bat # On Windows
-
Install dependencies:
pip install -r requirements.txt
-
Download and prepare the dataset (from Kaggle link above).
-
Open the notebook:
jupyter notebook code.ipynb
-
Run all cells to reproduce preprocessing, training, and evaluation.