Skip to content

fix: handle return_word_box=True for Arabic text recognition#5030

Merged
Bobholamovic merged 2 commits intoPaddlePaddle:developfrom
brandenkmurray:bm/fix-arabic-word-box
Mar 9, 2026
Merged

fix: handle return_word_box=True for Arabic text recognition#5030
Bobholamovic merged 2 commits intoPaddlePaddle:developfrom
brandenkmurray:bm/fix-arabic-word-box

Conversation

@brandenkmurray
Copy link

@brandenkmurray brandenkmurray commented Mar 3, 2026

Summary

Fix TypeError when using Arabic OCR models with return_word_box=True.

Related issue: PaddlePaddle/PaddleOCR#16952

Root Cause

When return_word_box=True, CTCLabelDecode returns texts as a list of tuples (text_string, word_info_list) instead of plain strings (see processors.py line 294). The Arabic bidi reshaping code at predictor.py line 139 passes these tuples directly to get_display(), which expects a unicode string.

Fix

Check whether each element in texts is a tuple. If so, apply get_display() only to the text string while preserving the word box info. Plain string mode is unaffected.

Reproduction

from paddleocr import PaddleOCR

ocr = PaddleOCR(lang='ar')
result = ocr.predict('arabic_text.png', return_word_box=True)  # crashes without fix

@CLAassistant
Copy link

CLAassistant commented Mar 3, 2026

CLA assistant check
All committers have signed the CLA.

@paddle-bot
Copy link

paddle-bot bot commented Mar 3, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Mar 3, 2026
@luotao1
Copy link
Collaborator

luotao1 commented Mar 3, 2026

Related issue: https://github.com/PaddlePaddle/PaddleX/issues/16952

404 error

@brandenkmurray
Copy link
Author

Related issue: https://github.com/PaddlePaddle/PaddleX/issues/16952

404 error

Sorry, should be PaddlePaddle/PaddleOCR#16952

@Bobholamovic Bobholamovic merged commit 3317b8c into PaddlePaddle:develop Mar 9, 2026
6 of 8 checks passed
TingquanGao pushed a commit to TingquanGao/PaddleX that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants