MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / __init__

Method __init__

tools/data/lmdb_dataset_test.py:40–85  ·  view source on GitHub ↗
(self,
                 config,
                 mode,
                 logger,
                 seed=None,
                 epoch=1,
                 gpu_i=0,
                 max_label_len: int = 25,
                 min_image_dim: int = 0,
                 remove_whitespace: bool = True,
                 normalize_unicode: bool = True,
                 unlabelled: bool = False,
                 transform=None,
                 task='rec')

Source from the content-addressed store, hash-verified

38 """
39
40 def __init__(self,
41 config,
42 mode,
43 logger,
44 seed=None,
45 epoch=1,
46 gpu_i=0,
47 max_label_len: int = 25,
48 min_image_dim: int = 0,
49 remove_whitespace: bool = True,
50 normalize_unicode: bool = True,
51 unlabelled: bool = False,
52 transform=None,
53 task='rec'):
54 dataset_config = config[mode]['dataset']
55 global_config = config['Global']
56 max_label_len = global_config['max_text_length']
57 self.root = dataset_config['data_dir']
58 self._env = None
59 self.unlabelled = unlabelled
60 self.transform = transform
61 self.labels = []
62 self.filtered_index_list = []
63 self.min_image_dim = min_image_dim
64 self.filter_label = dataset_config.get('filter_label',
65 True) #'data_dir']filter_label
66 character_dict_path = global_config.get('character_dict_path', None)
67 use_space_char = global_config.get('use_space_char', False)
68 if character_dict_path is None:
69 char_test = '0123456789abcdefghijklmnopqrstuvwxyz'
70 else:
71 char_test = ''
72 with open(character_dict_path, 'rb') as fin:
73 lines = fin.readlines()
74 for line in lines:
75 line = line.decode('utf-8').strip('\n').strip('\r\n')
76 char_test += line
77 if use_space_char:
78 char_test += ' '
79 self.ops = create_operators(dataset_config['transforms'],
80 global_config)
81 self.num_samples = self._preprocess_labels(char_test,
82 remove_whitespace,
83 normalize_unicode,
84 max_label_len,
85 min_image_dim)
86
87 def __del__(self):
88 if self._env is not None:

Callers

nothing calls this directly

Calls 4

_preprocess_labelsMethod · 0.95
create_operatorsFunction · 0.90
getMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected