127 def __getitem__(self, index):
128 if self.env is None:
129 self._init_lmdb()
130 img_key, pid, camid = self.img_items[index]
131
132 with self.env.begin(write=False) as txn:
133 buf = txn.get(img_key.encode('ascii'))
134
135 img_flat = np.frombuffer(buf, dtype=np.uint8)
136
137 im = cv2.imdecode(img_flat, cv2.IMREAD_COLOR)
138 im = Image.fromarray(im[:, :, ::-1])
139
140 if self.transform is not None:
141 im = self.transform(im)
142
143 return {'images': im, 'targets': pid,
144 'camids': 0, 'img_paths': img_key}
145