pytorch / pytorch/vision

Caltech-101 doesn't load bboxes but it should.

Open
#7,748 3 comments 0 reactions 1 assignee View on GitHub

@pmeier is already working on this.

Since Jul 24, 2023.

bug module: datasets
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🐛 Describe the bug

Annotation files in Caltech-101 have two keys: 'box_coord' and 'obj_contour'. Caltech101 PyTorch class appends just the contours, explicitly skipping 'box_coord'. This would be ok if coordinates of obj_contour were relative to the entire image. Unfortunately they are relative to the bboxes and thus are useless without loading box_coord.

There are two ways to fix this - load box_coord or transform obj_contour coordinates to be relative to the image.

Versions

My env is irrelevant as this is a clear bug in code on main:

torchvision/datasets/caltech.py#L95C9-L110C9

        target: Any = []
        for t in self.target_type:
            if t == "category":
                target.append(self.y[index])
            elif t == "annotation":
                data = scipy.io.loadmat(
                    os.path.join(
                        self.root,
                        "Annotations",
                        self.annotation_categories[self.y[index]],
                        f"annotation_{self.index[index]:04d}.mat",
                    )
                )
                target.append(data["obj_contour"])
        target = tuple(target) if len(target) > 1 else target[0]

cc @pmeier

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.