Views
No views yet
pip install medicalmultitaskmodeling, m3-sdk1from mmm.api.M3Model import M3Model, M3_MODELS, WSC_MTL_TINY
2# The downloaded .zip contains the .pt weights for the encoder, squeezer and grouper.
3# Load the selected Model
4model = M3Model(M3_MODELS[WSC_MTL_TINY])
5# Should give you dict_keys(['encoder', 'squeezer', 'grouper'])
6print(model.keys())1# now test the forward pass.
2test = torch.rand((10,3,224,224))
3
4with torch.no_grad():
5 model_in = test.to(model.device)
6 # We first obtain the pyramid features of the encoder
7 pyramid = model['encoder'](model_in)
8 # then pass it to obtain the latent representation of each instance
9 _, latent = model['squeezer'](pyramid)
10 latent = torch.nn.Flatten(start_dim=1)(latent)
11
12 # And group all instances.
13 # Notice the second argument in the forward pass. Here we define which instances of the batch belong together.
14 # In this case, all of the 10 instances belong to the same bag. Therefore we simply use ones.
15 wsi_vector, attention_per_head = model['grouper'](latent, torch.ones((10,), dtype=torch.long, device=model.device))
16
17# We obtain the latent_wsi vector of shape (1, 768) and the attention weights per head of shape (10, 8)
18wsi_vector.shape, attention_per_head.shape@misc{nicke2026slideconceptssupervisedfoundation,
title={Whole Slide Concepts: A Supervised Foundation Model For Pathological Images},
author={Till Nicke and Daniela Schacherer and Jan Raphael Schäfer and Natalia Artysh and Antje Prasse and André Homeyer and Andrea Schenk and Henning Höfener and Johannes Lotz},
year={2026},
eprint={2507.05742},
archivePrefix={arXiv},
primaryClass={eess.IV},
url={https://arxiv.org/abs/2507.05742},
}
@article{schafer2024overcoming,
title={Overcoming data scarcity in biomedical imaging with a foundational multi-task model},
author={Sch{\"a}fer, Raphael and Nicke, Till and H{\"o}fener, Henning and Lange, Annkristin and Merhof, Dorit and Feuerhake, Friedrich and Schulz, Volkmar and Lotz, Johannes and Kiessling, Fabian},
journal={Nature Computational Science},
volume={4},
number={7},
pages={495--509},
year={2024},
publisher={Nature Publishing Group US New York}
}