Repository navigation
[utils] Display page exports read back from a JSON file - #2168
Merged
felixdittrich92 merged 1 commit intoOct 13, 2026
Merged
Conversation
A page export saved with json.dump and loaded back stores every geometry as lists instead of tuples. create_obj_patch and rect_patch only accepted tuples, so visualize_page, visualize_kie_page and Page.show raised "invalid geometry format" on such exports, e.g. after Page.from_dict on a saved JSON file. Accept lists as well.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2168 +/- ##
==========================================
+ Coverage 97.55% 97.60% +0.05%
==========================================
Files 170 170
Lines 10668 10740 +72
==========================================
+ Hits 10407 10483 +76
+ Misses 261 257 -4
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
Oct 13, 2026
felixdittrich92
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @MohammadHijjawi97 LGTM 👍
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.
A page export saved with
json.dumpand loaded back stores every geometry as lists, not tuples.create_obj_patchandrect_patchonly accepted tuples, so displaying such an export failed:The same happens when the loaded dict goes straight to
visualize_pageorvisualize_kie_page.render(),synthesize()and the other exports already work on the restored page; only the display failed.This PR accepts lists as well as tuples in
create_obj_patchandrect_patch. Invalid shapes still raiseValueError.Tests:
test_visualize_json_exports: JSON round trip of a page with straight boxes, a rotated polygon and layout regions, in interactive and static modes, checking the same patches and labels as the tuple export, plus a KIE page.test_page_from_dict_restores_the_imagenow also calls.show()on a page restored from JSON.Both fail on
mainand pass with the fix.ruff check,ruff format --checkandmypy doctr/pass.Any feedback is welcome 🤗