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

Function uncrop_masks

utils/sam_utils/amg.py:255–264  ·  view source on GitHub ↗
(
    masks: torch.Tensor, crop_box: List[int], orig_h: int, orig_w: int
)

Source from the content-addressed store, hash-verified

253
254
255def uncrop_masks(
256 masks: torch.Tensor, crop_box: List[int], orig_h: int, orig_w: int
257) -> torch.Tensor:
258 x0, y0, x1, y1 = crop_box
259 if x0 == 0 and y0 == 0 and x1 == orig_w and y1 == orig_h:
260 return masks
261 # Coordinate transform masks
262 pad_x, pad_y = orig_w - (x1 - x0), orig_h - (y1 - y0)
263 pad = (x0, pad_x - x0, y0, pad_y - y0)
264 return torch.nn.functional.pad(masks, pad, value=0)
265
266
267def remove_small_regions(

Callers 1

_process_batchMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected