The code of paper "Enhancing Information Maximization with Distance-Aware Contrastive Learning for Source-Free Cross-Domain Few-Shot Learning"
conda creat --name im-dcl python=3.9
conda activate im-dcl
conda install pytorch torchvision -c pytorch
conda install pandas
pip install numpy
pip install argparse
pip install math
pip install os
pip install sklearn
pip install scipy
pip install PIL
pip install abc
git clone https://github.com/xuhuali-mxj/IM-DCL.git
cd IM-DCL
For the 4 datasets CropDiseases, EuroSAT, ISIC, and ChestX, we refer to the BS-CDFSL repo.
Our method aims at improving the performance of pretrained source model on the target FSL task. We introduce the information maximization, and propose a distance-aware contrastive learning, helping the pretrained source model to learn the decision boundary.
Please set your data address in configs.py.
We also provide the pretrained source model in mini_models/checkpoints/ResNet10_ce_aug/, We use ResNet10_ce_1200.tar to evaluate our IM-DCL.
We start from run.sh. Taking 5-way 1-shot as an example, the code runing process can be done as,
python ./adapt_da.py --model ResNet10 --train_aug --use_saved --dtarget CropDisease --n_shot 1
Coming soon.
Our code is built upon the implementation of FTEM_BSR_CDFSL and SHOT. Thanks for their work.