Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions models/sam3/model/box_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def generalized_box_iou(boxes1, boxes2):
return iou - (area - union) / area


@torch.jit.script
def fast_diag_generalized_box_iou(boxes1, boxes2):
assert len(boxes1) == len(boxes2)
box1_xy = boxes1[:, 2:]
Expand All @@ -168,8 +167,12 @@ def fast_diag_generalized_box_iou(boxes1, boxes2):

return iou - (tot_area - union) / tot_area

try:
fast_diag_generalized_box_iou = torch.jit.script(fast_diag_generalized_box_iou)
except Exception:
pass


@torch.jit.script
def fast_diag_box_iou(boxes1, boxes2):
assert len(boxes1) == len(boxes2)
box1_xy = boxes1[:, 2:]
Expand All @@ -193,6 +196,12 @@ def fast_diag_box_iou(boxes1, boxes2):
return iou


try:
fast_diag_box_iou = torch.jit.script(fast_diag_box_iou)
except Exception:
pass


def box_xywh_inter_union(
boxes1: torch.Tensor, boxes2: torch.Tensor
) -> Tuple[torch.Tensor, torch.Tensor]:
Expand Down