Skip to content

Commit

Permalink
Add overriding of GroundingDINO bboxes with calculated masks bboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Youho99 committed Apr 17, 2024
1 parent 12eea0d commit 5b1c390
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autodistill_grounded_sam/grounded_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

from autodistill.detection import CaptionOntology, DetectionBaseModel

from supervision.detection.utils import mask_to_xyxy

HOME = os.path.expanduser("~")
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Expand Down Expand Up @@ -77,5 +79,8 @@ def predict(self, input: Any) -> sv.Detections:

detections.mask = np.array(result_masks)

# override GroundingDINO bboxes with calculated masks bboxes
detections.xyxy = mask_to_xyxy(detections.mask)

# separate in supervision to combine detections and override class_ids
return detections

0 comments on commit 5b1c390

Please sign in to comment.