lmdb数据格式

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/

lmdb的一些封装函数:http://nbviewer.jupyter.org/github/joyofdata/joyofdata-articles/blob/master/deeplearning-with-caffe/Neural-Networks-with-Caffe-on-the-GPU.ipynb

参考文献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()

posted on 2016-02-27 10:37  一动不动的葱头  阅读(1084)  评论(0编辑  收藏  举报

导航