mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-22 07:10:34 +08:00
ukrainebanner. NDCMultinomialRaysampler
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -97,7 +97,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Absolute camera orientation given set of relative camera pairs
|
||||
@@ -57,7 +57,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -84,7 +84,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Camera position optimization using differentiable rendering
|
||||
@@ -44,7 +44,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -59,7 +59,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Dataloaders for ShapeNetCore and R2N2
|
||||
@@ -39,7 +39,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -98,7 +98,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Deform a source mesh to form a target mesh using 3D loss functions
|
||||
@@ -56,7 +56,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -64,7 +64,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
@@ -99,7 +100,7 @@
|
||||
"from pytorch3d.transforms import so3_exp_map\n",
|
||||
"from pytorch3d.renderer import (\n",
|
||||
" FoVPerspectiveCameras, \n",
|
||||
" NDCGridRaysampler,\n",
|
||||
" NDCMultinomialRaysampler,\n",
|
||||
" MonteCarloRaysampler,\n",
|
||||
" EmissionAbsorptionRaymarcher,\n",
|
||||
" ImplicitRenderer,\n",
|
||||
@@ -185,7 +186,7 @@
|
||||
"The renderer is composed of a *raymarcher* and a *raysampler*.\n",
|
||||
"- The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use two different raysamplers:\n",
|
||||
" - `MonteCarloRaysampler` is used to generate rays from a random subset of pixels of the image plane. The random subsampling of pixels is carried out during **training** to decrease the memory consumption of the implicit model.\n",
|
||||
" - `NDCGridRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user). In combination with the implicit model of the scene, `NDCGridRaysampler` consumes a large amount of memory and, hence, is only used for visualizing the results of the training at **test** time.\n",
|
||||
" - `NDCMultinomialRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user). In combination with the implicit model of the scene, `NDCMultinomialRaysampler` consumes a large amount of memory and, hence, is only used for visualizing the results of the training at **test** time.\n",
|
||||
"- The *raymarcher* takes the densities and colors sampled along each ray and renders each ray into a color and an opacity value of the ray's source pixel. Here we use the `EmissionAbsorptionRaymarcher` which implements the standard Emission-Absorption raymarching algorithm."
|
||||
]
|
||||
},
|
||||
@@ -210,10 +211,10 @@
|
||||
"\n",
|
||||
"# 1) Instantiate the raysamplers.\n",
|
||||
"\n",
|
||||
"# Here, NDCGridRaysampler generates a rectangular image\n",
|
||||
"# Here, NDCMultinomialRaysampler generates a rectangular image\n",
|
||||
"# grid of rays whose coordinates follow the PyTorch3D\n",
|
||||
"# coordinate conventions.\n",
|
||||
"raysampler_grid = NDCGridRaysampler(\n",
|
||||
"raysampler_grid = NDCMultinomialRaysampler(\n",
|
||||
" image_height=render_size,\n",
|
||||
" image_width=render_size,\n",
|
||||
" n_pts_per_ray=128,\n",
|
||||
@@ -843,7 +844,7 @@
|
||||
" fov=target_cameras.fov[0],\n",
|
||||
" device=device,\n",
|
||||
" )\n",
|
||||
" # Note that we again render with `NDCGridRaySampler`\n",
|
||||
" # Note that we again render with `NDCMultinomialRaysampler`\n",
|
||||
" # and the batched_forward function of neural_radiance_field.\n",
|
||||
" frames.append(\n",
|
||||
" renderer_grid(\n",
|
||||
@@ -866,7 +867,7 @@
|
||||
"source": [
|
||||
"## 6. Conclusion\n",
|
||||
"\n",
|
||||
"In this tutorial, we have shown how to optimize an implicit representation of a scene such that the renders of the scene from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's implicit function renderer composed of either a `MonteCarloRaysampler` or `NDCGridRaysampler`, and an `EmissionAbsorptionRaymarcher`."
|
||||
"In this tutorial, we have shown how to optimize an implicit representation of a scene such that the renders of the scene from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's implicit function renderer composed of either a `MonteCarloRaysampler` or `NDCMultinomialRaysampler`, and an `EmissionAbsorptionRaymarcher`."
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Fit a simple Neural Radiance Field via raymarching
|
||||
@@ -50,7 +50,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
@@ -82,7 +83,7 @@ from pytorch3d.structures import Volumes
|
||||
from pytorch3d.transforms import so3_exp_map
|
||||
from pytorch3d.renderer import (
|
||||
FoVPerspectiveCameras,
|
||||
NDCGridRaysampler,
|
||||
NDCMultinomialRaysampler,
|
||||
MonteCarloRaysampler,
|
||||
EmissionAbsorptionRaymarcher,
|
||||
ImplicitRenderer,
|
||||
@@ -145,7 +146,7 @@ print(f'Generated {len(target_images)} images/silhouettes/cameras.')
|
||||
# The renderer is composed of a *raymarcher* and a *raysampler*.
|
||||
# - The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use two different raysamplers:
|
||||
# - `MonteCarloRaysampler` is used to generate rays from a random subset of pixels of the image plane. The random subsampling of pixels is carried out during **training** to decrease the memory consumption of the implicit model.
|
||||
# - `NDCGridRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user). In combination with the implicit model of the scene, `NDCGridRaysampler` consumes a large amount of memory and, hence, is only used for visualizing the results of the training at **test** time.
|
||||
# - `NDCMultinomialRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user). In combination with the implicit model of the scene, `NDCMultinomialRaysampler` consumes a large amount of memory and, hence, is only used for visualizing the results of the training at **test** time.
|
||||
# - The *raymarcher* takes the densities and colors sampled along each ray and renders each ray into a color and an opacity value of the ray's source pixel. Here we use the `EmissionAbsorptionRaymarcher` which implements the standard Emission-Absorption raymarching algorithm.
|
||||
|
||||
# In[ ]:
|
||||
@@ -166,10 +167,10 @@ volume_extent_world = 3.0
|
||||
|
||||
# 1) Instantiate the raysamplers.
|
||||
|
||||
# Here, NDCGridRaysampler generates a rectangular image
|
||||
# Here, NDCMultinomialRaysampler generates a rectangular image
|
||||
# grid of rays whose coordinates follow the PyTorch3D
|
||||
# coordinate conventions.
|
||||
raysampler_grid = NDCGridRaysampler(
|
||||
raysampler_grid = NDCMultinomialRaysampler(
|
||||
image_height=render_size,
|
||||
image_width=render_size,
|
||||
n_pts_per_ray=128,
|
||||
@@ -768,7 +769,7 @@ def generate_rotating_nerf(neural_radiance_field, n_frames = 50):
|
||||
fov=target_cameras.fov[0],
|
||||
device=device,
|
||||
)
|
||||
# Note that we again render with `NDCGridRaySampler`
|
||||
# Note that we again render with `NDCMultinomialRaysampler`
|
||||
# and the batched_forward function of neural_radiance_field.
|
||||
frames.append(
|
||||
renderer_grid(
|
||||
@@ -787,4 +788,4 @@ plt.show()
|
||||
|
||||
# ## 6. Conclusion
|
||||
#
|
||||
# In this tutorial, we have shown how to optimize an implicit representation of a scene such that the renders of the scene from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's implicit function renderer composed of either a `MonteCarloRaysampler` or `NDCGridRaysampler`, and an `EmissionAbsorptionRaymarcher`.
|
||||
# In this tutorial, we have shown how to optimize an implicit representation of a scene such that the renders of the scene from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's implicit function renderer composed of either a `MonteCarloRaysampler` or `NDCMultinomialRaysampler`, and an `EmissionAbsorptionRaymarcher`.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -76,7 +76,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Fit a mesh via rendering
|
||||
@@ -39,7 +39,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -55,7 +55,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
@@ -88,7 +89,7 @@
|
||||
"from pytorch3d.renderer import (\n",
|
||||
" FoVPerspectiveCameras, \n",
|
||||
" VolumeRenderer,\n",
|
||||
" NDCGridRaysampler,\n",
|
||||
" NDCMultinomialRaysampler,\n",
|
||||
" EmissionAbsorptionRaymarcher\n",
|
||||
")\n",
|
||||
"from pytorch3d.transforms import so3_exp_map\n",
|
||||
@@ -163,7 +164,7 @@
|
||||
"The following initializes a volumetric renderer that emits a ray from each pixel of a target image and samples a set of uniformly-spaced points along the ray. At each ray-point, the corresponding density and color value is obtained by querying the corresponding location in the volumetric model of the scene (the model is described & instantiated in a later cell).\n",
|
||||
"\n",
|
||||
"The renderer is composed of a *raymarcher* and a *raysampler*.\n",
|
||||
"- The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use the `NDCGridRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user).\n",
|
||||
"- The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use the `NDCMultinomialRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user).\n",
|
||||
"- The *raymarcher* takes the densities and colors sampled along each ray and renders each ray into a color and an opacity value of the ray's source pixel. Here we use the `EmissionAbsorptionRaymarcher` which implements the standard Emission-Absorption raymarching algorithm."
|
||||
]
|
||||
},
|
||||
@@ -185,14 +186,14 @@
|
||||
"volume_extent_world = 3.0\n",
|
||||
"\n",
|
||||
"# 1) Instantiate the raysampler.\n",
|
||||
"# Here, NDCGridRaysampler generates a rectangular image\n",
|
||||
"# Here, NDCMultinomialRaysampler generates a rectangular image\n",
|
||||
"# grid of rays whose coordinates follow the PyTorch3D\n",
|
||||
"# coordinate conventions.\n",
|
||||
"# Since we use a volume of size 128^3, we sample n_pts_per_ray=150,\n",
|
||||
"# which roughly corresponds to a one ray-point per voxel.\n",
|
||||
"# We further set the min_depth=0.1 since there is no surface within\n",
|
||||
"# 0.1 units of any camera plane.\n",
|
||||
"raysampler = NDCGridRaysampler(\n",
|
||||
"raysampler = NDCMultinomialRaysampler(\n",
|
||||
" image_width=render_size,\n",
|
||||
" image_height=render_size,\n",
|
||||
" n_pts_per_ray=150,\n",
|
||||
@@ -461,7 +462,7 @@
|
||||
"source": [
|
||||
"## 6. Conclusion\n",
|
||||
"\n",
|
||||
"In this tutorial, we have shown how to optimize a 3D volumetric representation of a scene such that the renders of the volume from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's volumetric renderer composed of an `NDCGridRaysampler` and an `EmissionAbsorptionRaymarcher`."
|
||||
"In this tutorial, we have shown how to optimize a 3D volumetric representation of a scene such that the renders of the volume from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's volumetric renderer composed of an `NDCMultinomialRaysampler` and an `EmissionAbsorptionRaymarcher`."
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Fit a volume via raymarching
|
||||
@@ -40,7 +40,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
@@ -70,7 +71,7 @@ from pytorch3d.structures import Volumes
|
||||
from pytorch3d.renderer import (
|
||||
FoVPerspectiveCameras,
|
||||
VolumeRenderer,
|
||||
NDCGridRaysampler,
|
||||
NDCMultinomialRaysampler,
|
||||
EmissionAbsorptionRaymarcher
|
||||
)
|
||||
from pytorch3d.transforms import so3_exp_map
|
||||
@@ -122,7 +123,7 @@ print(f'Generated {len(target_images)} images/silhouettes/cameras.')
|
||||
# The following initializes a volumetric renderer that emits a ray from each pixel of a target image and samples a set of uniformly-spaced points along the ray. At each ray-point, the corresponding density and color value is obtained by querying the corresponding location in the volumetric model of the scene (the model is described & instantiated in a later cell).
|
||||
#
|
||||
# The renderer is composed of a *raymarcher* and a *raysampler*.
|
||||
# - The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use the `NDCGridRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user).
|
||||
# - The *raysampler* is responsible for emitting rays from image pixels and sampling the points along them. Here, we use the `NDCMultinomialRaysampler` which follows the standard PyTorch3D coordinate grid convention (+X from right to left; +Y from bottom to top; +Z away from the user).
|
||||
# - The *raymarcher* takes the densities and colors sampled along each ray and renders each ray into a color and an opacity value of the ray's source pixel. Here we use the `EmissionAbsorptionRaymarcher` which implements the standard Emission-Absorption raymarching algorithm.
|
||||
|
||||
# In[ ]:
|
||||
@@ -140,14 +141,14 @@ render_size = target_images.shape[1]
|
||||
volume_extent_world = 3.0
|
||||
|
||||
# 1) Instantiate the raysampler.
|
||||
# Here, NDCGridRaysampler generates a rectangular image
|
||||
# Here, NDCMultinomialRaysampler generates a rectangular image
|
||||
# grid of rays whose coordinates follow the PyTorch3D
|
||||
# coordinate conventions.
|
||||
# Since we use a volume of size 128^3, we sample n_pts_per_ray=150,
|
||||
# which roughly corresponds to a one ray-point per voxel.
|
||||
# We further set the min_depth=0.1 since there is no surface within
|
||||
# 0.1 units of any camera plane.
|
||||
raysampler = NDCGridRaysampler(
|
||||
raysampler = NDCMultinomialRaysampler(
|
||||
image_width=render_size,
|
||||
image_height=render_size,
|
||||
n_pts_per_ray=150,
|
||||
@@ -388,4 +389,4 @@ plt.show()
|
||||
|
||||
# ## 6. Conclusion
|
||||
#
|
||||
# In this tutorial, we have shown how to optimize a 3D volumetric representation of a scene such that the renders of the volume from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's volumetric renderer composed of an `NDCGridRaysampler` and an `EmissionAbsorptionRaymarcher`.
|
||||
# In this tutorial, we have shown how to optimize a 3D volumetric representation of a scene such that the renders of the volume from known viewpoints match the observed images for each viewpoint. The rendering was carried out using the PyTorch3D's volumetric renderer composed of an `NDCMultinomialRaysampler` and an `EmissionAbsorptionRaymarcher`.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -58,7 +58,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Render a colored point cloud
|
||||
@@ -38,7 +38,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -65,7 +65,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Render DensePose
|
||||
@@ -42,7 +42,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved."
|
||||
"# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -81,7 +81,8 @@
|
||||
" torch.version.cuda.replace(\".\",\"\"),\n",
|
||||
" f\"_pyt{pyt_version_str}\"\n",
|
||||
" ])\n",
|
||||
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" !pip install fvcore iopath\n",
|
||||
" !pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
|
||||
" else:\n",
|
||||
" # We try to install PyTorch3D from source.\n",
|
||||
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# In[ ]:
|
||||
|
||||
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
|
||||
|
||||
|
||||
# # Render a textured mesh
|
||||
@@ -40,7 +40,8 @@ if need_pytorch3d:
|
||||
torch.version.cuda.replace(".",""),
|
||||
f"_pyt{pyt_version_str}"
|
||||
])
|
||||
get_ipython().system('pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
get_ipython().system('pip install fvcore iopath')
|
||||
get_ipython().system('pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html')
|
||||
else:
|
||||
# We try to install PyTorch3D from source.
|
||||
get_ipython().system('curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz')
|
||||
|
||||
Reference in New Issue
Block a user