http://deepdish.io/2015/04/28/creating-lmdb-in-python/
https://lmdb.readthedocs.org/en/release/
https://github.com/BVLC/caffe/issues/1698#issuecomment-70211045
lmdb的安装:https://lmdb.readthedocs.org/en/release/
参考文献3:
import caffe
import lmdb
from PIL import Image
in_db = lmdb.open('image-lmdb', map_size=int(1e12))
with in_db.begin(write=True) as in_txn:
for in_idx, in_ in enumerate(inputs):
# load image:
# - as np.uint8 {0, ..., 255}
# - in BGR (switch from RGB)
# - in Channel x Height x Width order (switch from H x W x C)
im = np.array(Image.open(in_)) # or load whatever ndarray you need
im = im[:,:,::-1]
im = im.transpose((2,0,1))
im_dat = caffe.io.array_to_datum(im)
in_txn.put('{:0>10d}'.format(in_idx), im_dat.SerializeToString())
in_db.close()