Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update coco_utils.py #7869

Merged
merged 2 commits into from
Aug 23, 2023
Merged

Update coco_utils.py #7869

merged 2 commits into from
Aug 23, 2023

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Aug 22, 2023

Description:

  • Fixing convert_to_coco_api as target["image_id"] should be an integer than tensor.

We get the following error:

  File "/tutorials/intermediate_source/tv-training-code.py", line 225, in main
    evaluate(model, data_loader_test, device=device)
  File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/tutorials/intermediate_source/engine.py", line 102, in evaluate
    coco_evaluator.update(res)
  File "/tutorials/intermediate_source/coco_eval.py", line 37, in update
    coco_dt = COCO.loadRes(self.coco_gt, results) if results else COCO()
  File "/usr/local/lib/python3.10/dist-packages/pycocotools/coco.py", line 327, in loadRes
    assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())), \
AssertionError: Results do not correspond to current coco set

This happends because ground truth image_ids created by convert_to_coco_api are int but image_ids given by predictions are tensors.

Context:

For non-COCO datasets we are passing into the last branch (return convert_to_coco_api(dataset)) here:

def get_coco_api_from_dataset(dataset):
# FIXME: This is... awful?
for _ in range(10):
if isinstance(dataset, torchvision.datasets.CocoDetection):
break
if isinstance(dataset, torch.utils.data.Subset):
dataset = dataset.dataset
if isinstance(dataset, torchvision.datasets.CocoDetection):
return dataset.coco
return convert_to_coco_api(dataset)

So, there is no impact for the current MSCOCO training script.

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 22, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/7869

Note: Links to docs will display an error until the docs builds have been completed.

❌ 32 New Failures, 1 Unrelated Failure

As of commit e367139 with merge base 5c1e62f (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vfdev-5

@NicolasHug NicolasHug merged commit c486bb1 into main Aug 23, 2023
4 of 14 checks passed
@github-actions
Copy link

Hey @NicolasHug!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@vfdev-5 vfdev-5 deleted the fix-det-ref-tutorials branch August 23, 2023 11:12
facebook-github-bot pushed a commit that referenced this pull request Sep 6, 2023
Summary: (Note: this ignores all push blocking failures!)

Reviewed By: matteobettini

Differential Revision: D48900402

fbshipit-source-id: eba6b527b7ae7b2db4634cc1ceec17cc1b218ba6

Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants