Downloads · 30 days
0
classicmaster/mastiskhnet-brain-tumor-segmentation
mastiskhnet-brain-tumor-segmentation is a image segmentation model from classicmaster. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
MastiskhNet is a 3D Attention U-Net trained on the BraTS 2020 dataset to segment brain tumors from multi-modal MRI volumes (FLAIR, T1, T1ce, T2). It outputs a voxel-wise segmentation into background, necrotic/non-enha…
Downloads · 30 days
0
Access
Public
Updated Aug 7, 2026
Parameters
22.7M
669 MB on disk
Likes
2
Public
Click a slice to open those files.
.pth363 MB · 77%
From the Hugging Face model README
MastiskhNet is a 3D Attention U-Net trained on the BraTS 2020 dataset to segment brain tumors from multi-modal MRI volumes (FLAIR, T1, T1ce, T2). It outputs a voxel-wise segmentation into background, necrotic/non-enhancing core, edema, and enhancing tumor.
This repo contains the trained weights, standalone architecture code, and an inference script, built as part of the MastiskhNet project (backend, doctor portal, and mobile app for AI-assisted brain tumor analysis).
Evaluated on the held-out BraTS 2020 test split (56 batches), using EMA weights + test-time augmentation.
| Metric | Score |
|---|---|
| Test Loss | 0.1926 |
| Dice (Tumor Classes) | 0.7293 |
| IoU (Tumor Classes) | 0.6164 |
| Voxel Accuracy | 0.9900 |
| Class | Dice Score |
|---|---|
| Necrotic / Non-Enhancing Core | 0.7503 |
| Edema | 0.8046 |
| Enhancing Tumor | 0.8414 |
| Region | Dice Score |
|---|---|
| Whole Tumor (WT) | 0.9181 |
| Tumor Core (TC) | 0.8678 |
| Enhancing Tumor (ET) | 0.8414 |
Training converged over 100 epochs, reaching a best validation Dice of 0.7139 (validation loss 0.1932).
| File | Description |
|---|---|
model.py | Standalone AttentionUNet3D architecture definition (required to load the weights) |
best_model.pth | Trained model weights (raw, full precision) |
best_model_ema.pth | EMA-averaged weights (typically more stable for inference) |
model.safetensors | Weights in safetensors format |
inference.py | Standalone script to run inference on a preprocessed .npy MRI volume |
evaluation_report.md | Full evaluation report generated during training |
final_summary.csv | Test metrics as CSV |
report_figures/ | Training curves, prediction vs. ground-truth comparisons, overlay visualizations |
inference_output/ | Sample inference result on an unseen test volume |
from model import AttentionUNet3D
import torch
model = AttentionUNet3D()
checkpoint = torch.load("best_model.pth", map_location="cpu")
# Checkpoints saved via the training loop are wrapped in a dict
state_dict = checkpoint["model_state_dict"] if "model_state_dict" in checkpoint else checkpoint
model.load_state_dict(state_dict, strict=False)
model.eval()
# volume: torch.Tensor of shape (1, 4, 128, 128, 128) — FLAIR, T1, T1ce, T2, Z-score normalized
with torch.no_grad():
logits = model(volume)
prediction = torch.argmax(logits, dim=1) # (1, 128, 128, 128), values 0-3
Or use the provided script:
python inference.py --volume path/to/volume.npy --model best_model.pth
from model import AttentionUNet3D
from safetensors.torch import load_file
model = AttentionUNet3D()
model.load_state_dict(load_file("model.safetensors"))
model.eval()
Volumes must be preprocessed identically to training before inference:
nibabel{0, 1, 2, 4} → contiguous {0, 1, 2, 3}(4, 128, 128, 128) tensorIf you use this model, please cite the BraTS 2020 dataset:
Menze et al., "The Multimodal Brain Tumor Image Segmentation Benchmark (BRATS)", IEEE Transactions on Medical Imaging, 2015.