Saeed
Saeed

Reputation: 742

Merge two LMDB databases for feeding to the network (caffe)

Here are two LMDB databases. Is there any way to merge these two databases and feed it to network using caffe?

Upvotes: 2

Views: 3384

Answers (1)

Aidan Gomez
Aidan Gomez

Reputation: 8627

Simply write a script using the python lmdb interface. Something like:

import lmdb

env = lmdb.open("path/to/lmdbFile")
txn = env.begin(write=True)

database1 = txn.cursor("db1Name")
database2 = txn.cursor("db2Name")

env.open_db(key="newDBName", txn=txn)
newDatabase = txt.cursor("newDBName")

for (key, value) in database1:
    newDatabase.put(key, value)

for (key, value) in database2:
    newDatabase.put(key, value)

or you could just as simply add one to the other by:

for (key, value) in database2:
    database1.put(key, value)

Upvotes: 5

Related Questions