Skip to content

Commit

Permalink
fix Coco implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Feb 23, 2021
1 parent 315c4f6 commit e2b6938
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion torchvision/datasets/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def __init__(
super().__init__(root, transforms, transform, target_transform)
from pycocotools.coco import COCO

self.coco = COCO(annFile)
try:
self.coco = COCO(annFile)
except FileNotFoundError as error:
raise RuntimeError(f"The file {annFile} does not exist or is corrupt.") from error

self.ids = list(sorted(self.coco.imgs.keys()))

def _load_image(self, id: int) -> Image.Image:
Expand Down

0 comments on commit e2b6938

Please sign in to comment.