CoolFace
Apppublic

sakethdevx/brain-tumor-segmentation

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
App README

Sample Data

You can download sample NIfTI files for two patients to test the model from this Google Drive link:

Sample Data (Google Drive)

Brain Tumor Segmentation App

<p align="center"> <img src="https://img.shields.io/badge/Streamlit-Online-brightgreen" alt="Streamlit"> <a href="https://huggingface.co/spaces/saketh-005/brain-tumor-segmentation"><img src="https://img.shields.io/badge/HuggingFace-Live%20Demo-yellow" alt="Hugging Face Spaces"></a> </p>

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

  1. 1.Clone this repository:
sh
   git clone https://github.com/saketh-005/brain-tumor-segmentation.git
   cd brain-tumor-segmentation
  1. 1.(Recommended) Create and activate a Python virtual environment:
sh
   python3 -m venv .venv
   source .venv/bin/activate
  1. 1.Install dependencies:
sh
   pip install -r requirements.txt
  1. 1.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.)
  2. 2.Run the app:
sh
   streamlit run app.py
  1. 1.Open your browser to http://localhost:8501 and use the app.

File Structure

  • โ€”app.py - Main Streamlit app
  • โ€”unet_model.py - 3D U-Net model definition
  • โ€”utils.py - Preprocessing, postprocessing, and visualization utilities
  • โ€”requirements.txt - Python dependencies
  • โ€”unet3d_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

Author

Saketh Jangala