From 394fe5d7a8eded7a71389a960ccc2d0b3ffb3d93 Mon Sep 17 00:00:00 2001 From: Matt Tancik Date: Tue, 5 Apr 2022 13:48:00 -0700 Subject: [PATCH 1/2] add some base files --- mattport/nerf/cameras.py | 41 +++++++++++++++++++++++++++++++++++++++ mattport/nerf/loss.py | 0 mattport/nerf/renderer.py | 0 mattport/nerf/sampler.py | 0 mattport/nerf/trainer.py | 0 5 files changed, 41 insertions(+) create mode 100644 mattport/nerf/cameras.py create mode 100644 mattport/nerf/loss.py create mode 100644 mattport/nerf/renderer.py create mode 100644 mattport/nerf/sampler.py create mode 100644 mattport/nerf/trainer.py diff --git a/mattport/nerf/cameras.py b/mattport/nerf/cameras.py new file mode 100644 index 000000000..51dd72a62 --- /dev/null +++ b/mattport/nerf/cameras.py @@ -0,0 +1,41 @@ +""" +Camera Models +""" +from dataclasses import dataclass +from torchtyping import TensorType + + +@dataclass +class Rays: + """Camera rays. Can be arbitrary dimension""" + + origin: TensorType[..., 3] + direction: TensorType[..., 3] + + +class Camera: + """Base Camera. Intended to be subclassed""" + + def __init__(self, height, width, camera_to_world) -> None: + self.height = height + self.width = width + self.camera_to_world = camera_to_world + + def get_rays(self, coords: TensorType[..., 2]) -> Rays: + """Encodes an input tensor. + + Args: + coords (TensorType[..., 2]): Input tensor to be encoded + + Returns: + TensorType[..., "output_dim"]: A encoded input tensor + """ + raise NotImplementedError + + def get_all_rays(self) -> Rays: + """Generate rays for entire camera + + Returns: + Rays: Camera rays of shape [height, width] + """ + raise NotImplementedError diff --git a/mattport/nerf/loss.py b/mattport/nerf/loss.py new file mode 100644 index 000000000..e69de29bb diff --git a/mattport/nerf/renderer.py b/mattport/nerf/renderer.py new file mode 100644 index 000000000..e69de29bb diff --git a/mattport/nerf/sampler.py b/mattport/nerf/sampler.py new file mode 100644 index 000000000..e69de29bb diff --git a/mattport/nerf/trainer.py b/mattport/nerf/trainer.py new file mode 100644 index 000000000..e69de29bb From 81aa20a3d55abb5a4d36d7cf4448fdaf50aa2e43 Mon Sep 17 00:00:00 2001 From: Matt Tancik Date: Tue, 5 Apr 2022 13:50:51 -0700 Subject: [PATCH 2/2] add empty folders --- mattport/structures/__init__.py | 0 mattport/utils/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 mattport/structures/__init__.py create mode 100644 mattport/utils/__init__.py diff --git a/mattport/structures/__init__.py b/mattport/structures/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/mattport/utils/__init__.py b/mattport/utils/__init__.py new file mode 100644 index 000000000..e69de29bb