Skip to content

sava image_path in target of coco annotation data #8958

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion torchvision/datasets/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def _load_image(self, id: int) -> Image.Image:
return Image.open(os.path.join(self.root, path)).convert("RGB")

def _load_target(self, id: int) -> List[Any]:
return self.coco.loadAnns(self.coco.getAnnIds(id))
target = self.coco.loadAnns(self.coco.getAnnIds(id))
path = self.coco.loadImgs(id)[0]["file_name"]
target[0]["image_path"] = os.path.join(self.root, path)
return target

def __getitem__(self, index: int) -> Tuple[Any, Any]:

Expand Down