| 29 | |
| 30 | |
| 31 | class CocoDetection(torchvision.datasets.CocoDetection): |
| 32 | def __init__(self, img_folder, ann_file, transforms, return_masks): |
| 33 | super(CocoDetection, self).__init__(img_folder, ann_file) |
| 34 | self._transforms = transforms |
| 35 | self.prepare = ConvertCocoPolysToMask(return_masks) |
| 36 | |
| 37 | def __getitem__(self, idx): |
| 38 | img, target = super(CocoDetection, self).__getitem__(idx) |
| 39 | image_id = self.ids[idx] |
| 40 | target = {'image_id': image_id, 'annotations': target} |
| 41 | img, target = self.prepare(img, target) |
| 42 | if self._transforms is not None: |
| 43 | img, target = self._transforms(img, target) |
| 44 | return img, target |
| 45 | |
| 46 | |
| 47 | def convert_coco_poly_to_mask(segmentations, height, width): |
no outgoing calls
no test coverage detected