Skip to content

Commit

Permalink
Merge pull request #9 from matajoh/visualizer_refactor
Browse files Browse the repository at this point in the history
Visualizer refactor
  • Loading branch information
matajoh authored Jul 13, 2022
2 parents 4fa4b49 + e50a4e7 commit 7a5c0d7
Show file tree
Hide file tree
Showing 27 changed files with 1,839 additions and 889 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ dataset = ffn.PixelDataset.create(path_to_image_file, color_space="RGB",
## 3D Datasets

This is where the library becomes a bit picky about input data. The
[`RayDataset`](nerf/ray_dataset.py) supports a set format for data,
[`ImageDataset`](nerf/image_dataset.py) supports a set format for data,
and we provide several datasets in this format to play
with. These datasets are not stored in the repo, but the library will
automatically download them to the `data` folder when you first requests them
which you can do like so:

```python
dataset = ffn.RayDataset.load("antinous_400.npz", split="train", num_samples=64)
dataset = ffn.ImageDataset.load("antinous_400.npz", split="train", num_samples=64)
```

We recommend you use one of the following (all datasets are provided in 400 and 800 versions):
Expand Down Expand Up @@ -231,7 +231,7 @@ It will produce the frames of the following video:

https://user-images.githubusercontent.com/6894931/142744837-382e13b1-d1cf-4305-870a-b64763c73e54.mp4

Another way to visualize what the model has learned is toproduce a
Another way to visualize what the model has learned is to produce a
voxelization of the model. This is different from the voxel-based volume
rendering, in which multiple voxels contribute to a single sample. Rather, it
is a sparse octree containing voxels at the places the model has determined are
Expand Down
18 changes: 9 additions & 9 deletions azureml/aml_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ channels:
- pytorch
- nvidia
dependencies:
- python=3.7
- cudatoolkit=11.1
- pytorch=1.9.0
- torchvision=0.10
- torchaudio=0.9
- pip=20.2
- python=3.9
- cudatoolkit=11.3
- pytorch=1.12.0
- torchvision=0.13.0
- torchaudio=0.12.0
- pip=21.2.4
- cudnn
- pip:
- azureml-defaults
- azureml-train-core
- ffmpeg-python
- matplotlib
- numba==0.54.1
- numpy==1.20.3
- opencv-python-headless>=4.5.3
- numba==0.55.2
- numpy==1.22.4
- opencv-python-headless>=4.5.5
- progress
- requests
- scenepic
Expand Down
31 changes: 27 additions & 4 deletions fourier_feature_nets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@
MLP,
PositionalFourierMLP
)
from .image_dataset import ImageDataset
from .nerf_model import NeRF
from .octree import OcTree
from .pixel_dataset import PixelDataset
from .ray_caster import Raycaster
from .ray_dataset import RayData, RayDataset
from .ray_dataset import RayDataset
from .ray_sampler import RaySampler, RaySamples
from .signal_dataset import SignalDataset
from .utils import ETABar, interpolate_bilinear, load_model, orbit
from .utils import (
calculate_blend_weights,
ETABar,
exponential_lr_decay,
hemisphere,
interpolate_bilinear,
load_model,
orbit
)
from .version import __version__
from .visualizers import (
ActivationVisualizer,
ComparisonVisualizer,
EvaluationVisualizer,
OrbitVideoVisualizer
)
from .voxels_model import Voxels

__all__ = ["__version__",
Expand All @@ -29,17 +44,25 @@
"FourierFeatureMLP",
"PositionalFourierMLP",
"GaussianFourierMLP",
"ImageDataset",
"Voxels",
"calculate_blend_weights",
"exponential_lr_decay",
"interpolate_bilinear",
"hemisphere",
"load_model",
"orbit",
"OcTree",
"PixelDataset",
"Raycaster",
"RaySampler",
"RaySamples",
"RayData",
"RayDataset",
"Resolution",
"SignalDataset",
"Triangulation"]
"Triangulation",
"ActivationVisualizer",
"ComparisonVisualizer",
"EvaluationVisualizer",
"OrbitVideoVisualizer",
"PatchVisualizer"]
12 changes: 12 additions & 0 deletions fourier_feature_nets/camera_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def square(self) -> "Resolution":
size = min(self.width, self.height)
return Resolution(size, size)

@property
def ratio(self) -> float:
"""Aspect ratio."""
return self.width / self.height


class CameraInfo(NamedTuple("CameraInfo", [("name", str),
("resolution", Resolution),
Expand Down Expand Up @@ -79,6 +84,13 @@ def project(self, positions: np.ndarray) -> np.ndarray:
points = points[:, :2] / points[:, 2:3]
return points

@property
def fov_y_degrees(self) -> float:
"""Y-axis field of view (in degrees) for the camera."""
fov_y = (0.5 * self.resolution.width) / self.intrinsics[1, 1]
fov_y = 2 * np.arctan(fov_y)
return fov_y * 180 / np.pi

@property
def position(self) -> np.ndarray:
"""Returns the position of the camera in world coordinates."""
Expand Down
Loading

0 comments on commit 7a5c0d7

Please sign in to comment.