import caffeimport lmdb
import PIL.Imagefrom StringIO import StringIOimport numpy as np
lmdb_env = lmdb.open("trainval_lmdb")lmdb_txn = lmdb_env.begin()lmdb_cursor = lmdb_txn.cursor()
datum = caffe.proto.caffe_pb2.AnnotatedDatum()for key, value in lmdb_cursor: print("Key: {}", key) datum.ParseFromString(value) for ann in datum.annotation_group: print("Annotation ", ann.group_label) for a in ann.annotation: print(" instance_id:", a.instance_id) print(" bbox:", a.bbox.xmin, a.bbox.xmax, a.bbox.ymin, a.bbox.ymax, a.bbox.label)
(' instance_id:', 0)
(' bbox:', 0.5465949773788452, 0.6953405141830444, 0.17891374230384827, 0.28753992915153503, 0)
('Key: {}', '00000006_Images/1A9R00.jpg')
('Annotation ', 3)
(' instance_id:', 0)
(' bbox:', 0.6666666865348816, 0.8333333134651184, 0.0702875405550003, 0.3865814805030823, 0)
(' instance_id:', 1)
(' bbox:', 0.6146953701972961, 0.740143358707428, 0.00319488812237978, 0.17571884393692017, 0)
(' instance_id:', 2)
(' bbox:', 0.5035842061042786, 0.616487443447113, 0.00319488812237978, 0.17891374230384827, 0)
(' instance_id:', 3)
(' bbox:', 0.3333333432674408, 0.45519712567329407, 0.00319488812237978, 0.23961661756038666, 0)
('Annotation ', 2)