Skip to content

Batch TrOCR line inference with configurable batch size - #12

Merged
estherg12 merged 4 commits into
estherg12:mainfrom
sushan5140:feat/batched-trocr-inference
Oct 15, 2026
Merged

estherg12 merged 4 commits into
estherg12:mainfrom
sushan5140:feat/batched-trocr-inference

Conversation

@sushan5140

@sushan5140 sushan5140 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6

Summary

  • Batch cropped line images before calling the TrOCR processor/model
  • Add a configurable --batch-size CLI option (default: 4)
  • Preserve line ordering and the existing NLP correction step
  • Keep batch_size=1 as the previous single-line inference behavior
  • Keep custom transcribe_fn behavior unchanged for tests/integrations

Tests

  • Adds a focused test verifying 5 crops with batch_size=2 produce batches [2, 2, 1]
  • Verifies decoded line order is preserved
  • Validates invalid batch sizes are rejected

Scope

Only the cropped-line inference stage is batched; segmentation and export behavior remain unchanged.

@sushan5140 sushan5140 changed the title Feat/batched trocr inference Batch TrOCR line inference with configurable batch size Oct 3, 2026
@estherg12
estherg12 merged commit b5b0ff2 into estherg12:main Oct 15, 2026
1 check passed
@estherg12

Copy link
Copy Markdown
Owner

Hi!
Thank you very much for collaborating with the project. I hope to see you again around here (:

@sushan5140

Copy link
Copy Markdown
Contributor Author

Hi! Thank you very much for collaborating with the project. I hope to see you again around here (:
Thank you so much! Really enjoyed contributing to your project. I'd love to stay connected and exchange ideas sometime. Looking forward to collaborating again!

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.

[FEATURE] Implement batched inference for TrOCR

2 participants