🧠 Stroke Segmentation – Brain CT using Swin UPerNet + CBAM

This project provides a deep learning model for stroke lesion segmentation in brain CT images. Unlike classification (stroke / no stroke), this model predicts pixel-wise lesion masks to localize stroke regions.

🧠 Task

Objective: Given a single axial brain CT slice, predict a binary mask:

0 β†’ Background (No Lesion)

1 β†’ Stroke Lesion

πŸ§ͺ Dataset

Modality: Brain CT

Format: .png slices (converted from DICOM if needed)

Annotations: Binary lesion masks in .png format

Preprocessing:

Hounsfield Unit (HU) windowing & CLAHE applied if original PNG not available

Normalization parameters computed from training set:

mean β‰ˆ 0.189

std β‰ˆ 0.318

Source:

Dataset derived from the TEKNOFEST 2021 Medical AI Competition – Stroke CT Dataset, shared in collaboration with the Turkish Ministry of Health.

⚠️ These anonymized images are used solely for research and educational purposes. Public datasets can be accessed via the Ministry’s Open Data Portal

πŸ—οΈ Model

Backbone: swin_tiny_patch4_window7_224

Head: UPerNet with CBAM attention module

Pretrained Weights: Swin Transformer pretrained on ImageNet-21k

Task: Binary semantic segmentation (stroke lesion vs background)

πŸ”— Pretrained Model

πŸ‘‰ Available on Hugging Face: Sahende/teknofest_ct_stroke_segmentation

Example Usage import torch import numpy as np from PIL import Image from transformers import AutoFeatureExtractor, AutoModelForSemanticSegmentation

Load model and processor

extractor = AutoFeatureExtractor.from_pretrained("Sahende/teknofest_ct_stroke_segmentation") model = AutoModelForSemanticSegmentation.from_pretrained("Sahende/teknofest_ct_stroke_segmentation")

Load image

image = Image.open("example_ct.png").convert("RGB") inputs = extractor(images=image, return_tensors="pt")

Inference

with torch.no_grad(): outputs = model(**inputs) logits = outputs.logits # shape: [1, num_classes, H, W]

Convert to predicted mask (threshold 0.5 for binary mask)

mask = torch.sigmoid(logits)[0,0] > 0.5

print("🧠 Predicted mask shape:", mask.shape)

πŸ“Œ Notes

This model predicts stroke lesion masks at the slice level.

Intended for research use only – not for clinical deployment.

Supports mixed-precision training (AMP) and gradient accumulation.

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support