MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / transform_boxes

Method transform_boxes

sam2_train/utils/transforms.py:64–72  ·  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

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

Callers 1

_prep_promptsMethod · 0.80

Calls 1

transform_coordsMethod · 0.95

Tested by

no test coverage detected