Read a LMDB database with a custom decoder and produce decoded outputs.
| 156 | |
| 157 | |
| 158 | class LMDBDataDecoder(MapData): |
| 159 | """ Read a LMDB database with a custom decoder and produce decoded outputs.""" |
| 160 | def __init__(self, lmdb_data, decoder): |
| 161 | """ |
| 162 | Args: |
| 163 | lmdb_data: a :class:`LMDBData` instance. |
| 164 | decoder (k,v -> dp | None): a function taking k, v and returning a datapoint, |
| 165 | or return None to discard. |
| 166 | """ |
| 167 | def f(dp): |
| 168 | return decoder(dp[0], dp[1]) |
| 169 | super(LMDBDataDecoder, self).__init__(lmdb_data, f) |
| 170 | |
| 171 | |
| 172 | def CaffeLMDB(lmdb_path, shuffle=True, keys=None): |