Skip to content

Fix batch object detection 31356 #39306

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

z-pandeyji
Copy link

@amyeroberts @Narsil

Fixes #31356

Issue: Object Detection Pipeline only outputs first element when batching

Solution

The Object Detection Pipeline now correctly handles batched inputs, returning results for all images in the batch instead of just the first one.

Verification

  • Single image processing works correctly
  • Batch processing now returns results for all images
  • Tested with multiple image types (URLs, PIL images)
  • All existing tests pass

Before/After

Before: detector([img1, img2, img3]) → Returns results for only img1
After: detector([img1, img2, img3]) → Returns results for all 3 images

Technical Details

  • Files modified: src/transformers/pipelines/object_detection.py
  • Performance: No regression, improved batch efficiency
  • Compatibility: Fully backward compatible

Impact

  • Fixes critical batching bug affecting users
  • Improves user experience for batch processing
  • No breaking changes

@z-pandeyji z-pandeyji force-pushed the fix-batch-object-detection-31356 branch from c766412 to cb00bc7 Compare July 9, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object Detection Pipeline only outputs first element when batching
1 participant