Skip to content

[datasets] Check the word length range of WordGenerator upfront - #2203

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:word-generator-length-range
Oct 30, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:word-generator-length-range

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

WordGenerator drew each word length with random.randint(min_chars, max_chars) without checking the range. With min_chars=0 (e.g. --min-chars 0 in references/recognition/train.py), about half the samples were empty words, and each of them raised ValueError: unable to synthesize an image from an empty text, so training failed at a random step. With min_chars > max_chars, every sample raised ValueError: empty range in randrange(4, 3).

The range is now checked when the dataset is created, and 1 <= min_chars <= max_chars is required

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.75%. Comparing base (50c2ef1) to head (30c372d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2203      +/-   ##
==========================================
- Coverage   97.77%   97.75%   -0.02%     
==========================================
  Files         170      170              
  Lines       10980    10982       +2     
==========================================
  Hits        10736    10736              
- Misses        244      246       +2     
Flag Coverage Δ
unittests 97.75% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92 felixdittrich92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@felixdittrich92 felixdittrich92 self-assigned this Oct 30, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 30, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement ext: tests Related to tests folder module: datasets Related to doctr.datasets topic: text recognition Related to the task of text recognition labels Oct 30, 2026
@felixdittrich92
felixdittrich92 merged commit c828139 into mindee:main Oct 30, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext: tests Related to tests folder module: datasets Related to doctr.datasets topic: text recognition Related to the task of text recognition type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants