Instructions to use google/owlv2-base-patch16-ensemble with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/owlv2-base-patch16-ensemble with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-object-detection", model="google/owlv2-base-patch16-ensemble")# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection processor = AutoProcessor.from_pretrained("google/owlv2-base-patch16-ensemble") model = AutoModelForZeroShotObjectDetection.from_pretrained("google/owlv2-base-patch16-ensemble") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -45,7 +45,9 @@ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
|
| 45 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 46 |
texts = [["a photo of a cat", "a photo of a dog"]]
|
| 47 |
inputs = processor(text=texts, images=image, return_tensors="pt")
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Target image sizes (height, width) to rescale box predictions [batch_size, 2]
|
| 51 |
target_sizes = torch.Tensor([image.size[::-1]])
|
|
|
|
| 45 |
image = Image.open(requests.get(url, stream=True).raw)
|
| 46 |
texts = [["a photo of a cat", "a photo of a dog"]]
|
| 47 |
inputs = processor(text=texts, images=image, return_tensors="pt")
|
| 48 |
+
|
| 49 |
+
with torch.no_grad():
|
| 50 |
+
outputs = model(**inputs)
|
| 51 |
|
| 52 |
# Target image sizes (height, width) to rescale box predictions [batch_size, 2]
|
| 53 |
target_sizes = torch.Tensor([image.size[::-1]])
|