Views
No views yet
| Hyperparameter | Value |
|---|---|
Spatial dimensions (d) | 2 (2-D) |
| Encoder/decoder levels | 3 |
| Base feature maps | 64 |
| Kernel size | 3 |
| Upsampling | pixel shuffle |
| Dropout | ✓ |
| Property | Value |
|---|---|
| Input shape | (B, 4, 240, 240) — float32, max-normalized |
| Output — train mode | (B, 3) — raw logits |
| Output — eval mode | ((B, 3), (B, 3, H, W)) — logits and spatial heatmap |
| Class order | [Healthy, LGG, HGG] |
1import torch
2from transformers import AutoConfig, AutoModel
3
4# Load from HuggingFace Hub
5model = AutoModel.from_pretrained("soumickmj/GPShuffleUNet_BraTS2020_T1T2T1ceFlair_Axial", trust_remote_code=True)
6model.eval()
7
8# Inference (B=1 example)
9# x: tensor of shape (1, 4, 240, 240), channels = [T1, T2, T1CE, FLAIR]
10x = torch.randn(1, 4, 240, 240) # replace with real normalised slice
11with torch.no_grad():
12 logits = model(x) # shape: (1, 3)
13 probs = torch.softmax(logits, dim=1)
14 pred = probs.argmax(dim=1) # 0=Healthy, 1=LGG, 2=HGGmodel.train() → GMP is applied → returns logits (B, n_classes) — classification onlymodel.eval() → GMP is skipped → returns (logits, heatmap) where
heatmap has shape (B, n_classes, H, W) — one spatial map per classThe heatmap channels correspond to the same class order as the logits:0 = Healthy, 1 = LGG, 2 = HGG. The whole-tumour map can be obtained by combining channels 1 and 2.
1import torch
2import torch.nn.functional as F
3from transformers import AutoModel
4
5model = AutoModel.from_pretrained("soumickmj/GPShuffleUNet_BraTS2020_T1T2T1ceFlair_Axial", trust_remote_code=True)
6model.eval() # ← activates heatmap mode
7
8x = torch.randn(1, 4, 240, 240) # (B, 4, H, W): [T1, T2, T1CE, FLAIR], max-normalised
9
10with torch.no_grad():
11 logits, heatmap = model(x) # heatmap: (B, 3, H, W)
12
13pred_class = logits.argmax(dim=1) # (B,) — 0=Healthy, 1=LGG, 2=HGG
14
15# --- Whole-tumour heatmap (LGG + HGG channels) ---
16wt_map = heatmap[:, 1:, :, :].max(dim=1).values # (B, H, W)
17
18# --- Min-max normalise to [0, 1] ---
19wt_flat = wt_map.view(wt_map.size(0), -1)
20wt_min = wt_flat.min(dim=1).values[:, None, None]
21wt_max = wt_flat.max(dim=1).values[:, None, None]
22wt_norm = (wt_map - wt_min) / (wt_max - wt_min + 1e-8) # (B, H, W)
23
24# --- Binary mask via simple threshold ---
25binary_mask = (wt_norm > 0.5).float() # (B, H, W)1
2@article{chatterjee2026weakly,
3 title={Weakly-supervised segmentation using inherently-explainable classification models and their application to brain tumour classification},
4 author={Chatterjee, Soumick and Yassin, Hadya and Dubost, Florian and N{\"u}rnberger, Andreas and Speck, Oliver},
5 journal={Neurocomputing},
6 pages={133460},
7 year={2026},
8 publisher={Elsevier}
9}