Load leveldb data in Python
I have extracted the features from a image, which are store in the directory "features", and I want to use this features for further processing. However, when I use python and use leveldb to open it and see the values of these features, it show something following:
Input: leveldb.Get('1') Output: \x00\x005\x00\x00\x00\x005\x00\x00\x00\x005\xe5\xb8Q?5L\x7f\x8a? ''''''' \x00\x00\x00\x005n\xe0>@5\x00\x00\x00\x005\x00\x00\x00\x0050Tr@5\xb9\x17\xef@'
What's this meaning? And How can I retrieve the feature value that I want from this?? I use python, Thanks a lot!!!~~
It is stored as a serialised caffe "Datum" protobuffer, you can convert it to a numpy array like this:
import caffe
from caffe.proto import caffe_pb2
datum = caffe_pb2.Datum.FromString(db.Get('1'))
arr = caffe.io.datum_to_array(datum)
Hi @shelhamer
I also extracted the features which are stored in leveldb format in the folder features by the name data.mdb. When I run your python script I get the error :
NameError Traceback (most recent call last)
NameError: name 'db' is not defined
Can you please let me know what I should do? I am new to lmdb fromat hence sorry for asking!!
It looks like you need to define db first. db = plyvel.DB('/path/to/db/folder') before calling db.get