HOW TO CONVERT EXTRACTED LEVELDB DATABASE INTO MATLAB CONSUMABLE FILE

Visto 231 veces
Saltar al primer mensaje no leído

lolale...@gmail.com

no leída,
20 mar 2016, 10:41:2120/3/16
a Caffe Users
hHey guys i am new for caffe, i want to extract feature for 1491 images but i couldn't convert extracted feature in the  leveldb folder to matlab consumable file and also i don't know how to map the feature to the corresponding image .
 when i try to convert extracted feature for 6 images using  the following script it always gives me 32.8kb file and when i read it i always got a vector (1x8192) regardless of number of image and batch size

import caffe
import leveldb
import numpy as np
from caffe.proto import caffe_pb2

db = leveldb.LevelDB('/usr/lib/python2.7/caffe/examples/_temp/features')
datum = caffe_pb2.Datum()

for key, value in db.RangeIter():
    datum.ParseFromString(value)

    label = datum.label
    data = caffe.io.datum_to_array(datum)

    #
    image = np.transpose(data, (1,2,0))

    np.save('feature.txt',image)


-is there any one who tell me where i made a misteke or what to do inorder to convert "leveldb" file into matlab consumable file?
-and also is a single image represented by 4096 dimensional vector hence should i expect the number of image times 4096 for the total image i have extracted?

THANKS IN ADVANCE!

yeshwanth Napolean

no leída,
4 abr 2017, 8:23:524/4/17
a Caffe Users
I am new to caffe as well, but from what I can see,

data = caffe.io.datum_to_array(datum)

basically rewrites previously saved arrays as the loop runs, I dont know if this is the best fix but you could try,

i = 0 
data = np.zeros((128,4096))


db = leveldb.LevelDB('/usr/lib/python2.7/caffe/examples/_temp/features')
datum = caffe_pb2.Datum()

for key, value in db.RangeIter():
    datum.ParseFromString(value)

    label = datum.label
    data[i,:] = caffe.io.datum_to_array(datum)
    i += 1
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos