Zero-Shot Image Classification
Transformers
Safetensors
siglip
vision
Inference Endpoints

Weight mismatching shape at initialization

#2
by lucadiliello - opened

When loading the model, I get a weight shape mismatch initialization error

>>> from transformers import AutoModel
>>> model = AutoModel.from_pretrained('google/siglip2-giant-opt-patch16-256')
RuntimeError: Error(s) in loading state_dict for SiglipModel:
size mismatch for text_model.head.weight: copying a param with shape torch.Size([1536, 1152]) from checkpoint, the shape in current model is torch.Size([1152, 1152])
size mismatch for text_model.head.bias: copying a param with shape torch.Size([1536]) from checkpoint, the shape in current model is torch.Size([1152])
You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method

Which version of transformers are you using? Could you try install from source?

pip install --upgrade git+https://github.com/huggingface/transformers.git

The demo code result:
[{'score': 0.11874160170555115, 'label': '2 cats'}, {'score': 0.0041748350486159325, 'label': 'a remotes'}, {'score': 0.0004358810547273606, 'label': 'a remote'}, {'score': 2.0866073668912577e-07, 'label': 'a plane'}]

sum of scores != 1

Sign up or log in to comment