(uncompressed_rle: Dict[str, Any])
| 292 | |
| 293 | |
| 294 | def coco_encode_rle(uncompressed_rle: Dict[str, Any]) -> Dict[str, Any]: |
| 295 | from pycocotools import mask as mask_utils # type: ignore |
| 296 | |
| 297 | h, w = uncompressed_rle["size"] |
| 298 | rle = mask_utils.frPyObjects(uncompressed_rle, h, w) |
| 299 | rle["counts"] = rle["counts"].decode("utf-8") # Necessary to serialize with json |
| 300 | return rle |
| 301 | |
| 302 | |
| 303 | def batched_mask_to_box(masks: torch.Tensor) -> torch.Tensor: |