Skip to content

Honor target_keys for empty CocoDetection samples - #9650

Open
YeonwooSung wants to merge 1 commit into
pytorch:mainfrom
YeonwooSung:fix/coco-empty-target-keys-9162
Open

Honor target_keys for empty CocoDetection samples#9650
YeonwooSung wants to merge 1 commit into
pytorch:mainfrom
YeonwooSung:fix/coco-empty-target-keys-9162

Conversation

@YeonwooSung

Copy link
Copy Markdown

Empty COCO images (no objects) always returned {'image_id': ...} from wrap_dataset_for_transforms_v2, even when image_id was not in target_keys. Non-empty samples already honored target_keys.

This makes the empty-target branch check target_keys as well: return {'image_id': image_id} only if requested, otherwise {}. Default target_keys for CocoDetection still includes image_id, so default empty-sample behavior is unchanged.

Fixes #9162

@pytorch-bot

pytorch-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

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.

CocoDetection wrapped with wrap_dataset_for_transforms_v2 returns image_id even if not in target_keys

1 participant