Skip to content

Commit d136432

Browse files
Update inference.py (#298)
1 parent 2b62f41 commit d136432

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

groundingdino/util/inference.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ def predict(
9898

9999

100100
def annotate(image_source: np.ndarray, boxes: torch.Tensor, logits: torch.Tensor, phrases: List[str]) -> np.ndarray:
101+
"""
102+
This function annotates an image with bounding boxes and labels.
103+
104+
Parameters:
105+
image_source (np.ndarray): The source image to be annotated.
106+
boxes (torch.Tensor): A tensor containing bounding box coordinates.
107+
logits (torch.Tensor): A tensor containing confidence scores for each bounding box.
108+
phrases (List[str]): A list of labels for each bounding box.
109+
110+
Returns:
111+
np.ndarray: The annotated image.
112+
"""
101113
h, w, _ = image_source.shape
102114
boxes = boxes * torch.Tensor([w, h, w, h])
103115
xyxy = box_convert(boxes=boxes, in_fmt="cxcywh", out_fmt="xyxy").numpy()

0 commit comments

Comments
 (0)