Skip to content

fix(visualization): honor add_labels in visualize_kie_page - #2122

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
Anai-Guo:fix-kie-add-labels
Aug 17, 2026
Merged

fix(visualization): honor add_labels in visualize_kie_page#2122
felixdittrich92 merged 1 commit into
mindee:mainfrom
Anai-Guo:fix-kie-add-labels

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

What does this PR do?

visualize_kie_page() takes add_labels: bool = True and documents it as "for static plot, adds text labels on top of bounding box", but the body never calls ax.text() — the argument has no effect at all. A non-interactive KIE figure (page.show(interactive=False), or saving the returned figure) therefore renders as coloured boxes with no text, and there is no way to get labels onto it.

visualize_page() already does this, on the elif branch right after the interactive one; this PR mirrors that branch for KIE predictions, using the per-key colour that already exists in colors and drawing only for straight (two-point) geometries, exactly as visualize_page() does.

display_artefacts is also unused here, but that one is inherent — a KIE page export has predictions, not blocks/artefacts — so I left it alone rather than change the public signature in a bug-fix PR.

Before / after

Run against a two-prediction page (_mock_kie_pages() shape, values hello / world), reading back fig.axes[0].texts:

call before after
interactive=False, add_labels=True [] ['hello', 'world']
interactive=False, add_labels=False [] []
interactive=True, add_labels=True [] []
words_only=True [] (no patches) [] (no patches)

visualize_page() is untouched and still renders its label (['hi'] on the same harness).

Test

test_visualize_kie_page gains an assertion on both sides of the flag. It fails on main ([] != ['hello', 'world']) and passes with the fix.

ruff check / ruff format --check clean on both files with the repo config.

Type of change: Bug fix (non-breaking change which fixes an issue)

🤖 Generated with Claude Code

visualize_kie_page() accepts and documents add_labels ("for static plot,
adds text labels on top of bounding box") but never drew any text, so a
non-interactive KIE figure came out as unlabelled coloured boxes and the
argument was silently a no-op. visualize_page() already draws the label in
the same place, on the elif branch after the interactive one.

Mirror that branch for predictions, using the per-key colour and drawing
only for straight (two-point) geometries, as visualize_page() does.
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (5332574) to head (f96c5db).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2122   +/-   ##
=======================================
  Coverage   97.00%   97.00%           
=======================================
  Files         169      169           
  Lines        9611     9613    +2     
=======================================
+ Hits         9323     9325    +2     
  Misses        288      288           
Flag Coverage Δ
unittests 97.00% <100.00%> (+<0.01%) ⬆️

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.

Hi @Anai-Guo 👋,

Thanks for the PR looks good to me.

@felixdittrich92 felixdittrich92 added this to the 1.1.0 milestone Aug 17, 2026
@felixdittrich92 felixdittrich92 self-assigned this Aug 17, 2026
@felixdittrich92 felixdittrich92 added type: bug Something isn't working module: utils Related to doctr.utils ext: tests Related to tests folder labels Aug 17, 2026
@felixdittrich92
felixdittrich92 merged commit e812011 into mindee:main Aug 17, 2026
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: utils Related to doctr.utils type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants