Hey! This web app lets you perform 2D brain tumour segmentation on structural MRI scans with a ResU-Net convolutional neural network (CNN). The model is trained on a dataset from the 2021 RSNA-ASNR-MICCAI BraTS Challenge across 4 MRI modalities: T1, T1CE, T2, and FLAIR.
[insert host link here]
[insert video demo here]
You'll need 3 main pieces in place before running this project locally:
- On Windows, install WSL2 (Ubuntu 22.04 recommended)
- On Linux, you can run Docker natively
- On macOS, GPU acceleration isn’t supported (unless you’re using CPU-only builds)
- Install Docker Desktop
- Install the latest NVIDIA drivers for your GPU
- Install the NVIDIA Container Toolkit so that Docker can use your GPU
Verify setup:
docker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smi- Download the brain MRI scans from Kaggle, here
- Inside the
apidirectory, create a new folder and name itdata - Place the downloaded
BraTS2021_Training_Datafolder insidedata(api/data/BraTS2021_Training_Data)
These steps ensure that the preprocessing.py and model.py scripts in api/src/scripts can find the dataset without additional configuration.
# Clone repo and navigate to project dir
git clone https://github.com/aaren-aras/oncer.git && cd oncerFrom the project root, create a .env file and set a port number for the backend (e.g., 5000):
API_PORT=5000
Then, run the following:
chmod +x api/entrypoint.shTo avoid compatibility issues with the latest NVIDIA GPUs (and the ensuing CUDA/cuDNN mismatch headaches), I decided to use NVIDIA's NVIDIA GPU Cloud (NGC) TensorFlow containers for GPU-accelerated CNN training on Windows. These containers come pre-packaged with versions of TensorFlow, CUDA, and cuDNN that are (almost) guaranteed to work together, alongside other stuff for optimizing GPU performance.
After launching Docker Desktop:
# Build backend image
cd api && docker build -t oncer-api .
# Run backend locally (available @ https://localhost:${API_PORT})
cd api && docker compose up --buildYou can close the container with docker compose down.
Alternatively, if you don't want to use Docker/NGC, you could set up Python, TensorFlow, CUDA, and cuDNN manually from your end. This means YOU are responsible for making sure ALL software versions play nicely together, a fate I personally wouldn't wish on my worst enemy (but hey, the choice is yours).
Refer to this table for tested build configurations.
- TensorFlow GPU support outside containers is only guaranteed up to 2.10 (CUDA 11.2, cuDNN 8.1) for Windows
- If you have a newer GPU (e.g., RTX 40/50 series), containers are STRONGLY recommended
cd api
# Install Python deps within virtual env (Windows example)
py -3.10 -m venv .venv
source .venv/Scripts/activate # Git Bash
pip install -r requirements.txt
# Run backend
./entrypoint.shIn another terminal:
# Install Node.js deps
cd ../app && npm install
# Launch dev instance (frontend)
npm run start
# Build and preview prod instance
npm run build
npm run preview- TF GPU compatibility is fragile outside Docker NGC containers
- Windows requires WSL2 for Docker GPU acceleration
- Please stop falling for scope creep
- KNOW your tools, and when/how/why to use them given the scope
- Consider writing the entire backend in Python for all future DL projects
- Docker NGC containers MASSIVELY simplify GPU + CUDA setup for modern NVIDIA GPUs requiring CUDA 12+ (no version mismatch and local rebuild trial-and-error, no Bazel errors, no DLL errors, ...)
- Don't waste time with local installs and juggling Python versions, CUDA toolkits, and cuDNN DLLs on Windows when there're cleaner solutions available
- You don't have to use older versions of software to achieve compatibility
- Some TF builds lack precompiled CUDA kernels for newer GPUs with higher compute capabilities, forcing them to JIT-compile PTX at runtime, which can drastically slow startup; these containers avoid the issue by including prebuilt, GPU-optimized binaries
- Look into multi-GPU setups (distributed training?): https://developer.nvidia.com/nccl
- Implement model in PyTorch with ONNX