chenhaoxing / CPR

This repository is the code of our paper "Conditional Prototype Rectification Prompt Learning".
3 stars 0 forks source link

classnames #2

Open caoziyang1997 opened 2 months ago

caoziyang1997 commented 2 months ago

Traceback (most recent call last): File "main.py", line 77, in model = CPR(cfg, data.dataset.classnames, data.dataset.template, data.dataset.cupl_path, clip_model) File "/home/czy/project/CPR/model/CPR.py", line 130, in init super().init(cfg, classnames,templete, cupl_path, clip_model) File "/home/czy/project/CPR/model/base.py", line 208, in init self.clip_weights = pre_load_clip_weight(cfg) File "/home/czy/project/CPR/utils.py", line 82, in pre_load_clip_weight clip_weights = clip_classifier(cfg, classnames, template, clip_model, prompt_path=None) NameError: name 'classnames' is not defined 你好,请问你这个问题怎么解决

chenhaoxing commented 2 months ago

你好,我已经修改utils.pybase.py。你试试。

caoziyang1997 commented 2 months ago

我已经修改好了,但是我想问一下论文中的1,2,4,8,16shots的数据,在您的项目上用的哪一个具体的命令执行,我跑出来的数据和您论文的数据有很大出入。 image

chenhaoxing commented 2 months ago

你好,对于few shot任务可以参考下面设置yaml

# ------ root_path/dataset_name ------
root_path: '/datasets/VLM_Adapt/'
prompt_path: '/ossfs/workspace/CPR/gpt3_prompts/'

# ------ Load Cache and Features ------
load_cache: False
load_pre_feat: False

# load_cache: True
# load_pre_feat: True

# ------ Hyperparamters ------
search_hp: True
# search_hp: False

search_scale: [60, 70, 70]
search_step: [200, 70, 70]

init_beta: 1
init_alpha: 2

training_feat_num: 1024
#training_free_feat_num: 400
training_free_feat_num: 1024
w_training_free: [0.5, 0.5]
w_training: [0.2, 0.8]

# ------ Basic Config ------
dataset: 'dtd'
shots: 16
backbone: 'RN50'
subsample: 'all'
lr: 0.002
augment_epoch: 10
train_epoch: 200

然后再将main中的第四十行,base2new改为base2new = False。base中class PromptLearner中的n_ctx 可以设置为4,train_epoch也可以调整。你再试试~

caoziyang1997 commented 2 months ago

请问可以将few shot任务数据集的原始实验数据给我参考嘛,非常感谢!