Release of PromptSRC with pretrained models.

This commit is contained in:
uzair khattak
2023-07-13 23:43:31 +05:00
commit 8be7dcff6b
132 changed files with 106641 additions and 0 deletions

31
scripts/coop/eval.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
#cd ../..
# custom config
DATA=/path/to/datasets
TRAINER=CoOp
SHOTS=16
NCTX=16
CSC=False
CTP=end
DATASET=$1
CFG=$2
for SEED in 1 2 3
do
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 output/evaluation/${TRAINER}/${CFG}_${SHOTS}shots/nctx${NCTX}_csc${CSC}_ctp${CTP}/${DATASET}/seed${SEED} \
--model-dir output/imagenet/${TRAINER}/${CFG}_${SHOTS}shots/nctx${NCTX}_csc${CSC}_ctp${CTP}/seed${SEED} \
--load-epoch 50 \
--eval-only \
TRAINER.COOP.N_CTX ${NCTX} \
TRAINER.COOP.CSC ${CSC} \
TRAINER.COOP.CLASS_TOKEN_POSITION ${CTP}
done

35
scripts/coop/main.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
#cd ../..
# custom config
DATA=/path/to/datasets
TRAINER=CoOp
DATASET=$1
CFG=$2 # config file
CTP=$3 # class token position (end or middle)
NCTX=$4 # number of context tokens
SHOTS=$5 # number of shots (1, 2, 4, 8, 16)
CSC=$6 # class-specific context (False or True)
for SEED in 1 2 3
do
DIR=output/${DATASET}/${TRAINER}/${CFG}_${SHOTS}shots/nctx${NCTX}_csc${CSC}_ctp${CTP}/seed${SEED}
if [ -d "$DIR" ]; then
echo "Results are available in ${DIR}. Skip this job"
else
echo "Run this job and save the output to ${DIR}"
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} \
TRAINER.COOP.N_CTX ${NCTX} \
TRAINER.COOP.CSC ${CSC} \
TRAINER.COOP.CLASS_TOKEN_POSITION ${CTP} \
DATASET.NUM_SHOTS ${SHOTS}
fi
done