Instructions to use IDEA-Research/grounding-dino-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IDEA-Research/grounding-dino-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-object-detection", model="IDEA-Research/grounding-dino-base")# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection processor = AutoProcessor.from_pretrained("IDEA-Research/grounding-dino-base") model = AutoModelForZeroShotObjectDetection.from_pretrained("IDEA-Research/grounding-dino-base") - Notebooks
- Google Colab
- Kaggle
How to plot results using supervision
#5
by vishwamgupta - opened
kindly suggest how to plot results
You can examine the visual in the results (output) section by using this code blog.
draw = ImageDraw.Draw(image)
font = ImageFont.load_default()
for result in results:
boxes = result['boxes'].cpu().numpy() # Convert to numpy array
scores = result['scores'].cpu().numpy()
labels = result['labels']
for box, score, label in zip(boxes, scores, labels):
box = [int(b) for b in box]
draw.rectangle(box, outline="red", width=3)
draw.text((box[0], box[1]), f"{label}: {score:.2f}", fill="red", font=font)
# Display the image with bounding boxes
plt.figure(figsize=(10, 10))
plt.imshow(image)
plt.axis("off")
plt.show()
You can read supervision docs the only thing is that their from_transformers works only with the XxxForObjectDetection as the output of the pipelines (at least the zero shot pipeline) is different