MCPcopy Create free account
hub / github.com/bowang-lab/MedSAM2 / transform_boxes

Method transform_boxes

sam2/utils/transforms.py:66–74  ·  view source on GitHub ↗

Expects a tensor of shape Bx4. The coordinates can be in absolute image or normalized coordinates, if the coords are in absolute image coordinates, normalize should be set to True and original image size is required.

(
        self, boxes: torch.Tensor, normalize=False, orig_hw=None
    )

Source from the content-addressed store, hash-verified

64 return coords
65
66 def transform_boxes(
67 self, boxes: torch.Tensor, normalize=False, orig_hw=None
68 ) -> torch.Tensor:
69 """
70 Expects a tensor of shape Bx4. The coordinates can be in absolute image or normalized coordinates,
71 if the coords are in absolute image coordinates, normalize should be set to True and original image size is required.
72 """
73 boxes = self.transform_coords(boxes.reshape(-1, 2, 2), normalize, orig_hw)
74 return boxes
75
76 def postprocess_masks(self, masks: torch.Tensor, orig_hw) -> torch.Tensor:
77 """

Callers 2

normalize_bboxMethod · 0.45
_prep_promptsMethod · 0.45

Calls 1

transform_coordsMethod · 0.95

Tested by

no test coverage detected