// The encode is only essential in Python 3
txn.put(key, data)
txn.put(meta_key, meta.encode("ascii"))
print("Finish writing to lmdb - {}.".format(len(file_list)))
// create keys cache
keys_cache_file = os.path.join(lmdb_save_path, "_keys_cache.p")
env = lmdb.open(lmdb_save_path, readonly=True, lock=False, readahead=False, meminit=False)
After Change
env = lmdb.open(lmdb_save_path, map_size=data_size * 10)
print("Finish reading {} images.\nWrite lmdb...".format(len(img_list)))
pbar = ProgressBar(len(img_list))
with env.begin(write=True) as txn: // txn is a Transaction object
for i, v in enumerate(img_list):
pbar.update("Write {}".format(v))
base_name = os.path.splitext(os.path.basename(v))[0]
key = base_name.encode("ascii")
data = dataset[i]
if dataset[i].ndim == 2: