Views
No views yet
1import torch
2from synthstroke_model import SynthStrokeModel
3
4# Load the model from Hugging Face Hub
5model = SynthStrokeModel.from_pretrained("liamchalcroft/synthstroke-synth")
6
7# Prepare your input (example shape: batch_size=1, channels=1, H, W, D)
8input_tensor = torch.randn(1, 1, 192, 192, 192)
9
10# Get predictions (with optional TTA for improved accuracy)
11predictions = model.predict_segmentation(input_tensor, use_tta=True)
12
13# Get tissue probability maps
14background = predictions[:, 0] # Background
15gray_matter = predictions[:, 1] # Gray Matter
16white_matter = predictions[:, 2] # White Matter
17partial_volume = predictions[:, 3] # Gray/White Matter PV
18csf = predictions[:, 4] # Cerebro-Spinal Fluid
19stroke = predictions[:, 5] # Stroke lesion
20
21# Alternative: Get logits without TTA
22logits = model.predict_segmentation(input_tensor, apply_softmax=False)1@article{chalcroft2025synthetic,
2 title={Synthetic Data for Robust Stroke Segmentation},
3 author={Chalcroft, Liam and Pappas, Ioannis and Price, Cathy J. and Ashburner, John},
4 journal={Machine Learning for Biomedical Imaging},
5 volume={3},
6 pages={317--346},
7 year={2025},
8 publisher={Machine Learning for Biomedical Imaging},
9 doi={10.59275/j.melba.2025-f3g6},
10 url={https://www.melba-journal.org/papers/2025:014.html}
11}1@article{Chalcroft_2025,
2 title={Synthetic Data for Robust Stroke Segmentation},
3 volume={3},
4 ISSN={2766-905X},
5 url={http://dx.doi.org/10.59275/j.melba.2025-f3g6},
6 DOI={10.59275/j.melba.2025-f3g6},
7 number={August 2025},
8 journal={Machine Learning for Biomedical Imaging},
9 publisher={Machine Learning for Biomedical Imaging},
10 author={Chalcroft, Liam and Pappas, Ioannis and Price, Cathy J. and Ashburner, John},
11 year={2025},
12 month=aug, pages={317–346}
13}