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

Method get_ext_data

tools/data/lmdb_dataset.py:89–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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