Last active
February 14, 2017 10:59
Revisions
-
hiwonjoon revised this gist
May 9, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,14 @@ db = leveldb.LevelDB('./cifar_test',block_size=40 * (2 << 20) ) import struct def unpickle(file): import cPickle fo = open(file,'rb') dict = cPickle.load(fo) fo.close() return dict obj = unpickle('./test.pkl') batch = leveldb.WriteBatch() print 'Start Reading...' -
hiwonjoon renamed this gist
May 9, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
hiwonjoon created this gist
May 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ import caffe_pb2 as proto import leveldb import sys db = leveldb.LevelDB('./cifar_test',block_size=40 * (2 << 20) ) import struct batch = leveldb.WriteBatch() print 'Start Reading...' length = len(obj.get_data()) for i, label_data in enumerate(zip(obj.get_data()[1],obj.get_data()[0])): datum = proto.Datum() datum.channels = 3 datum.height = 32 datum.width = 32 datum.label = int(label_data[0][0]) for data in label_data[1]: datum.float_data.append(data); key = '%05d' % i out = datum.SerializeToString() batch.Put(key,out) print 'End Reading...' print 'Strat Writing DB...' db.Write(batch,sync=True) print 'End Writing DB...' print 'Done' db = None