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

Method __getitem__

tools/data/text_lmdb_dataset.py:115–128  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

113 return label
114
115 def __getitem__(self, idx):
116 lmdb_idx, file_idx = self.data_idx_order_list[idx]
117 lmdb_idx = int(lmdb_idx)
118 file_idx = int(file_idx)
119 sample_info = self.get_lmdb_sample_info(
120 self.lmdb_sets[lmdb_idx]['txn'], file_idx)
121 if sample_info is None:
122 return self.__getitem__(np.random.randint(self.__len__()))
123 label = sample_info
124 data = {'label': label}
125 outs = transform(data, self.ops)
126 if outs is None:
127 return self.__getitem__(np.random.randint(self.__len__()))
128 return outs
129
130 def __len__(self):
131 return self.data_idx_order_list.shape[0]

Callers

nothing calls this directly

Calls 3

get_lmdb_sample_infoMethod · 0.95
__len__Method · 0.95
transformFunction · 0.90

Tested by

no test coverage detected