Skip to content

Commit 906bcf3

Browse files
committed
fix: append space character to PaddleOCR text dicts if not present
1 parent 663845c commit 906bcf3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

manga_translator/ocr/model_paddleocr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ def _load_char_dict(self, model_config: dict) -> List[str]:
290290
if not os.path.exists(dict_path):
291291
raise FileNotFoundError(f"Dictionary not found: {dict_path}")
292292
with open(dict_path, 'r', encoding='utf-8') as f:
293-
return ['<blank>'] + [line.strip() for line in f]
293+
chars = [line.strip('\r\n') for line in f]
294+
if ' ' not in chars:
295+
chars.append(' ')
296+
return ['<blank>'] + chars
294297

295298
async def _infer(self, image: np.ndarray, textlines: List[Quadrilateral],
296299
config: OcrConfig, verbose: bool = False, q=None) -> List[Quadrilateral]:

0 commit comments

Comments
 (0)