# Create a conda environment
conda create -n dassl python=3.8
# Activate the environment
conda activate dassl
# Install torch (version >= 1.8.1) and torchvision
conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=11.1 -c pytorch -c nvidia
# Install dependencies
pip install -r requirements.txt
Please follow the CoOp instructions: DATASETS.md.
First, you need set the dataset path in ./scripts/***.sh. Then, navigate to the scripts folder:
cd ./scriptsRun the following command, where gpuid specifies the GPU ID you want to use.
bash base2new.sh gpuidFor domain generalization and cross-dataset evaluation, we first train on ImageNet with multiple GPUs, as shown below:
cd ./scripts
bash xd_train.sh gpuid1,gpuid2Next, we perform Domain Generalization and Cross-dataset evaluation on the new dataset.
bash xd_test_cross.sh gpuid1,gpuid2
bash xd_test_dg.sh gpuid1,gpuid2For few-shot evaluation, run the following command.
The first two arguments specify the GPU IDs, and the third argument sets the number of shots.
bash few-shot.sh gpuid1,gpuid2 shots