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

Method __getitem__

tools/data/ratio_dataset_test.py:241–270  ·  view source on GitHub ↗
(self, properties)

Source from the content-addressed store, hash-verified

239 return imgbuf, label
240
241 def __getitem__(self, properties):
242 img_width = properties[0]
243 img_height = properties[1]
244 idx = properties[2]
245 ratio = properties[3]
246 lmdb_idx, file_idx = self.data_idx_order_list[idx]
247 lmdb_idx = int(lmdb_idx)
248 file_idx = int(file_idx)
249 sample_info = self.get_lmdb_sample_info(
250 self.lmdb_sets[lmdb_idx]['txn'], file_idx)
251 if sample_info is None:
252 ratio_ids = np.where(self.wh_ratio == ratio)[0].tolist()
253 ids = random.sample(ratio_ids, 1)
254 return self.__getitem__([img_width, img_height, ids[0], ratio])
255 img, label = sample_info
256 data = {'image': img, 'label': label}
257 outs = transform(data, self.ops[:-1])
258 if outs is not None:
259 outs = self.resize_norm_img(outs, ratio, padding=False)
260 if outs is None:
261 ratio_ids = np.where(self.wh_ratio == ratio)[0].tolist()
262 ids = random.sample(ratio_ids, 1)
263 return self.__getitem__([img_width, img_height, ids[0], ratio])
264
265 outs = transform(outs, self.ops[-1:])
266 if outs is None:
267 ratio_ids = np.where(self.wh_ratio == ratio)[0].tolist()
268 ids = random.sample(ratio_ids, 1)
269 return self.__getitem__([img_width, img_height, ids[0], ratio])
270 return outs
271
272 def __len__(self):
273 return self.data_idx_order_list.shape[0]

Callers

nothing calls this directly

Calls 3

get_lmdb_sample_infoMethod · 0.95
resize_norm_imgMethod · 0.95
transformFunction · 0.90

Tested by

no test coverage detected