Skip to content

A library that integrates different MIL methods into a unified framework

Notifications You must be signed in to change notification settings

lingxitong/MIL_BASELINE

Repository files navigation



MIL_BASELINE

A library that integrates different MIL methods into a unified framework

UPDATES INFO

2024-07-20

  • fix bug of all MIL-models expect DTFD-MIL

2024-07-21

  • fix bug of DTFD-MIL
  • fix bug of test_mil.py

2024-07-27

  • fix bug of plip-transforms

📝 Overall Introduction

🔖 Library Introduction

  • A library that integrates different MIL methods into a unified framework
  • A library that integrates different Datasets into a unified Interface
  • A library that provides different Datasets-Split-Methods which commonly used
  • A library that easily extend by following a uniform definition

💡 Dataset Uniform Interface

  • User only need to provide the following csvs whether Public/Private Dataset
    /datasets/example_Dataset.csv

🌂 Supported Dataset-Split-Method

  • User-difined Train-Val-Test split
  • Train-Val split with K-fold
  • Train-Val-Test split with K-fold

📐 Feature Encoder

💎 Implementated NetWork

☑️ Implementated Metrics

  • AUC: macro,micro,weighed (same when 2-classes)
  • F1,PRE,RECALL: macro,micro,weighed
  • ACC,BACC: BACC is macro-RECALL
  • KAPPLE: linear,quadratic
  • Confusion_Mat
  • FROC
  • Patch-level-metrics

📙 Let's Begin Now

🔨 Code Framework

  • /configs: MIL_BASELINE defines MIL models through a YAML configuration file.
  • /modules: Defined the network architectures of different MIL models.
  • /process: Defined the training frameworks for different MIL models.
  • /feature_extracter: Supports different feature extractors.
  • /datasets: User-Datasets path information.
  • /utils: Framework's utility scripts.
  • /train_mil.py: Train Entry function of the framework.
  • /test_mil.py: Test Entry function of the framework.

📁 Dataset Pre-Process

🥚 Feature Extracter

  • OpenSlide supported formats and SDPC formats
  • R50 and VIT-S are supported directly.
  • PLIP/UNI/COUCH/TRANSPATH/GIG are supported by push the model-weights in /feature_extracter/PLIP /feature_extracter/UNI /feature_extracter/COUCH /feature_extracter/CTRANSPATH /feature_extracter/GIG.
  • To permform feature extracter
    • First, you should get h5 file
      python /feature_extracter/CLAM/create_patches_fp.py --source /path/to/your/slide_dir --save_dir /path/to/your/save_dr --preset /feature_extractor/CLAM/presets/bwh_biopsy.csv --patch_level your_path_level --patch_size your_patch_size --seg --patch
    • Second, you should get pt file
      CUDA_VISIBLE_DEVICES=your_cuda_id python /feature_extractor/CLAM/extract_features_fp.py --data_h5_dir /path/to/your/h5_save_dir --data_slide_dir /path/to/your/slide_dir --csv_path /path/to/your/h5_save_dir/process_list_autogen.csv --feat_dir path/to/your/pt_save_dir --batch_size your_bach_size --slide_ext your_ext --backbone your_backbone --target_patch_size your_target_patch_size --model_dir your_backbone_dir
      • backbone : resnet50_imagenet/vit_s_imagenet/plip/uni
      • ext : .svs/.tif/.ndpi/......./.sdpc
      • target_patch_size : for example, vit_s need 224 as input
      • ctranspath needs timm== timm-0.5.4 / gig needs timm=>1.0.3 / uni,conch... need timm==0.9.16

🍮 Dataset-Csv Construction

  • You should construct a csv-file like the format of /datasets/example_Dataset.csv

🍪 Dataset-Csv Construction

  • You can use the dataset-split-scripts to perform different data-split.

🔥 Train/Test MIL

🎱 Yaml Config

  • you can config the yaml-file in /configs
  • for example, /configs/AB_MIL.yaml, A detailed explanation has been written in /configs/AB_MIL.yaml
  • Then, /train_mil.py will help you !
  • /test_mil.py will help you test pretrained model !

Git Pull

  • Personal experience is limited, and code submissions are welcome !!

About

A library that integrates different MIL methods into a unified framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages