Bina-0.4-Rizeh / stallion /indra-scale /visual_token.py
Reza2kn's picture
Bina 0.4 Rizeh: full 95k production pipeline
4b917c4
Raw History Blame Contribute Delete
491 Bytes
"""Preserve the trained RTL bank's explicit visual-order convention in table splits."""
class RTLVisualChar(str):
base_rtl = True
class CTCDecodeMixin:
def _decode(self, tokens):
if any(getattr(t[0], 'base_rtl', False) for t in tokens):
from indra_ocr.rtl import flip
visual = ''.join(t[0] if isinstance(t[0], str) else self.vocab.chars[t[0] - 1] for t in tokens)
return flip(visual, base_rtl=True)
return super()._decode(tokens)