Skip to content

Commit b19a526

Browse files
vedanujapsdehal
authored andcommitted
[fix] Fix LMDBFeatureReader (#116)
Summary: Fix LMDBFeatureReader Test Plan : Test with mmimdb dataset. Pull Request resolved: https://github.com/fairinternal/pythia-internal/pull/116 Reviewed By: apsdehal Differential Revision: D21445705 Pulled By: vedanuj fbshipit-source-id: af96f3cc32f50d3c97ebc2df8ca815f97bea0c0d
1 parent f6abb44 commit b19a526

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

mmf/datasets/databases/readers/feature_readers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,14 @@ def _load(self, image_file_path):
202202
image_id = int(split.split("_")[-1])
203203
# Try fetching to see if it actually exists otherwise fall back to
204204
# default
205-
_ = self.image_id_indices[image_id]
205+
img_id_idx = self.image_id_indices[str(image_id).encode()]
206206
except (ValueError, KeyError):
207207
# The image id is complex or involves folder, use it directly
208-
image_id = split
209-
image_id = str(image_id).encode()
208+
image_id = str(split).encode()
209+
img_id_idx = self.image_id_indices[image_id]
210210

211211
with self.env.begin(write=False, buffers=True) as txn:
212-
image_info = pickle.loads(
213-
txn.get(self.image_ids[self.image_id_indices[image_id]])
214-
)
212+
image_info = pickle.loads(txn.get(self.image_ids[img_id_idx]))
215213

216214
return image_info
217215

0 commit comments

Comments
 (0)