Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available: 1.56.0
metadata
title: Brain Tumor Segmentation
emoji: 🧠
colorFrom: blue
colorTo: pink
sdk: streamlit
sdk_version: 1.48.1
app_file: app.py
pinned: false
license: mit
Sample Data
You can download sample NIfTI files for two patients to test the model from this Google Drive link:
Brain Tumor Segmentation App
This project is a web application for brain tumor segmentation from 3D/4D NIfTI MRI scans using a 3D U-Net model, built with PyTorch and Streamlit.
Live Demo
👉 Try the app instantly on Hugging Face Spaces:
https://huggingface.co/spaces/saketh-005/brain-tumor-segmentation
No installation required. Just open the link, upload your NIfTI files, and view the results.
Features
- Upload four 3D NIfTI brain scans (T1, T1ce, T2, FLAIR)
- Automatic preprocessing and patch-based inference
- Visualizes the predicted tumor mask overlayed on the MRI
Local Usage
- Clone this repository:
git clone https://github.com/saketh-005/brain-tumor-segmentation.git cd brain-tumor-segmentation - (Recommended) Create and activate a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate - Install dependencies:
pip install -r requirements.txt - Download the trained model file (
unet3d_model.pth) and place it in this directory. (Due to file size, it is not included in the repo. Please contact the author or use your own trained model.) - Run the app:
streamlit run app.py - Open your browser to http://localhost:8501 and use the app.
File Structure
app.py- Main Streamlit appunet_model.py- 3D U-Net model definitionutils.py- Preprocessing, postprocessing, and visualization utilitiesrequirements.txt- Python dependenciesunet3d_model.pth- Trained model weights (not included)
Notes
- The model file (
unet3d_model.pth) must be trained and exported separately. - For large files, use cloud storage and provide a download link in this README or in your Hugging Face Space.
- For best results, ensure all input NIfTI files have the same dimensions and orientation.
License
MIT License