This repo provides:
Open available slide-level models for whole-slide image (WSI) analysis, including classic MIL architectures and pre-trained slide encoders that operate on patch features.
Open available dataset .json lists for WSI analysis, including classification and survival prediction datasets. You can find the lists in downstream_task_jsons/ and surv_downstream_task_jsons/.
Easy-to-use benchmark scripts for downstream tasks (classification and survival prediction).
MIL models
Pre-trained slide encoders
Run the demo to verify all models:
python demo_test_model.py
Create a model in Python:
from slide_encoder_models.model_registry import create_slide_encoder, list_models
print(list_models())
model = create_slide_encoder("abmil", dim_in=1024, dim_hidden=512, num_classes=2)
downstream_task_jsons/surv_downstream_task_jsons/Edit run_benchmark_all.sh first:
DATA_ROOT="YOUR_DATA_ROOT" to your dataset root.PFM_NAMES=(...), SLIDE_NAME=..., DTYPE=...JSON_DIR=./downstream_task_jsons, SURV_JSON_DIR=./surv_downstream_task_jsons, JOB_DIR=./resultsThen run:
bash run_benchmark_all.sh
run_five_seeds).cptac_* fold tasks, 10 folds × 5 seeds per fold.run_five_seeds_surv).Metrics are written under results/ following the script arguments (dataset / pfm_name / slide_name / seed / benchmark), e.g.:
results/<dataset>/<pfm_name>/<slide_name>/<seed>/benchmark/all_test_metrics.jsonresults/<dataset>/<task>/fold<k>/<pfm_name>/<slide_name>/<seed>/benchmark/all_test_metrics.jsonThis repo also provides lightweight benchmarks for pre-trained slide encoders (WSI encoders) that take patch features as input.
Script: knn_benchmark.py + run_knn_benchmark.sh
*.pth patch-feature files referenced by downstream_task_jsons/*.json (with <PFM_NAME> placeholder in the path).--slide-encoder (pre-trained slide encoders only).knn_results/<pfm_name>/<dataset>/<slide_encoder>/k{k}_{metric}/Run:
# 1) Edit DATA_ROOT in the script
bash run_knn_benchmark.sh
Script: linear_probe_benchmark.py + run_linear_benchmark.sh
linear_probe_results/<pfm_name>/<dataset>/<slide_encoder>/lp_f{num_folds}_pat{patience}/Run:
# 1) Edit DATA_ROOT in the script
bash run_linear_benchmark.sh
For these pre-trained slide encoders, the required patch encoder is fixed (do not mix), and the benchmark scripts enforce this mapping:
conch_v1_5conch_v1_5conch_v1ctranspathvirchow_1prov_gigapathuni_v1uni_v2conch_v1_5uni_v1conchv15 by default (tile_encoder_key also supports hoptimus1, uni2h, gigapath, virchow2)Jiawen Li, jw-li24@mails.tsinghua.edu.cn
12 commits
Python
96.4%
Shell
3.6%
This repo provides:
Open available slide-level models for whole-slide image (WSI) analysis, including classic MIL architectures and pre-trained slide encoders that operate on patch features.
Open available dataset .json lists for WSI analysis, including classification and survival prediction datasets. You can find the lists in downstream_task_jsons/ and surv_downstream_task_jsons/.
Easy-to-use benchmark scripts for downstream tasks (classification and survival prediction).
MIL models
Pre-trained slide encoders
Run the demo to verify all models:
python demo_test_model.py
Create a model in Python:
from slide_encoder_models.model_registry import create_slide_encoder, list_models
print(list_models())
model = create_slide_encoder("abmil", dim_in=1024, dim_hidden=512, num_classes=2)
downstream_task_jsons/surv_downstream_task_jsons/Edit run_benchmark_all.sh first:
DATA_ROOT="YOUR_DATA_ROOT" to your dataset root.PFM_NAMES=(...), SLIDE_NAME=..., DTYPE=...JSON_DIR=./downstream_task_jsons, SURV_JSON_DIR=./surv_downstream_task_jsons, JOB_DIR=./resultsThen run:
bash run_benchmark_all.sh
run_five_seeds).cptac_* fold tasks, 10 folds × 5 seeds per fold.run_five_seeds_surv).Metrics are written under results/ following the script arguments (dataset / pfm_name / slide_name / seed / benchmark), e.g.:
results/<dataset>/<pfm_name>/<slide_name>/<seed>/benchmark/all_test_metrics.jsonresults/<dataset>/<task>/fold<k>/<pfm_name>/<slide_name>/<seed>/benchmark/all_test_metrics.jsonThis repo also provides lightweight benchmarks for pre-trained slide encoders (WSI encoders) that take patch features as input.
Script: knn_benchmark.py + run_knn_benchmark.sh
*.pth patch-feature files referenced by downstream_task_jsons/*.json (with <PFM_NAME> placeholder in the path).--slide-encoder (pre-trained slide encoders only).knn_results/<pfm_name>/<dataset>/<slide_encoder>/k{k}_{metric}/Run:
# 1) Edit DATA_ROOT in the script
bash run_knn_benchmark.sh
Script: linear_probe_benchmark.py + run_linear_benchmark.sh
linear_probe_results/<pfm_name>/<dataset>/<slide_encoder>/lp_f{num_folds}_pat{patience}/Run:
# 1) Edit DATA_ROOT in the script
bash run_linear_benchmark.sh
For these pre-trained slide encoders, the required patch encoder is fixed (do not mix), and the benchmark scripts enforce this mapping:
conch_v1_5conch_v1_5conch_v1ctranspathvirchow_1prov_gigapathuni_v1uni_v2conch_v1_5uni_v1conchv15 by default (tile_encoder_key also supports hoptimus1, uni2h, gigapath, virchow2)Jiawen Li, jw-li24@mails.tsinghua.edu.cn
12 commits
Python
96.4%
Shell
3.6%