Repository navigation
Align word box columns with reversed text for RTL recognition - #18386
Open
longzhenren wants to merge 1 commit into
Open
longzhenren wants to merge 1 commit into
longzhenren wants to merge 1 commit into
Conversation
Author
|
I have read and agree to the Contributor License Agreement |
This branch has not been deployed
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.
Root cause: For dicts with "arabic" in the filename,
BaseRecLabelDecodesetsreverse=Trueanddecode()reverses the decoded text withpred_reverse()before callingget_word_info().pred_reversekeeps runs of LTR characters together and reverses the token sequence, butselection(the feature-column mask) was passed through unchanged.get_word_infothen pairs each character of the reversed text with the ascending column list, so every word-level box is attributed to the wrong columns.Reproduction (
return_word_box=True, reversed dict, text"Hello مرحبا"):Every column after the first LTR run shifts, so downstream word-level bbox alignment for RTL models is wrong end to end.
Fix: when reversing, reorder the selected columns with the same token mapping as
pred_reverse(new helperreverse_selectionreturning an explicit column array) and pass that toget_word_info, which now accepts either the boolean mask or an explicit column array. Non-reversed decoding is untouched.Test:
tests/unit/test_rec_postprocess.pycovers the mixed LTR/RTL case (columns follow the reversed reading order, including with interleaved blanks) and the unchanged LTR behavior. Run withpytest tests/unit/test_rec_postprocess.py(5 passed).