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

蓝咒 提交于 2019-12-07 22:02:43

问题


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


回答1:


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)


来源:https://stackoverflow.com/questions/33443020/merge-two-lmdb-databases-for-feeding-to-the-network-caffe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!