Authors: Pablo Meseguer1, Rocío del Amor1,2, Valery Naranjo1,2
Journal: Medical Image Analysis (MedIA)
1Universitat Politècnica de València (UPV)
2Artikode Intelligence SL
Clone repository and intall a compatible torch version with your GPU and required libraries.
git clone https://github.com/cvblab/MIL-Adapter.git
cd MIL-Adapter
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
From this link, you can manually download the files including the embeddings extracted with the corresponding foundation model. Each .npy file contain N*d array, where N denotes the number of patches in the slide and d the dimension of the patch-level features. The folder argument should point to the path containing the subfolder <project>\<encoder>.
The impact of classifier initialization in Multiple Instance Learning (MIL) frameworks have been considerably understudied, specially in few-shot learning scenarios where it exists a higher risk of overfitting. You can investigate the performance of different MIL models with randomly initialized classifiers running the following execution.
python main.py --folder <folder> --project NSCLC --encoder CONCH --aggregator ABMIL --adapter ZSMIL --init random --k_shots 4
Note that the --init argument determines if the classification layer is initialized randomly or following the zero-shot (ZS) prototypes. Different choices for the --aggregator and --encoder parameters are provided in the argument parser code.
Vision-language models (VLM) offer the oportunity to leverage prior information about the classification task by using natural language and the VLM text encoders. We rely on textual ensemble learning to reduce prompt dependence and innovately combine VL-adapter for the MIL paradigm.
python main.py --folder <folder> --project NSCLC --encoder CONCH --aggregator ABMIL --adapter TaskRes --init ZS --k_shots 4
Note that all adapters are initialized with the text prototypes using --init ZS. Different choices for the --adapter parameter are provided in the argument parser code.
- Provide code to encode text prototypes with textual ensemble learning.
- Provide code to perform weakly-supervised zero-shot classification.
If you find this work and repository useful, please consider citing this paper:
@article{MESEGUER2026103964,
title = {MIL-Adapter: Coupling multiple instance learning and vision-language adapters for few-shot slide-level classification},
journal = {Medical Image Analysis},
pages = {103964},
year = {2026},
issn = {1361-8415},
doi = {https://doi.org/10.1016/j.media.2026.103964},
url = {https://www.sciencedirect.com/science/article/pii/S1361841526000332},
}
