Skip to content

Conversation

@Teekyy
Copy link

@Teekyy Teekyy commented Dec 29, 2025

Fixes #30

Summary

Fixes a crash in FFDetrDetector.extract_widgets() when the final batch contains a single page (e.g. len(pages) % batch_size == 1 and len(pages) > 1).

Root cause

model.predict() returns:

  • List[sv.Detections] for batch size > 1
  • sv.Detections for batch size == 1

When the final batch size is 1, results.extend(predictions) iterates the sv.Detections object and adds non-detection items (e.g. tuples) into results, which later breaks .with_nms().

Fix

  • Use append for single sv.Detections and extend for lists (ensures results is always List[sv.Detections]).

Testing

  • Confirmed the crash on main with a 4-page PDF using batch_size=3 (batches of 3 + 1).
  • Confirmed fixed with this change; also tested batch_size=1.

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.

FFDetrDetector fails when last batch has size 1 (AttributeError: 'tuple' object has no attribute 'with_nms')

1 participant