import h5py import lmdb import numpy as np from tqdm import tqdm h5_path = "data/h5/features/resnet_slowfast_1.5.h5" lmdb_path = "data/features/resnet_slowfast_1.5" h5_data = h5py.File(h5_path, 'r') env = lmdb.open(lmdb_path, readonly=False, create=True, max_dbs=0, map_size=1 * 1024**3) # Open or create the LMDB database n = 0 with env.begin(write=True) as txn: # Iterate over items in the HDF5 file for key in tqdm(h5_data.keys()): print(key) # Read the feature array for the current key feature = h5_data[key][:] buffer = np.getbuffer(feature) txn.put(key.encode(), buffer) n += 1 if n > 10: break print("Conversion completed.")