MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / apply_boxes_torch

Method apply_boxes_torch

utils/sam_utils/transforms.py:83–91  ·  view source on GitHub ↗

Expects a torch tensor with shape Bx4. Requires the original image size in (H, W) format.

(
        self, boxes: torch.Tensor, original_size: Tuple[int, ...]
    )

Source from the content-addressed store, hash-verified

81 return coords
82
83 def apply_boxes_torch(
84 self, boxes: torch.Tensor, original_size: Tuple[int, ...]
85 ) -> torch.Tensor:
86 """
87 Expects a torch tensor with shape Bx4. Requires the original image
88 size in (H, W) format.
89 """
90 boxes = self.apply_coords_torch(boxes.reshape(-1, 2, 2), original_size)
91 return boxes.reshape(-1, 4)
92
93 @staticmethod
94 def get_preprocess_shape(oldh: int, oldw: int, long_side_length: int) -> Tuple[int, int]:

Callers

nothing calls this directly

Calls 1

apply_coords_torchMethod · 0.95

Tested by

no test coverage detected