Instructions to use google/siglip-base-patch16-512 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/siglip-base-patch16-512 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="google/siglip-base-patch16-512") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotImageClassification processor = AutoProcessor.from_pretrained("google/siglip-base-patch16-512") model = AutoModelForZeroShotImageClassification.from_pretrained("google/siglip-base-patch16-512") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -42,7 +42,7 @@ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
|
| 42 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 43 |
|
| 44 |
texts = ["a photo of 2 cats", "a photo of 2 dogs"]
|
| 45 |
-
inputs = processor(text=texts, images=image, return_tensors="pt")
|
| 46 |
|
| 47 |
with torch.no_grad():
|
| 48 |
outputs = model(**inputs)
|
|
|
|
| 42 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 43 |
|
| 44 |
texts = ["a photo of 2 cats", "a photo of 2 dogs"]
|
| 45 |
+
inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")
|
| 46 |
|
| 47 |
with torch.no_grad():
|
| 48 |
outputs = model(**inputs)
|