Get attributes of datum in Lmdb

31 views
Skip to first unread message

Mansi Goel

unread,
May 29, 2017, 6:46:21 AM5/29/17
to Caffe Users
Hi

I want to get all the attributes of datum object from my lmdb file in Python.

Below is the code I am using to read lmdb file.

import caffe
import lmdb
import PIL.Image
from StringIO import StringIO
import numpy as np

def read_lmdb(lmdb_file):
    cursor = lmdb.open(lmdb_file, readonly=True).begin().cursor()
    datum = caffe.proto.caffe_pb2.Datum()
    for key, value in cursor:
        datum.ParseFromString(value)
        s = StringIO()
        s.write(datum.data)
        s.seek(0)
        yield s, datum.label
 
lmdb_dir = '/root/ssd/caffe/examples/VOC0712/VOC0712_trainval_lmdb'
for im, label in read_lmdb(lmdb_dir):
    print label, im

I tried dir(datum) but it didn't contain attributes like data, label etc.

Kindly help.
Reply all
Reply to author
Forward
0 new messages