(
masks: torch.Tensor, crop_box: List[int], orig_h: int, orig_w: int
)
| 253 | |
| 254 | |
| 255 | def 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 | |
| 267 | def remove_small_regions( |