Multiple Instance Learning with Coarse-to-fine Self-Distillation
We used torch 2.2.0 with CUDA 12.3 on Ubuntu 22.04.3 LTS for implementation. The envrionment can be obtained by:
conda env create -f environment.yml1.1. Create Patches with CLAM
- Clone the CLAM and copy the mrs_bc.csv preset file into ‘CLAM_modified/presets’
- Stitching using CLAM. The presets are
internal_bc.csv,tcga.csvandcamelyon16.csv.
python create_patches_fp.py --source DATA_DIRECTORY --save_dir RESULTS_DIRECTORY --patch_size 256 --preset PRESET_PATH --patch_level 1 --seg --patch --stitch- Generate patches
python generate_patches.py --ann ANN_DIR --src SLIDE_DIR --img_format IMG_FORMAT --save_dir RES_DIR --pbag CLAM_PATCHES_DIR- HuggingFace token is required for using GigaPath.
- Feature dimension for resnet50 is 1024 and for GigaPath is 1536.
python generate_features.py --backbone [resnet50, gigapath] --src PATCH_DIR --save_dir FEAT_DIRpython [main_baselines.py, main_baselines_surv.py] --arch MODEL_NAME --ann ANNOTATION_PATH --split_dir SPLIT_PATH --data_dir FEAT_PATH --res_root RES_PATH --task TASK --lr 2e-4 --gc 32 --epochs 150 --in_dim FEAT_DIM --scheduler CAWR --early_stoppingpython [main_laddermil.py, main_laddermil_surv.py] --arch MODEL_NAME --ann ANNOTATION_PATH --split_dir SPLIT_PATH --data_dir FEAT_PATH --res_root RES_PATH --task TASK --lr 2e-4 --gc 32 --epochs 150 --in_dim FEAT_DIM --scheduler CAWR --early_stopping --pos_enc cegpython eval_baselines.py --arch MODEL_NAME --ann ANNOTATION_PATH --split_dir SPLIT_PATH --eval_csv EVAL_ANNOTATION --data_dir FEAT_PATH --res_root RES_PATH --ckpt_root CHECKPOINT --task TASK
python eval_laddermil.py --arch MODEL_NAME --ann ANNOTATION_PATH --split_dir SPLIT_PATH --eval_csv EVAL_ANNOTATION --data_dir FEAT_PATH --res_root RES_PATH --ckpt_root CHECKPOINT --task TASK --pos_enc ceg