Syliz517/CLIP-ReID

Issue in evaluating the models

Closed this issue · 6 comments

Hey, thanks for this excellent work of yours.
I have trained a model on the custom dataset, when I try to load the model for evaluation the script raises an error saying

  Resized position embedding: %s to %s torch.Size([197, 768]) torch.Size([129, 768])
  Position embedding resize to height:16 width: 8
  Traceback (most recent call last):
  File "test_clipreid.py", line 44, in <module>
  model.load_param_finetune(cfg.TEST.WEIGHT)
  File "/app/model/make_model_clipreid.py", line 173, in load_param_finetune
  self.state_dict()[i].copy_(param_dict[i])
  RuntimeError: The size of tensor a (129) must match the size of tensor b (211) at non-singleton dimension 0

Resized position embedding: %s to %s torch.Size([197, 768]) torch.Size([129, 768]). This is during evaluation, whereas the position embedding size during the training is Resized position embedding: %s to %s torch.Size([197, 768]) torch.Size([211, 768]). Please can you check on this part?

The same is the case when I try to load the VeRi finetuned model and Market1501 model, with the scripts you have provided.

Hi, are you using the correct .yml file with SIZE_TRAIN and SIZE_TEST modified? It looks like you have a mismatch between the size of the training image and the inference image.

Hi, are you using the correct .yml file with SIZE_TRAIN and SIZE_TEST modified? It looks like you have a mismatch between the size of the training image and the inference image.

Yes, I am using the correct file, but I want to evaluate the pre-trained models on my custom datasets.
How Can I do that?

same issue

self state dict image_encoder.positional_embedding
param_dict torch.Size([211, 768])
Traceback (most recent call last):
File "CLIP-reid.py", line 32, in
model.load_param(cfg.TEST.WEIGHT)
File "/home/ubuntu/liuxuefei/ByteTrack-main/reid/model/make_model_clipreid.py", line 172, in load_param
self.state_dict()[i.replace('module.', '')].copy_(param_dict[i])
RuntimeError: The size of tensor a (129) must match the size of tensor b (211) at non-singleton dimension 0

I print the state dict ,this issue sames to caused then load the clip ,the positional embedding parameter is resized to 129,while the pretrained model's param is 211

@406747925 修改vit_clipreid.yml的STRIDE_SIZE为[12,12]

self state dict image_encoder.positional_embedding param_dict torch.Size([211, 768]) Traceback (most recent call last): File "CLIP-reid.py", line 32, in model.load_param(cfg.TEST.WEIGHT) File "/home/ubuntu/liuxuefei/ByteTrack-main/reid/model/make_model_clipreid.py", line 172, in load_param self.state_dict()[i.replace('module.', '')].copy_(param_dict[i]) RuntimeError: The size of tensor a (129) must match the size of tensor b (211) at non-singleton dimension 0

I print the state dict ,this issue sames to caused then load the clip ,the positional embedding parameter is resized to 129,while the pretrained model's param is 211

The problem here is that the pre-trained model use is trained with a different no. of classes as compared to the dataset used for training. If you use the same dataset as the training dataset you might not get that error.