htyao89 / KgCoOp

80 stars 8 forks source link

How to perform validation of domain generalization? #8

Open freya-7 opened 5 months ago

freya-7 commented 5 months ago

I have trained the model on imagenet and want to validate it on the other four variants. But I didn't find the relevant xd_test.bash file, could you provide it?

htyao89 commented 5 months ago

I have trained the model on imagenet and want to validate it on the other four variants. But I didn't find the relevant xd_test.bash file, could you provide it?

The saved model's path might be changed with your path (--model-dir).
"--load-epoch" is set as the epoch of training.

!/bin/bash

cd ..

custom config

DATA=/data/yht/data/cl/data/ TRAINER=KgCoOp

CFG=vit_b16_ep100_ctxv1 SHOTS=16 WEIGHT=8.0

for DATASET in imagenetv2 imagenet_sketch imagenet_a imagenet_r do for SEED in 1 2 3 d DIR=output_0122cd/evaluation/${TRAINER}/${CFG}${SHOTS}shots/${DATASET}/seed${SEED} if [ -d "$DIR" ]; then echo "Oops! The results exist at ${DIR} (so skip this job)" else python train.py \ --root ${DATA} \ --seed ${SEED} \ --trainer ${TRAINER} \ --dataset-config-file configs/datasets/${DATASET}.yaml \ --config-file configs/trainers/${TRAINER}/${CFG}.yaml \ --output-dir ${DIR} \ --model-dir output_0122_cd/base2new/trainbase/imagenet/shots${SHOTS}_${WEIGHT}/${TRAINER}/${CFG}/seed${SEED} \ --load-epoch 25\ --eval-only \ TRAINER.COOP.N_CTX 4 fi done done