fix(visualization): honor add_labels in visualize_kie_page - #2122
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
felixdittrich92
approved these changes
Aug 17, 2026
felixdittrich92
left a comment
Collaborator
There was a problem hiding this comment.
Hi @Anai-Guo 👋,
Thanks for the PR looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
visualize_kie_page()takesadd_labels: bool = Trueand documents it as "for static plot, adds text labels on top of bounding box", but the body never callsax.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 theelifbranch right after theinteractiveone; this PR mirrors that branch for KIE predictions, using the per-key colour that already exists incolorsand drawing only for straight (two-point) geometries, exactly asvisualize_page()does.display_artefactsis also unused here, but that one is inherent — a KIE page export haspredictions, notblocks/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, valueshello/world), reading backfig.axes[0].texts: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_pagegains an assertion on both sides of the flag. It fails onmain([] != ['hello', 'world']) and passes with the fix.ruff check/ruff format --checkclean on both files with the repo config.Type of change: Bug fix (non-breaking change which fixes an issue)
🤖 Generated with Claude Code