Instructions to use google/siglip2-base-patch16-naflex with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/siglip2-base-patch16-naflex with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="google/siglip2-base-patch16-naflex") 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/siglip2-base-patch16-naflex") model = AutoModelForZeroShotImageClassification.from_pretrained("google/siglip2-base-patch16-naflex") - Notebooks
- Google Colab
- Kaggle
Fix error in example code snippet
Browse filesLooks like you forgot to load the image from the url in the first example. This PR fixes that.
README.md
CHANGED
|
@@ -26,6 +26,7 @@ Here is how to use this model to perform zero-shot image classification:
|
|
| 26 |
|
| 27 |
```python
|
| 28 |
from transformers import pipeline
|
|
|
|
| 29 |
|
| 30 |
# load pipeline
|
| 31 |
ckpt = "google/siglip2-base-patch16-naflex"
|
|
@@ -33,6 +34,7 @@ image_classifier = pipeline(model=ckpt, task="zero-shot-image-classification")
|
|
| 33 |
|
| 34 |
# load image and candidate labels
|
| 35 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
|
|
|
| 36 |
candidate_labels = ["2 cats", "a plane", "a remote"]
|
| 37 |
|
| 38 |
# run inference
|
|
|
|
| 26 |
|
| 27 |
```python
|
| 28 |
from transformers import pipeline
|
| 29 |
+
from transformers.image_utils import load_image
|
| 30 |
|
| 31 |
# load pipeline
|
| 32 |
ckpt = "google/siglip2-base-patch16-naflex"
|
|
|
|
| 34 |
|
| 35 |
# load image and candidate labels
|
| 36 |
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 37 |
+
image = load_image(url)
|
| 38 |
candidate_labels = ["2 cats", "a plane", "a remote"]
|
| 39 |
|
| 40 |
# run inference
|