diff --git a/docs/models/nerf.md b/docs/models/nerf.md
index 431f43a6d..b5813f7ad 100644
--- a/docs/models/nerf.md
+++ b/docs/models/nerf.md
@@ -52,6 +52,6 @@ How we sample the rays in space is an important design decision.
| Implementation | Mic | Ficus | Chair | Hotdog | Materials | Drums | Ship | Lego | Average |
| --------------------------------------------------------------------------------- | :-------: | --------- | :-------: | --------- | --------- | --------- | --------- | --------- | --------- |
-| nerfactory | 34.28 | **30.63** | **36.16** | 36.49 | 28.36 | **25.44** | 28.69 | **33.67** | **31.71** |
+| nerfactory | 33.76 | **31.98** | **34.35** | 36.57 | **31.00** | **25.11** | 29.87 | **34.46** | **32.14** |
| [TF NeRF](https://github.com/bmild/nerf) | 32.91 | 30.13 | 33.00 | 36.18 | 29.62 | 25.01 | 28.65 | 32.54 | 31.04 |
-| [JaxNeRF](https://github.com/google-research/google-research/tree/master/jaxnerf) | **34.53** | 30.43 | 34.08 | **36.92** | **29.91** | 25.03 | **29.36** | 33.28 | 31.69 |
+| [JaxNeRF](https://github.com/google-research/google-research/tree/master/jaxnerf) | **34.53** | 30.43 | 34.08 | **36.92** | 29.91 | 25.03 | **29.36** | 33.28 | 31.69 |
diff --git a/docs/notebooks/index.rst b/docs/notebooks/index.rst
index 003b01b21..6279c1d3d 100644
--- a/docs/notebooks/index.rst
+++ b/docs/notebooks/index.rst
@@ -7,8 +7,8 @@ Components
:maxdepth: 1
visualize_cameras.ipynb
- visualize_samplers.ipynb
visualize_samples.ipynb
+ visualize_samplers.ipynb
visualize_spatial_distortions.ipynb
visualize_encoders.ipynb
\ No newline at end of file
diff --git a/docs/notebooks/visualize_samplers.ipynb b/docs/notebooks/visualize_samplers.ipynb
index 04b71ecd6..ff85f9a5d 100644
--- a/docs/notebooks/visualize_samplers.ipynb
+++ b/docs/notebooks/visualize_samplers.ipynb
@@ -18,7 +18,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 5,
"metadata": {
"tags": [
"hide-input"
@@ -4126,6 +4126,12 @@
],
"height": 700,
"hovermode": false,
+ "margin": {
+ "b": 20,
+ "l": 20,
+ "r": 20,
+ "t": 50
+ },
"showlegend": false,
"template": {
"data": {
@@ -5038,9 +5044,9 @@
}
},
"text/html": [
- "
"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "# COLLAPSED\n",
+ "import torch\n",
+ "from nerfactory.cameras.rays import RayBundle\n",
+ "from nerfactory.graphs.modules import ray_sampler\n",
+ "import plotly.graph_objects as go\n",
+ "from plotly.subplots import make_subplots\n",
+ "\n",
+ "num_coarse_samples = 20\n",
+ "num_samples = 1000\n",
+ "near = 2\n",
+ "far = 5\n",
+ "train_stratified = False\n",
+ "\n",
+ "fig = make_subplots(\n",
+ " rows=1,\n",
+ " cols=2,\n",
+ " subplot_titles=(\"PDF\", \"Samples\"),\n",
+ ")\n",
+ "\n",
+ "uniform_sampler = ray_sampler.UniformSampler(num_samples=num_coarse_samples, train_stratified=train_stratified)\n",
+ "pdf_sampler = ray_sampler.PDFSampler(num_samples=num_samples, train_stratified=train_stratified, include_original=False)\n",
+ "\n",
+ "ray_bundle = RayBundle(\n",
+ " origins=torch.ones([1, 3]),\n",
+ " directions=torch.ones([1, 3]),\n",
+ " pixel_area=torch.ones([1, 1]),\n",
+ " nears=torch.ones([1, 1]) * near,\n",
+ " fars=torch.ones([1, 1]) * far,\n",
+ ")\n",
+ "\n",
+ "coarse_ray_samples = uniform_sampler(ray_bundle)\n",
+ "\n",
+ "# Generate arbitrary PDF\n",
+ "weights = torch.ones(num_coarse_samples)\n",
+ "weights += torch.sin(torch.linspace(0, 3 * torch.pi, num_coarse_samples))\n",
+ "weights += torch.sin(torch.linspace(0, 0.5 * torch.pi, num_coarse_samples))\n",
+ "weights -= torch.min(weights)\n",
+ "weights /= torch.sum(weights)\n",
+ "\n",
+ "samples = pdf_sampler.generate_ray_samples(ray_bundle, coarse_ray_samples, weights[None, :, None], num_samples)\n",
+ "\n",
+ "# Plotting stuff\n",
+ "x = torch.ones((num_coarse_samples * 2))\n",
+ "x[::2] = coarse_ray_samples.frustums.starts[0, :, 0]\n",
+ "x[1::2] = coarse_ray_samples.frustums.ends[0, :, 0]\n",
+ "\n",
+ "y = torch.ones((num_coarse_samples * 2))\n",
+ "y[::2] = weights\n",
+ "y[1::2] = weights\n",
+ "\n",
+ "pdf_trace = go.Scatter(x=x, y=y)\n",
+ "fig.append_trace(pdf_trace, 1, 1)\n",
+ "\n",
+ "samples_trace = go.Histogram(x=samples.frustums.starts[0, :, 0], nbinsx=100)\n",
+ "fig.append_trace(samples_trace, 1, 2)\n",
+ "\n",
+ "fig.update_yaxes(title_text=\"# Samples\", row=1, col=2)\n",
+ "fig.update_xaxes(title_text=\"Distance\", row=1, col=1)\n",
+ "fig.update_xaxes(title_text=\"Distance\", row=1, col=2)\n",
+ "\n",
+ "# Overlay both histograms\n",
+ "fig.update_layout(height=400, hovermode=False, showlegend=False, margin=dict(l=20, r=20, t=50, b=20))\n",
+ "fig.update_traces(opacity=0.7)\n",
+ "fig.show()"
+ ]
}
],
"metadata": {
diff --git a/scripts/docs/build_docs.py b/scripts/docs/build_docs.py
index 737baac1f..2b5303c2b 100644
--- a/scripts/docs/build_docs.py
+++ b/scripts/docs/build_docs.py
@@ -19,8 +19,12 @@ def run_command(command: str) -> None:
sys.exit(1)
-def main():
- """Run the github actions locally."""
+def main(clean_cache: bool = False):
+ """Run the github actions locally.
+
+ Args:
+ clean_cache: whether to clean the cache before building docs.
+ """
print_green = lambda x: print(f"\033[32m{x}\033[0m")
@@ -29,7 +33,10 @@ def main():
# Add checks for building documentation
print_green("Building Documentation")
- run_command("cd docs/; make html SPHINXOPTS='-W;'")
+ if clean_cache:
+ run_command("cd docs/; make clean; make html SPHINXOPTS='-W;'")
+ else:
+ run_command("cd docs/; make html SPHINXOPTS='-W;'")
print("\n")
print_green("=" * 100)