Skip to content

junjianli106/CA2CL

Repository files navigation

CA2CL: Cluster-Aware Adversarial Contrastive Learning for Pathological Image Analysis

This is a PyTorch implementation of the CA2CL

Preparation

Download the NCT-CRC-HE-100K and CRC-VAL-HE-7K:NCT dataset.

Unsupervised Training

To do unsupervised pre-training of a ResNet-18 model on NCT-CRC-HE-100K in an 2*A100(40G) gpu machine, run:

CUDA_VISIBLE_DEVICES=0,1 python pretrain.py 

the NCT pretrained checkpoint is available at checkpoint

Fine-tuning

With a pre-trained model, to train a supervised linear classifier on frozen features/weights in an 1-gpu machine, run:

python ft_le.py --dataset_path '../data/Kather_Multi_Class/' \
                --model_name 'resnet18' \
                --model_path './save/NCT/pretrain/resnet18/CA2CL_NCT.tar' \
                --ft_epoch 40 \ 
                --lr 0.0003 \ 
                --seed 1 \ 
                --only_fine_turning \ 
                --labeled_train 0.01 \ 
                --gpu_index 3

Fine-tuning results on CRC-VAL-HE-7K (seed=1):

label of train
1%
label of train
10%
label of train
50%
label of train
100%
acc 0.958 0.967 0.968 0.970
f1 0.941 0.954 0.957 0.960
logs download download download download

Linear Classification

With a pre-trained model, to train a supervised linear classifier on frozen features/weights in an 8-gpu machine, run:

python ft_le.py --dataset_path '../data/Kather_Multi_Class/' 
                --model_name 'resnet18'
                --model_path './save/NCT/pretrain/resnet18/CA2CL_NCT.tar' \
                --ft_epoch 100
                --lr 0.01
                --seed 1
                --only_linear_eval
                --labeled_train 0.01
                --gpu_index 3

Linear classification results on CRC-VAL-HE-7K (seed=1):

label of train
1%
label of train
10%
label of train
50%
label of train
100%
acc 0.967 0.969 0.969 0.968
f1 0.953 0.959 0.958 0.956
logs download download download download

Transferring to Object Detection

We follow the evaluation setting in MoCo when trasferring to object detection.

  1. Install detectron2..

  2. You can download our pre-processed datasets from GlaS-coco-format and CRAG-coco-format.

  3. Put dataset under "benchmarks/detection/datasets" directory, following the directory structure requried by detectron2.

  4. the converted backbone weights is available at checkpoint, put dataset under "benchmarks\detection\converted_weights" directory,

  5. run run_ft.sh runs of fine-tuning and evaluation on GlaS dataset.

License

This project is under the CC-BY-NC 4.0 license. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published