Enable __getitem__ for Cameras to return an instance of Cameras

Summary:
Added a custom `__getitem__` method to `CamerasBase` which returns an instance of the appropriate camera instead of the `TensorAccessor` class.

Long term we should deprecate the `TensorAccessor` and the `__getitem__` method on `TensorProperties`

FB: In the next diff I will update the uses of `select_cameras` in implicitron.

Reviewed By: bottler

Differential Revision: D33185885

fbshipit-source-id: c31995d0eb126981e91ba61a6151d5404b263f67
This commit is contained in:
Nikhila Ravi
2021-12-21 05:45:32 -08:00
committed by Facebook GitHub Bot
parent cc3259ba93
commit 28ccdb7328
3 changed files with 224 additions and 13 deletions

View File

@@ -155,7 +155,7 @@ class TensorProperties(nn.Module):
Returns:
if `index` is an index int/slice return a TensorAccessor class
with getattribute/setattribute methods which return/update the value
at the index in the original camera.
at the index in the original class.
"""
if isinstance(index, (int, slice)):
return TensorAccessor(class_object=self, index=index)