You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the Autodistill issues and found no similar feature requests.
Question
I am trying to create some annotations using GroundingDINO using "inference" and "autodistill" libraries, and visualize the detections and annotations that were applied to the images. I can't use plot function because I am using the terminal to access the arch linux node, and I am trying to write the annotations to each image using "cv2". The following code works, but when I inspect the images, the detections are not showing at all on the images. Any ideas on what might be going wrong?
`from autodistill_grounding_dino import GroundingDINO
from autodistill.detection import CaptionOntology
from autodistill.utils import plot
import supervision as sv
import cv2
import os
images = ["../Images/batch_12/000062.jpg", "../Images/batch_1/000014.jpg", "../Images/batch_12/000061.jpg", "../Images/batch_12/000043.jpg", "../Images/batch_12/000084.jpg"]
for image in images:
image_dir, image_file = os.path.split(image)
image_filename, image_extension = os.path.splitext(image_file)
image = cv2.imread(image)
ontology = CaptionOntology(
{
"garbage": "garbage",
}
)
model = GroundingDINO(ontology=ontology)
result = model.predict(image)
detections = sv.Detections.from_inference(result)
bounding_box_annotator = sv.BoundingBoxAnnotator(thickness=8, color=sv.ColorPalette.DEFAULT.by_idx(12))
label_annotator = sv.LabelAnnotator(text_thickness=3, text_scale=1.5, text_color=sv.Color.WHITE, color=sv.Color.ROBOFLOW)
labels = [
f"{model.ontology.classes()[class_id]} {confidence:0.2f}"
for _, _, confidence, class_id, _ in detections
]
annotated_image = bounding_box_annotator.annotate(
scene=image.copy(), detections=detections
)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections, labels=labels
)
cv2.imwrite(f'./predictions/{image_filename}_groundingDINO_autodistill.jpg', annotated_image)`
Additional
No response
The text was updated successfully, but these errors were encountered:
Search before asking
Question
I am trying to create some annotations using GroundingDINO using "inference" and "autodistill" libraries, and visualize the detections and annotations that were applied to the images. I can't use plot function because I am using the terminal to access the arch linux node, and I am trying to write the annotations to each image using "cv2". The following code works, but when I inspect the images, the detections are not showing at all on the images. Any ideas on what might be going wrong?
Additional
No response
The text was updated successfully, but these errors were encountered: