KeyError 'siglip'
Unable to use the model google/siglip-base-patch16-224from PIL import Image
import requests
from transformers import AutoProcessor, AutoModel
import torch

model = AutoModel.from_pretrained("google/siglip-base-patch16-224")
processor = AutoProcessor.from_pretrained("google/siglip-base-patch16-224")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

texts = ["a photo of 2 cats", "a photo of 2 dogs"]
# important: we pass `padding=max_length` since the model was trained with this
inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")

with torch.no_grad():
    outputs = model(**inputs)

logits_per_image = outputs.logits_per_image
probs = torch.sigmoid(logits_per_image) # these are the probabilities
print(f"{probs[0][0]:.1%} that image 0 is '{texts[0]}'")HF envtransformersversion: 4.37.0Platform: macOS-10.16-x86_64-i386-64bitPython version: 3.10.13Huggingface_hub version: 0.19.4Safetensors version: 0.4.2Accelerate version: 0.26.1Accelerate config: 	not foundPyTorch version (GPU?): 2.1.2 (False)Tensorflow version (GPU?): not installed (NA)Flax version (CPU?/GPU?/TPU?): not installed (NA)Jax version: not installedJaxLib version: not installedUsing GPU in script?: noUsing distributed or parallel set-up in script?: no
2024-02-01T14:51:51Z
Facing the same problem for “google/siglip-base-patch16-512”. My guess it’s the same for all SigLIP models from Google. Looking at the error message, looks like “siglip” is not under theCONFIG_MAPPING_NAMESdictionary in theconfiguration_auto.pyfile.
2024-02-01T15:20:20Z
Fixed the issue by updating to transformers 4.37.2.