diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-11 23:09:22 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-11 23:09:22 +0200 |
commit | 6df941bdf5cad80db38d851dcb23a08a9dc55617 (patch) | |
tree | ecbe41259990955201f910f0113c723cd080ab78 /text_recognizer/data/mappings | |
parent | 8177b5210fbbe11bd361dedbd5b4a4e1950bdb2e (diff) |
Fix emnist mapping
Diffstat (limited to 'text_recognizer/data/mappings')
-rw-r--r-- | text_recognizer/data/mappings/emnist.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/text_recognizer/data/mappings/emnist.py b/text_recognizer/data/mappings/emnist.py index 606d200..03465a1 100644 --- a/text_recognizer/data/mappings/emnist.py +++ b/text_recognizer/data/mappings/emnist.py @@ -14,20 +14,21 @@ class EmnistMapping: def __init__( self, - input_size: List[int], - mapping: List[str], - inverse_mapping: Dict[str, int], extra_symbols: Optional[Sequence[str]] = None, lower: bool = True, ) -> None: - self.input_size = input_size - self.mapping = mapping - self.inverse_mapping = inverse_mapping self.extra_symbols = set(extra_symbols) if extra_symbols is not None else None self.mapping, self.inverse_mapping, self.input_size = self._load_mapping() if lower: self._to_lower() + def __len__(self) -> int: + return len(self.mapping) + + @property + def num_classes(self) -> int: + return self.__len__() + def _load_mapping(self) -> Tuple[List, Dict[str, int], List[int]]: """Return the EMNIST mapping.""" with ESSENTIALS_FILENAME.open() as f: |