diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-09 22:30:45 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-09 22:30:45 +0200 |
commit | 316c6a456c9b9f1964f77e8ba016651405c6f9c0 (patch) | |
tree | d877b1eb429820ccf5bb0a0426358910597d203a /text_recognizer/data/mappings/emnist.py | |
parent | a96fa058827b739238972569f7c559c75ba6514f (diff) |
Remove abstract mapping
Diffstat (limited to 'text_recognizer/data/mappings/emnist.py')
-rw-r--r-- | text_recognizer/data/mappings/emnist.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/text_recognizer/data/mappings/emnist.py b/text_recognizer/data/mappings/emnist.py index ecd862e..606d200 100644 --- a/text_recognizer/data/mappings/emnist.py +++ b/text_recognizer/data/mappings/emnist.py @@ -6,22 +6,27 @@ from typing import Dict, List, Optional, Sequence, Union, Tuple import torch from torch import Tensor -from text_recognizer.data.mappings.base import AbstractMapping - ESSENTIALS_FILENAME = Path(__file__).parents[0].resolve() / "emnist_essentials.json" -class EmnistMapping(AbstractMapping): +class EmnistMapping: """Mapping for EMNIST labels.""" def __init__( - self, extra_symbols: Optional[Sequence[str]] = None, lower: bool = True + 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() - super().__init__(self.input_size, self.mapping, self.inverse_mapping) def _load_mapping(self) -> Tuple[List, Dict[str, int], List[int]]: """Return the EMNIST mapping.""" |