Download stallion/indra-scale/visual_token.py from Reza2kn/Bina-0.4-Rizeh: direct link, hf CLI and curl.
- Browser
- Download file 491 Bytes
-
https://huggingface.co/Reza2kn/Bina-0.4-Rizeh/resolve/main/stallion/indra-scale/visual_token.py
- Command line
-
hf download hf://Reza2kn/Bina-0.4-Rizeh/stallion/indra-scale/visual_token.py
-
curl -L -o visual_token.py https://huggingface.co/Reza2kn/Bina-0.4-Rizeh/resolve/main/stallion/indra-scale/visual_token.py
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) | |