Instructions to use google/owlv2-large-patch14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/owlv2-large-patch14 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-object-detection", model="google/owlv2-large-patch14")# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection processor = AutoProcessor.from_pretrained("google/owlv2-large-patch14") model = AutoModelForZeroShotObjectDetection.from_pretrained("google/owlv2-large-patch14") - Notebooks
- Google Colab
- Kaggle
Bounding box normalization
#3
by Rivoks - opened
Hello,
It seems that he demo code for OWLv2 has an issue with the image normalization. The helper function get_preprocessed_image doesn't work.
This code section works to normalize the bounding box coordinates:
# Utility function for OWL-v2
# See https://github.com/huggingface/transformers/issues/30131#issuecomment-2097490581
def get_normalized_bbox(image, bbox):
width, height = image.size
width_ratio = 1
height_ratio = 1
if width < height:
width_ratio = width / height
elif height < width:
height_ratio = height / width
xmin, ymin, xmax, ymax = bbox
xmin /= width_ratio
ymin /= height_ratio
xmax /= width_ratio
ymax /= height_ratio
return [xmin, ymin, xmax, ymax]
Is it possible to update the README.md ? (I can make a PR if needed)
Kind regards,
Yazid