How to read Datum in LMDB using Python

3,042 views
Skip to first unread message

Hiroshi Kuwajima

unread,
Mar 26, 2015, 2:17:16 PM3/26/15
to caffe...@googlegroups.com
For debug purpose, I would like to examine actual images in LMDB which are used for training. Does anyone know how to get images (in datum objects) in a given LMDB, in the same order of Caffe training, using Python?

Axel Angel

unread,
Mar 28, 2015, 6:27:17 AM3/28/15
to caffe...@googlegroups.com
You should search before asking a common question. You can find Python scripts that does what you want, you can take a look:


You can show "image" with matplotlib.pyplot.imshow.

Hiroshi Kuwajima

unread,
Mar 28, 2015, 3:19:05 PM3/28/15
to caffe...@googlegroups.com
Thank you Alex, the following code in your past answer is what I want.

        datum = caffe.proto.caffe_pb2.Datum()
        datum.ParseFromString(value)
        label = int(datum.label)
        image = caffe.io.datum_to_array(datum)
        image = image.astype(np.uint8)

> You should search before asking a common question.

Sorry, I couldn't find your answer by myself.

Steven

unread,
Apr 21, 2015, 12:43:35 PM4/21/15
to caffe...@googlegroups.com
Hiroshi - Thanks. I had the same question you did, and this was the thread I found.
Reply all
Reply to author
Forward
0 new messages