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

Sign up or log in to comment