The segmentation should be the full mask, the size of the image and with size [h, w].
(self, image_id:int, category_id:int, segmentation:np.ndarray, score:float)
| 318 | }) |
| 319 | |
| 320 | def add_mask(self, image_id:int, category_id:int, segmentation:np.ndarray, score:float): |
| 321 | """ The segmentation should be the full mask, the size of the image and with size [h, w]. """ |
| 322 | rle = pycocotools.mask.encode(np.asfortranarray(segmentation.astype(np.uint8))) |
| 323 | rle['counts'] = rle['counts'].decode('ascii') # json.dump doesn't like bytes strings |
| 324 | |
| 325 | self.mask_data.append({ |
| 326 | 'image_id': int(image_id), |
| 327 | 'category_id': get_coco_cat(int(category_id)), |
| 328 | 'segmentation': rle, |
| 329 | 'score': float(score) |
| 330 | }) |
| 331 | |
| 332 | def dump(self): |
| 333 | dump_arguments = [ |
no test coverage detected