diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-04-03 21:59:07 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-04-03 21:59:07 +0200 |
commit | 07f2cc3665a1a60efe8ed8073cad6ac4f344b2c2 (patch) | |
tree | d24ae8e3b9b39bfcfb3b850b30cb966eb3b064a7 /text_recognizer/data/transforms.py | |
parent | 3196144ec99e803cef218295ddea592748931c57 (diff) |
Add IAM paragraphs dataset
Diffstat (limited to 'text_recognizer/data/transforms.py')
-rw-r--r-- | text_recognizer/data/transforms.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/text_recognizer/data/transforms.py b/text_recognizer/data/transforms.py index 2291eec..616e236 100644 --- a/text_recognizer/data/transforms.py +++ b/text_recognizer/data/transforms.py @@ -9,7 +9,8 @@ from torch import Tensor from text_recognizer.datasets.iam_preprocessor import Preprocessor from text_recognizer.data.emnist import emnist_mapping - + + class ToLower: """Converts target to lower case.""" @@ -23,15 +24,11 @@ class ToCharcters: """Converts integers to characters.""" def __init__(self) -> None: - self.mapping, _, _ = emnist_mapping() + self.mapping, _, _ = emnist_mapping() def __call__(self, y: Tensor) -> str: """Converts a Tensor to a str.""" - return ( - "".join([self.mapping(int(i)) for i in y]) - .strip("<p>") - .replace(" ", "▁") - ) + return "".join([self.mapping(int(i)) for i in y]).strip("<p>").replace(" ", "▁") class WordPieces: |