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

Method apply_image_torch

utils/sam_utils/transforms.py:55–65  ·  view source on GitHub ↗

Expects batched images with shape BxCxHxW and float format. This transformation may not exactly match apply_image. apply_image is the transformation expected by the model.

(self, image: torch.Tensor)

Source from the content-addressed store, hash-verified

53 return boxes.reshape(-1, 4)
54
55 def apply_image_torch(self, image: torch.Tensor) -> torch.Tensor:
56 """
57 Expects batched images with shape BxCxHxW and float format. This
58 transformation may not exactly match apply_image. apply_image is
59 the transformation expected by the model.
60 """
61 # Expects an image in BCHW format. May not exactly match apply_image.
62 target_size = self.get_preprocess_shape(image.shape[0], image.shape[1], self.target_length)
63 return F.interpolate(
64 image, target_size, mode="bilinear", align_corners=False, antialias=True
65 )
66
67 def apply_coords_torch(
68 self, coords: torch.Tensor, original_size: Tuple[int, ...]

Callers

nothing calls this directly

Calls 1

get_preprocess_shapeMethod · 0.95

Tested by

no test coverage detected