Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Object Detection Pipeline only outputs first element when batching #31356

Description

@simonschoenhofen

System Info

  • transformers version: 4.41.2
  • Platform: Linux-5.4.0-182-generic-x86_64-with-glibc2.31
  • Python version: 3.11.8
  • Huggingface_hub version: 0.23.0
  • Safetensors version: 0.4.2
  • Accelerate version: 0.30.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.2.2+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

When running the ObjectDetectionPipeline in a batch, the output will only be the bounding boxes of the first input image due to ObjectDetectionPipeline.py accessing element [0] in postprocessing and not looping over all outputs.

raw_annotation = raw_annotations[0]

This accesses only and always the first element, instead of looping over all outputs.

Only the first element is accessed in postprocessing

Who can help?

@Narsil

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. Create object detection Pipeline

pipe = pipeline("object-detection", model=model_name, image_processor=preprocessor_name, device=device)

  1. use batch inference with batch_size > 2.
    for out in tqdm(pipe(dataset, batch_size=batch_size)):

Expected behavior

Expected Output: 2 Elements with each x items (bboxes).
Actual Output, only bboxes of the first input element.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions