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

Method __init_lmdb

tools/data/native_size_dataset.py:452–477  ·  view source on GitHub ↗

Initializes the LMDB environment.

(self)

Source from the content-addressed store, hash-verified

450 return img_label_pair_list
451
452 def __init_lmdb(self):
453 """Initializes the LMDB environment."""
454 if self.env is None:
455 # Set max_readers high enough for potential multi-process data loading
456 # map_size should be large enough to hold your entire dataset
457 # self.env = lmdb.open(self.lmdb_path, readonly=True, create=False) # create=False 表示如果不存在则报错
458 en_lmdb_path = f'{self.root_path}/en_pdf_lmdb'
459 self.env = lmdb.open(
460 en_lmdb_path,
461 max_readers=32,
462 readonly=True,
463 lock=False,
464 readahead=False,
465 meminit=False,
466 )
467 self.txn = self.env.begin()
468 ch_lmdb_path = f'{self.root_path}/ch_pdf_lmdb'
469 self.env_ch = lmdb.open(
470 ch_lmdb_path,
471 max_readers=32,
472 readonly=True,
473 lock=False,
474 readahead=False,
475 meminit=False,
476 )
477 self.txn_ch = self.env_ch.begin()
478
479 def __init_line_lmdb(self, epoch_current):
480 """Initializes the LMDB environment."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected