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

Method get_ext_data

tools/data/strlmdb_dataset.py:91–115  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

89 return imgori
90
91 def get_ext_data(self):
92 ext_data_num = 0
93 for op in self.ops:
94 if hasattr(op, 'ext_data_num'):
95 ext_data_num = getattr(op, 'ext_data_num')
96 break
97 load_data_ops = self.ops[:self.ext_op_transform_idx]
98 ext_data = []
99
100 while len(ext_data) < ext_data_num:
101 lmdb_idx, file_idx = self.data_idx_order_list[np.random.randint(
102 len(self))]
103 lmdb_idx = int(lmdb_idx)
104 file_idx = int(file_idx)
105 sample_info = self.get_lmdb_sample_info(
106 self.lmdb_sets[lmdb_idx]['txn'], file_idx)
107 if sample_info is None:
108 continue
109 img, label = sample_info
110 data = {'image': img, 'label': label}
111 data = transform(data, load_data_ops)
112 if data is None:
113 continue
114 ext_data.append(data)
115 return ext_data
116
117 def get_lmdb_sample_info(self, txn, index):
118 label_key = 'label-%09d'.encode() % index

Callers 1

__getitem__Method · 0.95

Calls 2

get_lmdb_sample_infoMethod · 0.95
transformFunction · 0.90

Tested by

no test coverage detected