This is a PyTorch implementation of the CA2CL
Download the NCT-CRC-HE-100K and CRC-VAL-HE-7K:NCT dataset.
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
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 |
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 |
We follow the evaluation setting in MoCo when trasferring to object detection.
-
Install detectron2..
-
You can download our pre-processed datasets from GlaS-coco-format and CRAG-coco-format.
-
Put dataset under "benchmarks/detection/datasets" directory, following the directory structure requried by detectron2.
-
the converted backbone weights is available at checkpoint, put dataset under "benchmarks\detection\converted_weights" directory,
-
run
run_ft.sh
runs of fine-tuning and evaluation on GlaS dataset.
This project is under the CC-BY-NC 4.0 license. See LICENSE for details.