Instructions to use google/siglip2-giant-opt-patch16-256 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/siglip2-giant-opt-patch16-256 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="google/siglip2-giant-opt-patch16-256") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("google/siglip2-giant-opt-patch16-256", dtype="auto") - Notebooks
- Google Colab
- Kaggle
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