Refactor: FrameDataBuilder is more extensible.

Summary:
This is mostly a refactoring diff to reduce friction in extending the frame data.

Slight functional changes: dataset getitem now accepts (seq_name, frame_number_as_singleton_tensor) as a non-advertised feature. Otherwise this code crashes:
```
item = dataset[0]
dataset[item.sequence_name, item.frame_number]
```

Reviewed By: bottler

Differential Revision: D45780175

fbshipit-source-id: 75b8e8d3dabed954a804310abdbd8ab44a8dea29
This commit is contained in:
Roman Shapovalov
2023-05-17 10:38:34 -07:00
committed by Facebook GitHub Bot
parent d08fe6d45a
commit b0462598ac
5 changed files with 102 additions and 41 deletions

View File

@@ -210,6 +210,9 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): # pyre-ignore
seq, frame = self._index.index[frame_idx]
else:
seq, frame, *rest = frame_idx
if isinstance(frame, torch.LongTensor):
frame = frame.item()
if (seq, frame) not in self._index.index:
raise IndexError(
f"Sequence-frame index {frame_idx} not found; was it filtered out?"