MCPcopy Create free account
hub / github.com/PolyU-ChenLab/UniPixel / transform_boxes

Method transform_boxes

sam2/utils/transforms.py:62–68  ·  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

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

Callers 1

_prep_promptsMethod · 0.80

Calls 1

transform_coordsMethod · 0.95

Tested by

no test coverage detected