From 124bb5e391c0afe1d47bb214ff884bdb0f93b945 Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Fri, 9 Apr 2021 09:57:55 -0700 Subject: [PATCH] spelling Summary: Collection of spelling things, mostly in docs / tutorials. Reviewed By: gkioxari Differential Revision: D26101323 fbshipit-source-id: 652f62bc9d71a4ff872efa21141225e43191353a --- INSTALL.md | 2 +- docs/notes/batching.md | 4 +-- docs/notes/cameras.md | 2 +- docs/notes/io.md | 2 +- docs/notes/meshes_io.md | 6 ++-- docs/notes/renderer_getting_started.md | 4 +-- docs/tutorials/bundle_adjustment.ipynb | 2 +- ...zation_with_differentiable_rendering.ipynb | 14 ++++---- .../dataloaders_ShapeNetCore_R2N2.ipynb | 10 +++--- .../fit_simple_neural_radiance_field.ipynb | 30 ++++++++-------- docs/tutorials/fit_textured_mesh.ipynb | 14 ++++---- docs/tutorials/fit_textured_volume.ipynb | 10 +++--- docs/tutorials/render_colored_points.ipynb | 2 +- docs/tutorials/render_densepose.ipynb | 4 +-- docs/tutorials/render_textured_meshes.ipynb | 12 +++---- docs/tutorials/utils/generate_cow_renders.py | 6 ++-- projects/nerf/README.md | 2 +- projects/nerf/nerf/eval_video_utils.py | 4 +-- projects/nerf/nerf/harmonic_embedding.py | 2 +- projects/nerf/nerf/implicit_function.py | 2 +- projects/nerf/nerf/nerf_renderer.py | 2 +- projects/nerf/nerf/raymarcher.py | 4 +-- projects/nerf/test_nerf.py | 4 +-- projects/nerf/tests/test_raysampler.py | 2 +- projects/nerf/train_nerf.py | 8 ++--- .../csrc/rasterize_meshes/rasterize_meshes.cu | 4 +-- .../csrc/rasterize_points/rasterize_points.cu | 4 +-- pytorch3d/csrc/utils/geometry_utils.cuh | 2 +- pytorch3d/csrc/utils/geometry_utils.h | 2 +- pytorch3d/datasets/r2n2/r2n2.py | 4 +-- pytorch3d/datasets/r2n2/utils.py | 10 +++--- pytorch3d/datasets/shapenet/shapenet_core.py | 4 +-- pytorch3d/datasets/shapenet_base.py | 2 +- pytorch3d/io/mtl_io.py | 6 ++-- pytorch3d/io/obj_io.py | 6 ++-- pytorch3d/io/pluggable.py | 6 ++-- pytorch3d/io/ply_io.py | 10 +++--- pytorch3d/loss/mesh_laplacian_smoothing.py | 2 +- pytorch3d/loss/point_mesh_distance.py | 2 +- pytorch3d/ops/interp_face_attrs.py | 2 +- pytorch3d/ops/knn.py | 2 +- pytorch3d/ops/perspective_n_points.py | 2 +- pytorch3d/ops/points_normals.py | 4 +-- pytorch3d/ops/points_to_volumes.py | 4 +-- pytorch3d/ops/sample_points_from_meshes.py | 11 +++--- pytorch3d/ops/utils.py | 2 +- pytorch3d/ops/vert_align.py | 4 +-- pytorch3d/renderer/cameras.py | 34 +++++++++---------- pytorch3d/renderer/implicit/raymarching.py | 4 +-- pytorch3d/renderer/implicit/raysampling.py | 4 +-- pytorch3d/renderer/implicit/renderer.py | 14 ++++---- pytorch3d/renderer/lighting.py | 4 +-- pytorch3d/renderer/mesh/rasterize_meshes.py | 10 +++--- pytorch3d/renderer/mesh/rasterizer.py | 2 +- pytorch3d/renderer/mesh/textures.py | 20 +++++------ pytorch3d/renderer/mesh/utils.py | 4 +-- pytorch3d/renderer/points/rasterize_points.py | 8 ++--- pytorch3d/renderer/utils.py | 2 +- pytorch3d/structures/meshes.py | 12 +++---- pytorch3d/structures/pointclouds.py | 16 ++++----- pytorch3d/structures/volumes.py | 2 +- pytorch3d/transforms/rotation_conversions.py | 2 +- pytorch3d/transforms/transform3d.py | 8 ++--- pytorch3d/vis/plotly_vis.py | 4 +-- tests/test_io_obj.py | 6 ++-- tests/test_io_ply.py | 4 +-- tests/test_points_alignment.py | 2 +- tests/test_points_to_volumes.py | 4 +-- tests/test_rasterize_points.py | 2 +- tests/test_rasterize_rectangle_images.py | 4 +-- tests/test_raymarching.py | 2 +- tests/test_render_meshes.py | 2 +- tests/test_render_volumes.py | 6 ++-- tests/test_so3.py | 4 +-- website/pages/tutorials/index.js | 2 +- 75 files changed, 220 insertions(+), 217 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 6cc1c7f3..d0cf3794 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ ### Core library -The core library is written in PyTorch. Several components have underlying implementation in CUDA for improved performance. A subset of these components have CPU implementations in C++/Pytorch. It is advised to use PyTorch3D with GPU support in order to use all the features. +The core library is written in PyTorch. Several components have underlying implementation in CUDA for improved performance. A subset of these components have CPU implementations in C++/PyTorch. It is advised to use PyTorch3D with GPU support in order to use all the features. - Linux or macOS or Windows - Python 3.6, 3.7 or 3.8 diff --git a/docs/notes/batching.md b/docs/notes/batching.md index f42cee65..1c7ca56b 100644 --- a/docs/notes/batching.md +++ b/docs/notes/batching.md @@ -5,7 +5,7 @@ sidebar_label: Batching # Batching -In deep learning, every optimization step operates on multiple input examples for robust training. Thus, efficient batching is crucial. For image inputs, batching is straighforward; N images are resized to the same height and width and stacked as a 4 dimensional tensor of shape `N x 3 x H x W`. For meshes, batching is less straighforward. +In deep learning, every optimization step operates on multiple input examples for robust training. Thus, efficient batching is crucial. For image inputs, batching is straightforward; N images are resized to the same height and width and stacked as a 4 dimensional tensor of shape `N x 3 x H x W`. For meshes, batching is less straightforward. batch_intro @@ -21,7 +21,7 @@ Assume you want to construct a batch containing two meshes, with `mesh1 = (v1: V ## Use cases for batch modes -The need for different mesh batch modes is inherent to the way pytorch operators are implemented. To fully utilize the optimized pytorch ops, the [Meshes][meshes] data structure allows for efficient conversion between the different batch modes. This is crucial when aiming for a fast and efficient training cycle. An example of this is [Mesh R-CNN][meshrcnn]. Here, in the same forward pass different parts of the network assume different inputs, which are computed by converting between the different batch modes. In particular, [vert_align][vert_align] assumes a *padded* input tensor while immediately after [graph_conv][graphconv] assumes a *packed* input tensor. +The need for different mesh batch modes is inherent to the way PyTorch operators are implemented. To fully utilize the optimized PyTorch ops, the [Meshes][meshes] data structure allows for efficient conversion between the different batch modes. This is crucial when aiming for a fast and efficient training cycle. An example of this is [Mesh R-CNN][meshrcnn]. Here, in the same forward pass different parts of the network assume different inputs, which are computed by converting between the different batch modes. In particular, [vert_align][vert_align] assumes a *padded* input tensor while immediately after [graph_conv][graphconv] assumes a *packed* input tensor. meshrcnn diff --git a/docs/notes/cameras.md b/docs/notes/cameras.md index fec21f7c..1261c1ea 100644 --- a/docs/notes/cameras.md +++ b/docs/notes/cameras.md @@ -13,7 +13,7 @@ This is the system the object/scene lives - the world. * **Camera view coordinate system** This is the system that has its origin on the image plane and the `Z`-axis perpendicular to the image plane. In PyTorch3D, we assume that `+X` points left, and `+Y` points up and `+Z` points out from the image plane. The transformation from world to view happens after applying a rotation (`R`) and translation (`T`). * **NDC coordinate system** -This is the normalized coordinate system that confines in a volume the renderered part of the object/scene. Also known as view volume. Under the PyTorch3D convention, `(+1, +1, znear)` is the top left near corner, and `(-1, -1, zfar)` is the bottom right far corner of the volume. The transformation from view to NDC happens after applying the camera projection matrix (`P`). +This is the normalized coordinate system that confines in a volume the rendered part of the object/scene. Also known as view volume. Under the PyTorch3D convention, `(+1, +1, znear)` is the top left near corner, and `(-1, -1, zfar)` is the bottom right far corner of the volume. The transformation from view to NDC happens after applying the camera projection matrix (`P`). * **Screen coordinate system** This is another representation of the view volume with the `XY` coordinates defined in pixel space instead of a normalized space. diff --git a/docs/notes/io.md b/docs/notes/io.md index a6c17793..201e8178 100644 --- a/docs/notes/io.md +++ b/docs/notes/io.md @@ -20,5 +20,5 @@ mesh = IO().load_mesh("mymesh.ply", device=device) and to save a pointcloud you might do ``` pcl = Pointclouds(...) -IO().save_point_cloud(pcl, "output_poincloud.obj") +IO().save_point_cloud(pcl, "output_pointcloud.obj") ``` diff --git a/docs/notes/meshes_io.md b/docs/notes/meshes_io.md index e6d02209..330c2abf 100644 --- a/docs/notes/meshes_io.md +++ b/docs/notes/meshes_io.md @@ -6,13 +6,13 @@ hide_title: true # Meshes and IO The Meshes object represents a batch of triangulated meshes, and is central to -much of the functionality of pytorch3d. There is no insistence that each mesh in +much of the functionality of PyTorch3D. There is no insistence that each mesh in the batch has the same number of vertices or faces. When available, it can store other data which pertains to the mesh, for example face normals, face areas and textures. Two common file formats for storing single meshes are ".obj" and ".ply" files, -and pytorch3d has functions for reading these. +and PyTorch3D has functions for reading these. ## OBJ @@ -60,7 +60,7 @@ The `load_objs_as_meshes` function provides this procedure. ## PLY -Ply files are flexible in the way they store additional information, pytorch3d +Ply files are flexible in the way they store additional information. PyTorch3D provides a function just to read the vertices and faces from a ply file. The call ``` diff --git a/docs/notes/renderer_getting_started.md b/docs/notes/renderer_getting_started.md index ae0b9527..6da9eb8f 100644 --- a/docs/notes/renderer_getting_started.md +++ b/docs/notes/renderer_getting_started.md @@ -84,7 +84,7 @@ For mesh texturing we offer several options (in `pytorch3d/renderer/mesh/texturi 1. **Vertex Textures**: D dimensional textures for each vertex (for example an RGB color) which can be interpolated across the face. This can be represented as an `(N, V, D)` tensor. This is a fairly simple representation though and cannot model complex textures if the mesh faces are large. 2. **UV Textures**: vertex UV coordinates and **one** texture map for the whole mesh. For a point on a face with given barycentric coordinates, the face color can be computed by interpolating the vertex uv coordinates and then sampling from the texture map. This representation requires two tensors (UVs: `(N, V, 2), Texture map: `(N, H, W, 3)`), and is limited to only support one texture map per mesh. -3. **Face Textures**: In more complex cases such as ShapeNet meshes, there are multiple texture maps per mesh and some faces have texture while other do not. For these cases, a more flexible representation is a texture atlas, where each face is represented as an `(RxR)` texture map where R is the texture resolution. For a given point on the face, the texture value can be sampled from the per face texture map using the barycentric coordinates of the point. This representation requires one tensor of shape `(N, F, R, R, 3)`. This texturing method is inspired by the SoftRasterizer implementation. For more details refer to the [`make_material_atlas`](https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/io/mtl_io.py#L123) and [`sample_textures`](https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/textures.py#L452) functions. **NOTE:**: The `TextureAtlas` texture sampling is only differentiable with respect to the texture atlas but not differentiable with respect to the barycentric coordinates. +3. **Face Textures**: In more complex cases such as ShapeNet meshes, there are multiple texture maps per mesh and some faces have texture while other do not. For these cases, a more flexible representation is a texture atlas, where each face is represented as an `(RxR)` texture map where R is the texture resolution. For a given point on the face, the texture value can be sampled from the per face texture map using the barycentric coordinates of the point. This representation requires one tensor of shape `(N, F, R, R, 3)`. This texturing method is inspired by the SoftRasterizer implementation. For more details refer to the [`make_material_atlas`](https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/io/mtl_io.py#L123) and [`sample_textures`](https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/renderer/mesh/textures.py#L452) functions. **NOTE:**: The `TexturesAtlas` texture sampling is only differentiable with respect to the texture atlas but not differentiable with respect to the barycentric coordinates. @@ -116,7 +116,7 @@ raster_settings = RasterizationSettings( faces_per_pixel=1, ) -# Create a phong renderer by composing a rasterizer and a shader. Here we can use a predefined +# Create a Phong renderer by composing a rasterizer and a shader. Here we can use a predefined # PhongShader, passing in the device on which to initialize the default parameters renderer = MeshRenderer( rasterizer=MeshRasterizer(cameras=cameras, raster_settings=raster_settings), diff --git a/docs/tutorials/bundle_adjustment.ipynb b/docs/tutorials/bundle_adjustment.ipynb index b17e4ac0..bb2cb44a 100644 --- a/docs/tutorials/bundle_adjustment.ipynb +++ b/docs/tutorials/bundle_adjustment.ipynb @@ -387,7 +387,7 @@ " device = device,\n", " )\n", "\n", - " # compute the relative cameras as a compositon of the absolute cameras\n", + " # compute the relative cameras as a composition of the absolute cameras\n", " cameras_relative_composed = \\\n", " get_relative_camera(cameras_absolute, relative_edges)\n", "\n", diff --git a/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb b/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb index c905fd64..6967795f 100644 --- a/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb +++ b/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb @@ -223,9 +223,9 @@ "source": [ "### Create a renderer\n", "\n", - "A **renderer** in PyTorch3D is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthgraphic/perspective). Here we initialize some of these components and use default values for the rest. \n", + "A **renderer** in PyTorch3D is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthographic/perspective). Here we initialize some of these components and use default values for the rest. \n", "\n", - "For optimizing the camera position we will use a renderer which produces a **silhouette** of the object only and does not apply any **lighting** or **shading**. We will also initialize another renderer which applies full **phong shading** and use this for visualizing the outputs. " + "For optimizing the camera position we will use a renderer which produces a **silhouette** of the object only and does not apply any **lighting** or **shading**. We will also initialize another renderer which applies full **Phong shading** and use this for visualizing the outputs. " ] }, { @@ -266,7 +266,7 @@ ")\n", "\n", "\n", - "# We will also create a phong renderer. This is simpler and only needs to render one face per pixel.\n", + "# We will also create a Phong renderer. This is simpler and only needs to render one face per pixel.\n", "raster_settings = RasterizationSettings(\n", " image_size=256, \n", " blur_radius=0.0, \n", @@ -322,15 +322,15 @@ "R, T = look_at_view_transform(distance, elevation, azimuth, device=device)\n", "\n", "# Render the teapot providing the values of R and T. \n", - "silhouete = silhouette_renderer(meshes_world=teapot_mesh, R=R, T=T)\n", + "silhouette = silhouette_renderer(meshes_world=teapot_mesh, R=R, T=T)\n", "image_ref = phong_renderer(meshes_world=teapot_mesh, R=R, T=T)\n", "\n", - "silhouete = silhouete.cpu().numpy()\n", + "silhouette = silhouette.cpu().numpy()\n", "image_ref = image_ref.cpu().numpy()\n", "\n", "plt.figure(figsize=(10, 10))\n", "plt.subplot(1, 2, 1)\n", - "plt.imshow(silhouete.squeeze()[..., 3]) # only plot the alpha channel of the RGBA image\n", + "plt.imshow(silhouette.squeeze()[..., 3]) # only plot the alpha channel of the RGBA image\n", "plt.grid(False)\n", "plt.subplot(1, 2, 2)\n", "plt.imshow(image_ref.squeeze())\n", @@ -377,7 +377,7 @@ " def forward(self):\n", " \n", " # Render the image using the updated camera position. Based on the new position of the \n", - " # camer we calculate the rotation and translation matrices\n", + " # camera we calculate the rotation and translation matrices\n", " R = look_at_rotation(self.camera_position[None, :], device=self.device) # (1, 3, 3)\n", " T = -torch.bmm(R.transpose(1, 2), self.camera_position[None, :, None])[:, :, 0] # (1, 3)\n", " \n", diff --git a/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb b/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb index 1b561a45..060ef865 100644 --- a/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb +++ b/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb @@ -190,7 +190,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can retrieve a model by indexing into the loaded dataset. For both ShapeNetCore and R2N2, we can examine the category this model belongs to (in the form of a synset id, equivalend to wnid described in ImageNet's API: http://image-net.org/download-API), its model id, and its vertices and faces." + "We can retrieve a model by indexing into the loaded dataset. For both ShapeNetCore and R2N2, we can examine the category this model belongs to (in the form of a synset id, equivalent to wnid described in ImageNet's API: http://image-net.org/download-API), its model id, and its vertices and faces." ] }, { @@ -254,11 +254,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Training deep learning models, usually requires passing in batches of inputs. The `torch.utils.data.DataLoader` from Pytorch helps us do this. PyTorch3D provides a function `collate_batched_meshes` to group the input meshes into a single `Meshes` object which represents the batch. The `Meshes` datastructure can then be used directly by other PyTorch3D ops which might be part of the deep learning model (e.g. `graph_conv`).\n", + "Training deep learning models, usually requires passing in batches of inputs. The `torch.utils.data.DataLoader` from PyTorch helps us do this. PyTorch3D provides a function `collate_batched_meshes` to group the input meshes into a single `Meshes` object which represents the batch. The `Meshes` datastructure can then be used directly by other PyTorch3D ops which might be part of the deep learning model (e.g. `graph_conv`).\n", "\n", "For R2N2, if all the models in the batch have the same number of views, the views, rotation matrices, translation matrices, intrinsic matrices and voxels will also be stacked into batched tensors.\n", "\n", - "**NOTE**: All models in the `val` split of R2N2 have 24 views, but there are 8 models that split their 24 views between `train` and `test` splits, in which case `collate_batched_meshes` will only be able to join the matrices, views and voxels as lists. However, this can be avoided by laoding only one view of each model by setting `return_all_views = False`." + "**NOTE**: All models in the `val` split of R2N2 have 24 views, but there are 8 models that split their 24 views between `train` and `test` splits, in which case `collate_batched_meshes` will only be able to join the matrices, views and voxels as lists. However, this can be avoided by loading only one view of each model by setting `return_all_views = False`." ] }, { @@ -295,7 +295,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 3. Render ShapeNetCore models with PyTorch3D's differntiable renderer" + "## 3. Render ShapeNetCore models with PyTorch3D's differentiable renderer" ] }, { @@ -450,7 +450,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we will visualize PyTorch3d's renderings:" + "Next, we will visualize PyTorch3D's renderings:" ] }, { diff --git a/docs/tutorials/fit_simple_neural_radiance_field.ipynb b/docs/tutorials/fit_simple_neural_radiance_field.ipynb index 55de597e..33bfa2da 100644 --- a/docs/tutorials/fit_simple_neural_radiance_field.ipynb +++ b/docs/tutorials/fit_simple_neural_radiance_field.ipynb @@ -17,7 +17,7 @@ "\n", "This tutorial shows how to fit Neural Radiance Field given a set of views of a scene using differentiable implicit function rendering.\n", "\n", - "More specificially, this tutorial will explain how to:\n", + "More specifically, this tutorial will explain how to:\n", "1. Create a differentiable implicit function renderer with either image-grid or Monte Carlo ray sampling.\n", "2. Create an Implicit model of a scene.\n", "3. Fit the implicit function (Neural Radiance Field) based on input images using the differentiable implicit renderer. \n", @@ -158,9 +158,9 @@ "The following initializes an implicit 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 neural 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 emiting rays from image pixels and sampling the points along them. Here, we use two different raysamplers:\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", + " - `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", "- 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." ] }, @@ -186,7 +186,7 @@ "# 1) Instantiate the raysamplers.\n", "\n", "# Here, NDCGridRaysampler generates a rectangular image\n", - "# grid of rays whose coordinates follow the PyTorch3d\n", + "# grid of rays whose coordinates follow the PyTorch3D\n", "# coordinate conventions.\n", "raysampler_grid = NDCGridRaysampler(\n", " image_height=render_size,\n", @@ -236,7 +236,7 @@ "\n", "The `forward` function of `NeuralRadianceField` (NeRF) receives as input a set of tensors that parametrize a bundle of rendering rays. The ray bundle is later converted to 3D ray points in the world coordinates of the scene. Each 3D point is then mapped to a harmonic representation using the `HarmonicEmbedding` layer (defined in the next cell). The harmonic embeddings then enter the _color_ and _opacity_ branches of the NeRF model in order to label each ray point with a 3D vector and a 1D scalar ranging in [0-1] which define the point's RGB color and opacity respectively.\n", "\n", - "Since NeRF has a large memory footprint, we also implement the `NeuralRadianceField.forward_batched` method. The method splits the input rays into batches and executes the `forward` function for each batch separately in a for loop. This allows to render a large set of rays without running out of GPU memory. Standardly, `forward_batched` would be used to render rays emitted from all pixels of an image in order to produce a full-sized render of a scene.\n" + "Since NeRF has a large memory footprint, we also implement the `NeuralRadianceField.forward_batched` method. The method splits the input rays into batches and executes the `forward` function for each batch separately in a for loop. This lets us render a large set of rays without running out of GPU memory. Standardly, `forward_batched` would be used to render rays emitted from all pixels of an image in order to produce a full-sized render of a scene.\n" ] }, { @@ -266,7 +266,7 @@ " ]\n", " \n", " Note that `x` is also premultiplied by `omega0` before\n", - " evaluting the harmonic functions.\n", + " evaluating the harmonic functions.\n", " \"\"\"\n", " super().__init__()\n", " self.register_buffer(\n", @@ -417,7 +417,7 @@ "\n", " Returns:\n", " rays_densities: A tensor of shape `(minibatch, ..., num_points_per_ray, 1)`\n", - " denoting the opacitiy of each ray point.\n", + " denoting the opacity of each ray point.\n", " rays_colors: A tensor of shape `(minibatch, ..., num_points_per_ray, 3)`\n", " denoting the color of each ray point.\n", " \"\"\"\n", @@ -457,11 +457,11 @@ " This function is used to allow for memory efficient processing\n", " of input rays. The input rays are first split to `n_batches`\n", " chunks and passed through the `self.forward` function one at a time\n", - " in a for loop. Combined with disabling Pytorch gradient caching\n", + " in a for loop. Combined with disabling PyTorch gradient caching\n", " (`torch.no_grad()`), this allows for rendering large batches\n", " of rays that do not all fit into GPU memory in a single forward pass.\n", " In our case, batched_forward is used to export a fully-sized render\n", - " of the radiance field for visualisation purposes.\n", + " of the radiance field for visualization purposes.\n", " \n", " Args:\n", " ray_bundle: A RayBundle object containing the following variables:\n", @@ -477,7 +477,7 @@ "\n", " Returns:\n", " rays_densities: A tensor of shape `(minibatch, ..., num_points_per_ray, 1)`\n", - " denoting the opacitiy of each ray point.\n", + " denoting the opacity of each ray point.\n", " rays_colors: A tensor of shape `(minibatch, ..., num_points_per_ray, 3)`\n", " denoting the color of each ray point.\n", "\n", @@ -576,12 +576,12 @@ " intermediate results of the learning. \n", " \n", " Since the `NeuralRadianceField` suffers from\n", - " a large memory footprint, which does not allow to\n", + " a large memory footprint, which does not let us\n", " render the full image grid in a single forward pass,\n", " we utilize the `NeuralRadianceField.batched_forward`\n", " function in combination with disabling the gradient caching.\n", " This chunks the set of emitted rays to batches and \n", - " evaluates the implicit function on one-batch at a time\n", + " evaluates the implicit function on one batch at a time\n", " to prevent GPU memory overflow.\n", " \"\"\"\n", " \n", @@ -720,7 +720,7 @@ " rendered_images_silhouettes.split([3, 1], dim=-1)\n", " )\n", " \n", - " # Compute the silhoutte error as the mean huber\n", + " # Compute the silhouette error as the mean huber\n", " # loss between the predicted masks and the\n", " # sampled target silhouettes.\n", " silhouettes_at_rays = sample_images_at_mc_locs(\n", @@ -818,7 +818,7 @@ " fov=target_cameras.fov[0],\n", " device=device,\n", " )\n", - " # Note that we again render with `NDCGridSampler`\n", + " # Note that we again render with `NDCGridRaySampler`\n", " # and the batched_forward function of neural_radiance_field.\n", " frames.append(\n", " renderer_grid(\n", @@ -841,7 +841,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 `NDCGridRaysampler`, and an `EmissionAbsorptionRaymarcher`." ] } ], diff --git a/docs/tutorials/fit_textured_mesh.ipynb b/docs/tutorials/fit_textured_mesh.ipynb index 59e44e8f..83ad5c73 100644 --- a/docs/tutorials/fit_textured_mesh.ipynb +++ b/docs/tutorials/fit_textured_mesh.ipynb @@ -193,11 +193,11 @@ "source": [ "### 1. Load a mesh and texture file\n", "\n", - "Load an `.obj` file and it's associated `.mtl` file and create a **Textures** and **Meshes** object. \n", + "Load an `.obj` file and its associated `.mtl` file and create a **Textures** and **Meshes** object. \n", "\n", "**Meshes** is a unique datastructure provided in PyTorch3D for working with batches of meshes of different sizes. \n", "\n", - "**TexturesVertex** is an auxillary datastructure for storing vertex rgb texture information about meshes. \n", + "**TexturesVertex** is an auxiliary datastructure for storing vertex rgb texture information about meshes. \n", "\n", "**Meshes** has several class methods which are used throughout the rendering pipeline." ] @@ -315,7 +315,7 @@ "# purposes only we will set faces_per_pixel=1 and blur_radius=0.0. Refer to \n", "# rasterize_meshes.py for explanations of these parameters. We also leave \n", "# bin_size and max_faces_per_bin to their default values of None, which sets \n", - "# their values using huristics and ensures that the faster coarse-to-fine \n", + "# their values using heuristics and ensures that the faster coarse-to-fine \n", "# rasterization method is used. Refer to docs/notes/renderer.md for an \n", "# explanation of the difference between naive and coarse-to-fine rasterization. \n", "raster_settings = RasterizationSettings(\n", @@ -324,8 +324,8 @@ " faces_per_pixel=1, \n", ")\n", "\n", - "# Create a phong renderer by composing a rasterizer and a shader. The textured \n", - "# phong shader will interpolate the texture uv coordinates for each vertex, \n", + "# Create a Phong renderer by composing a rasterizer and a shader. The textured \n", + "# Phong shader will interpolate the texture uv coordinates for each vertex, \n", "# sample from a texture image and apply the Phong lighting model\n", "renderer = MeshRenderer(\n", " rasterizer=MeshRasterizer(\n", @@ -386,7 +386,7 @@ "id": "gOb4rYx65E8z" }, "source": [ - "Later in this tutorial, we will fit a mesh to the rendered RGB images, as well as to just images of just the cow silhouette. For the latter case, we will render a dataset of silhouette images. Most shaders in PyTorch3D will output an alpha channel along with the RGB image as a 4th channel in an RGBA image. The alpha channel encodes the probability that each pixel belongs to the foreground of the object. We contruct a soft silhouette shader to render this alpha channel." + "Later in this tutorial, we will fit a mesh to the rendered RGB images, as well as to just images of just the cow silhouette. For the latter case, we will render a dataset of silhouette images. Most shaders in PyTorch3D will output an alpha channel along with the RGB image as a 4th channel in an RGBA image. The alpha channel encodes the probability that each pixel belongs to the foreground of the object. We construct a soft silhouette shader to render this alpha channel." ] }, { @@ -607,7 +607,7 @@ "id": "QLc9zK8lEqFS" }, "source": [ - "We write an optimization loop to iteratively refine our predicted mesh from the sphere mesh into a mesh that matches the sillhouettes of the target images:" + "We write an optimization loop to iteratively refine our predicted mesh from the sphere mesh into a mesh that matches the silhouettes of the target images:" ] }, { diff --git a/docs/tutorials/fit_textured_volume.ipynb b/docs/tutorials/fit_textured_volume.ipynb index e7645efc..395c482c 100644 --- a/docs/tutorials/fit_textured_volume.ipynb +++ b/docs/tutorials/fit_textured_volume.ipynb @@ -17,7 +17,7 @@ "\n", "This tutorial shows how to fit a volume given a set of views of a scene using differentiable volumetric rendering.\n", "\n", - "More specificially, this tutorial will explain how to:\n", + "More specifically, this tutorial will explain how to:\n", "1. Create a differentiable volumetric renderer.\n", "2. Create a Volumetric model (including how to use the `Volumes` class).\n", "3. Fit the volume based on the images using the differentiable volumetric renderer. \n", @@ -138,7 +138,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 emiting 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 `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 *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." ] }, @@ -161,11 +161,11 @@ "\n", "# 1) Instantiate the raysampler.\n", "# Here, NDCGridRaysampler generates a rectangular image\n", - "# grid of rays whose coordinates follow the pytorch3d\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 futher set the min_depth=0.1 since there is no surface within\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", " image_width=render_size,\n", @@ -334,7 +334,7 @@ " batch_cameras\n", " ).split([3, 1], dim=-1)\n", " \n", - " # Compute the silhoutte error as the mean huber\n", + " # Compute the silhouette error as the mean huber\n", " # loss between the predicted masks and the\n", " # target silhouettes.\n", " sil_err = huber(\n", diff --git a/docs/tutorials/render_colored_points.ipynb b/docs/tutorials/render_colored_points.ipynb index 133f4ca5..8d4858b5 100644 --- a/docs/tutorials/render_colored_points.ipynb +++ b/docs/tutorials/render_colored_points.ipynb @@ -157,7 +157,7 @@ "source": [ "## Create a renderer\n", "\n", - "A renderer in PyTorch3D is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthgraphic/perspective). Here we initialize some of these components and use default values for the rest.\n", + "A renderer in PyTorch3D is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthographic/perspective). Here we initialize some of these components and use default values for the rest.\n", "\n", "In this example we will first create a **renderer** which uses an **orthographic camera**, and applies **alpha compositing**. Then we learn how to vary different components using the modular API. \n", "\n", diff --git a/docs/tutorials/render_densepose.ipynb b/docs/tutorials/render_densepose.ipynb index fe2fbf1b..47f442cd 100644 --- a/docs/tutorials/render_densepose.ipynb +++ b/docs/tutorials/render_densepose.ipynb @@ -277,7 +277,7 @@ "\n", "**Meshes** is a unique datastructure provided in PyTorch3D for working with batches of meshes of different sizes.\n", "\n", - "**TexturesUV** is an auxillary datastructure for storing vertex uv and texture maps for meshes." + "**TexturesUV** is an auxiliary datastructure for storing vertex uv and texture maps for meshes." ] }, { @@ -320,7 +320,7 @@ "# Place a point light in front of the person. \n", "lights = PointLights(device=device, location=[[0.0, 0.0, 2.0]])\n", "\n", - "# Create a phong renderer by composing a rasterizer and a shader. The textured phong shader will \n", + "# Create a Phong renderer by composing a rasterizer and a shader. The textured Phong shader will \n", "# interpolate the texture uv coordinates for each vertex, sample from a texture image and \n", "# apply the Phong lighting model\n", "renderer = MeshRenderer(\n", diff --git a/docs/tutorials/render_textured_meshes.ipynb b/docs/tutorials/render_textured_meshes.ipynb index 138ca369..e52afb44 100644 --- a/docs/tutorials/render_textured_meshes.ipynb +++ b/docs/tutorials/render_textured_meshes.ipynb @@ -191,11 +191,11 @@ "source": [ "### 1. Load a mesh and texture file\n", "\n", - "Load an `.obj` file and it's associated `.mtl` file and create a **Textures** and **Meshes** object. \n", + "Load an `.obj` file and its associated `.mtl` file and create a **Textures** and **Meshes** object. \n", "\n", "**Meshes** is a unique datastructure provided in PyTorch3D for working with batches of meshes of different sizes. \n", "\n", - "**TexturesUV** is an auxillary datastructure for storing vertex uv and texture maps for meshes. \n", + "**TexturesUV** is an auxiliary datastructure for storing vertex uv and texture maps for meshes. \n", "\n", "**Meshes** has several class methods which are used throughout the rendering pipeline." ] @@ -317,7 +317,7 @@ "\n", "A renderer in PyTorch3D is composed of a **rasterizer** and a **shader** which each have a number of subcomponents such as a **camera** (orthographic/perspective). Here we initialize some of these components and use default values for the rest.\n", "\n", - "In this example we will first create a **renderer** which uses a **perspective camera**, a **point light** and applies **phong shading**. Then we learn how to vary different components using the modular API. " + "In this example we will first create a **renderer** which uses a **perspective camera**, a **point light** and applies **Phong shading**. Then we learn how to vary different components using the modular API. " ] }, { @@ -352,7 +352,7 @@ "# -z direction. \n", "lights = PointLights(device=device, location=[[0.0, 0.0, -3.0]])\n", "\n", - "# Create a phong renderer by composing a rasterizer and a shader. The textured phong shader will \n", + "# Create a Phong renderer by composing a rasterizer and a shader. The textured Phong shader will \n", "# interpolate the texture uv coordinates for each vertex, sample from a texture image and \n", "# apply the Phong lighting model\n", "renderer = MeshRenderer(\n", @@ -418,7 +418,7 @@ "source": [ "## 4. Move the light behind the object and re-render\n", "\n", - "We can pass arbirary keyword arguments to the `rasterizer`/`shader` via the call to the `renderer` so the renderer does not need to be reinitialized if any of the settings change/\n", + "We can pass arbitrary keyword arguments to the `rasterizer`/`shader` via the call to the `renderer` so the renderer does not need to be reinitialized if any of the settings change/\n", "\n", "In this case, we can simply update the location of the lights and pass them into the call to the renderer. \n", "\n", @@ -579,7 +579,7 @@ }, "outputs": [], "source": [ - "# We can pass arbirary keyword arguments to the rasterizer/shader via the renderer\n", + "# We can pass arbitrary keyword arguments to the rasterizer/shader via the renderer\n", "# so the renderer does not need to be reinitialized if any of the settings change.\n", "images = renderer(meshes, cameras=cameras, lights=lights)" ] diff --git a/docs/tutorials/utils/generate_cow_renders.py b/docs/tutorials/utils/generate_cow_renders.py index b39deb87..2a05c7d9 100644 --- a/docs/tutorials/utils/generate_cow_renders.py +++ b/docs/tutorials/utils/generate_cow_renders.py @@ -113,15 +113,15 @@ def generate_cow_renders( # purposes only we will set faces_per_pixel=1 and blur_radius=0.0. Refer to # rasterize_meshes.py for explanations of these parameters. We also leave # bin_size and max_faces_per_bin to their default values of None, which sets - # their values using huristics and ensures that the faster coarse-to-fine + # their values using heuristics and ensures that the faster coarse-to-fine # rasterization method is used. Refer to docs/notes/renderer.md for an # explanation of the difference between naive and coarse-to-fine rasterization. raster_settings = RasterizationSettings( image_size=128, blur_radius=0.0, faces_per_pixel=1 ) - # Create a phong renderer by composing a rasterizer and a shader. The textured - # phong shader will interpolate the texture uv coordinates for each vertex, + # Create a Phong renderer by composing a rasterizer and a shader. The textured + # Phong shader will interpolate the texture uv coordinates for each vertex, # sample from a texture image and apply the Phong lighting model blend_params = BlendParams(sigma=1e-4, gamma=1e-4, background_color=(0.0, 0.0, 0.0)) renderer = MeshRenderer( diff --git a/projects/nerf/README.md b/projects/nerf/README.md index 4cd1e3a9..18c25ba3 100644 --- a/projects/nerf/README.md +++ b/projects/nerf/README.md @@ -50,7 +50,7 @@ python ./test_nerf.py --config-name lego ``` Will load a trained model from the `./checkpoints` directory and evaluate it on the test split of the corresponding dataset (Lego in the case above). -### Exporting multi-view video of the radience field +### Exporting multi-view video of the radiance field Furthermore, the codebase supports generating videos of the neural radiance field. The following generates a turntable video of the Lego scene: ``` diff --git a/projects/nerf/nerf/eval_video_utils.py b/projects/nerf/nerf/eval_video_utils.py index 2fdc9a21..c31e31f9 100644 --- a/projects/nerf/nerf/eval_video_utils.py +++ b/projects/nerf/nerf/eval_video_utils.py @@ -77,7 +77,7 @@ def generate_eval_video_cameras( cam_centers_c = cam_centers - plane_mean[None] if up is not None: - # us the up vector instad of the plane through the camera centers + # us the up vector instead of the plane through the camera centers plane_normal = torch.FloatTensor(up) else: cov = (cam_centers_c.t() @ cam_centers_c) / cam_centers_c.shape[0] @@ -99,7 +99,7 @@ def generate_eval_video_cameras( traj = traj @ e_vec.t() + plane_mean[None] else: - raise ValueError(f"Uknown trajectory_type {trajectory_type}.") + raise ValueError(f"Unknown trajectory_type {trajectory_type}.") # point all cameras towards the center of the scene R, T = look_at_view_transform( diff --git a/projects/nerf/nerf/harmonic_embedding.py b/projects/nerf/nerf/harmonic_embedding.py index 9c512e9a..02db628d 100644 --- a/projects/nerf/nerf/harmonic_embedding.py +++ b/projects/nerf/nerf/harmonic_embedding.py @@ -42,7 +42,7 @@ class HarmonicEmbedding(torch.nn.Module): )` Note that `x` is also premultiplied by the base frequency `omega0` - before evaluting the harmonic functions. + before evaluating the harmonic functions. """ super().__init__() diff --git a/projects/nerf/nerf/implicit_function.py b/projects/nerf/nerf/implicit_function.py index 24ec955b..ed4c5e23 100644 --- a/projects/nerf/nerf/implicit_function.py +++ b/projects/nerf/nerf/implicit_function.py @@ -169,7 +169,7 @@ class NeuralRadianceField(torch.nn.Module): Returns: rays_densities: A tensor of shape `(minibatch, ..., num_points_per_ray, 1)` - denoting the opacitiy of each ray point. + denoting the opacity of each ray point. rays_colors: A tensor of shape `(minibatch, ..., num_points_per_ray, 3)` denoting the color of each ray point. """ diff --git a/projects/nerf/nerf/nerf_renderer.py b/projects/nerf/nerf/nerf_renderer.py index dbfc3840..c84afc26 100644 --- a/projects/nerf/nerf/nerf_renderer.py +++ b/projects/nerf/nerf/nerf_renderer.py @@ -266,7 +266,7 @@ class RadianceFieldRenderer(torch.nn.Module): image: torch.Tensor, ) -> Tuple[dict, dict]: """ - Performs the coarse and fine rendering passees of the radiance field + Performs the coarse and fine rendering passes of the radiance field from the viewpoint of the input `camera`. Afterwards, both renders are compared to the input ground truth `image` by evaluating the peak signal-to-noise ratio and the mean-squared error. diff --git a/projects/nerf/nerf/raymarcher.py b/projects/nerf/nerf/raymarcher.py index 3be73d32..36c3da98 100644 --- a/projects/nerf/nerf/raymarcher.py +++ b/projects/nerf/nerf/raymarcher.py @@ -36,7 +36,7 @@ class EmissionAbsorptionNeRFRaymarcher(EmissionAbsorptionRaymarcher): rays_features: Per-ray feature values represented with a tensor of shape `(..., n_points_per_ray, feature_dim)`. eps: A lower bound added to `rays_densities` before computing - the absorbtion function (cumprod of `1-rays_densities` along + the absorption function (cumprod of `1-rays_densities` along each ray). This prevents the cumprod to yield exact 0 which would inhibit any gradient-based learning. @@ -44,7 +44,7 @@ class EmissionAbsorptionNeRFRaymarcher(EmissionAbsorptionRaymarcher): features: A tensor of shape `(..., feature_dim)` containing the rendered features for each ray. weights: A tensor of shape `(..., n_points_per_ray)` containing - the ray-specific emission-absorbtion distribution. + the ray-specific emission-absorption distribution. Each ray distribution `(..., :)` is a valid probability distribution, i.e. it contains non-negative values that integrate to 1, such that `weights.sum(dim=-1)==1).all()` yields `True`. diff --git a/projects/nerf/test_nerf.py b/projects/nerf/test_nerf.py index 70296947..64682ec2 100644 --- a/projects/nerf/test_nerf.py +++ b/projects/nerf/test_nerf.py @@ -60,7 +60,7 @@ def main(cfg: DictConfig): print(f"Loading checkpoint {checkpoint_path}.") loaded_data = torch.load(checkpoint_path) # Do not load the cached xy grid. - # - this allows to set an arbitrary evaluation image size. + # - this allows setting an arbitrary evaluation image size. state_dict = { k: v for k, v in loaded_data["model"].items() @@ -121,7 +121,7 @@ def main(cfg: DictConfig): test_image = test_image.to(device) test_camera = test_camera.to(device) - # Activate eval mode of the model (allows to do a full rendering pass). + # Activate eval mode of the model (lets us do a full rendering pass). model.eval() with torch.no_grad(): test_nerf_out, test_metrics = model( diff --git a/projects/nerf/tests/test_raysampler.py b/projects/nerf/tests/test_raysampler.py index bae85ad4..72de843e 100644 --- a/projects/nerf/tests/test_raysampler.py +++ b/projects/nerf/tests/test_raysampler.py @@ -70,7 +70,7 @@ class TestRaysampler(unittest.TestCase): def test_probabilistic_raysampler(self, batch_size=1, n_pts_per_ray=60): """ - Check that the probabilisitc ray sampler does not crash for various + Check that the probabilistic ray sampler does not crash for various settings. """ diff --git a/projects/nerf/train_nerf.py b/projects/nerf/train_nerf.py index 795b6cf7..87847046 100644 --- a/projects/nerf/train_nerf.py +++ b/projects/nerf/train_nerf.py @@ -31,7 +31,7 @@ def main(cfg: DictConfig): else: warnings.warn( "Please note that although executing on CPU is supported," - + "the training is unlikely to finish in resonable time." + + "the training is unlikely to finish in reasonable time." ) device = "cpu" @@ -109,7 +109,7 @@ def main(cfg: DictConfig): optimizer, lr_lambda, last_epoch=start_epoch - 1, verbose=False ) - # Initialize the cache for storing variables needed for visulization. + # Initialize the cache for storing variables needed for visualization. visuals_cache = collections.deque(maxlen=cfg.visualization.history_size) # Init the visualization visdom env. @@ -194,7 +194,7 @@ def main(cfg: DictConfig): if iteration % cfg.stats_print_interval == 0: stats.print(stat_set="train") - # Update the visualisatioon cache. + # Update the visualization cache. visuals_cache.append( { "camera": camera.cpu(), @@ -219,7 +219,7 @@ def main(cfg: DictConfig): val_image = val_image.to(device) val_camera = val_camera.to(device) - # Activate eval mode of the model (allows to do a full rendering pass). + # Activate eval mode of the model (lets us do a full rendering pass). model.eval() with torch.no_grad(): val_nerf_out, val_metrics = model( diff --git a/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.cu b/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.cu index 714d6aca..6cca278a 100644 --- a/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.cu +++ b/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.cu @@ -105,7 +105,7 @@ __device__ bool CheckPointOutsideBoundingBox( // which contains Pixel structs with the indices of the faces which intersect // with this pixel sorted by closest z distance. If the point pxy lies in the // face, the list (q) is updated and re-orderered in place. In addition -// the auxillary variables q_size, q_max_z and q_max_idx are also modified. +// the auxiliary variables q_size, q_max_z and q_max_idx are also modified. // This code is shared between RasterizeMeshesNaiveCudaKernel and // RasterizeMeshesFineCudaKernel. template @@ -275,7 +275,7 @@ __global__ void RasterizeMeshesNaiveCudaKernel( const int yi = H - 1 - pix_idx / W; const int xi = W - 1 - pix_idx % W; - // screen coordinates to ndc coordiantes of pixel. + // screen coordinates to ndc coordinates of pixel. const float xf = PixToNonSquareNdc(xi, W, H); const float yf = PixToNonSquareNdc(yi, H, W); const float2 pxy = make_float2(xf, yf); diff --git a/pytorch3d/csrc/rasterize_points/rasterize_points.cu b/pytorch3d/csrc/rasterize_points/rasterize_points.cu index 8b5ea133..35effd72 100644 --- a/pytorch3d/csrc/rasterize_points/rasterize_points.cu +++ b/pytorch3d/csrc/rasterize_points/rasterize_points.cu @@ -27,7 +27,7 @@ __device__ inline bool operator<(const Pix& a, const Pix& b) { // which contains Pixel structs with the indices of the points which intersect // with this pixel sorted by closest z distance. If the pixel pxy lies in the // point, the list (q) is updated and re-orderered in place. In addition -// the auxillary variables q_size, q_max_z and q_max_idx are also modified. +// the auxiliary variables q_size, q_max_z and q_max_idx are also modified. // This code is shared between RasterizePointsNaiveCudaKernel and // RasterizePointsFineCudaKernel. template @@ -104,7 +104,7 @@ __global__ void RasterizePointsNaiveCudaKernel( const int yi = H - 1 - pix_idx / W; const int xi = W - 1 - pix_idx % W; - // screen coordinates to ndc coordiantes of pixel. + // screen coordinates to ndc coordinates of pixel. const float xf = PixToNonSquareNdc(xi, W, H); const float yf = PixToNonSquareNdc(yi, H, W); diff --git a/pytorch3d/csrc/utils/geometry_utils.cuh b/pytorch3d/csrc/utils/geometry_utils.cuh index f8d6b2a8..16746396 100644 --- a/pytorch3d/csrc/utils/geometry_utils.cuh +++ b/pytorch3d/csrc/utils/geometry_utils.cuh @@ -224,7 +224,7 @@ BarycentricPerspectiveCorrectionBackward( // Clip negative barycentric coordinates to 0.0 and renormalize so // the barycentric coordinates for a point sum to 1. When the blur_radius // is greater than 0, a face will still be recorded as overlapping a pixel -// if the pixel is outisde the face. In this case at least one of the +// if the pixel is outside the face. In this case at least one of the // barycentric coordinates for the pixel relative to the face will be negative. // Clipping will ensure that the texture and z buffer are interpolated // correctly. diff --git a/pytorch3d/csrc/utils/geometry_utils.h b/pytorch3d/csrc/utils/geometry_utils.h index f24f58ac..fd95a815 100644 --- a/pytorch3d/csrc/utils/geometry_utils.h +++ b/pytorch3d/csrc/utils/geometry_utils.h @@ -245,7 +245,7 @@ inline std::tuple, T, T, T> BarycentricPerspectiveCorrectionBackward( // Clip negative barycentric coordinates to 0.0 and renormalize so // the barycentric coordinates for a point sum to 1. When the blur_radius // is greater than 0, a face will still be recorded as overlapping a pixel -// if the pixel is outisde the face. In this case at least one of the +// if the pixel is outside the face. In this case at least one of the // barycentric coordinates for the pixel relative to the face will be negative. // Clipping will ensure that the texture and z buffer are interpolated // correctly. diff --git a/pytorch3d/datasets/r2n2/r2n2.py b/pytorch3d/datasets/r2n2/r2n2.py index b4ef58c0..dff335c5 100644 --- a/pytorch3d/datasets/r2n2/r2n2.py +++ b/pytorch3d/datasets/r2n2/r2n2.py @@ -99,7 +99,7 @@ class R2N2(ShapeNetBase): path.join(SYNSET_DICT_DIR, "r2n2_synset_dict.json"), "r" ) as read_dict: self.synset_dict = json.load(read_dict) - # Inverse dicitonary mapping synset labels to corresponding offsets. + # Inverse dictionary mapping synset labels to corresponding offsets. self.synset_inv = {label: offset for offset, label in self.synset_dict.items()} # Store synset and model ids of objects mentioned in the splits_file. @@ -383,7 +383,7 @@ class R2N2(ShapeNetBase): view_idxs: each model will be rendered with the orientation(s) of the specified views. Only render by view_idxs if no camera or args for BlenderCamera is supplied. - Accepts any of the args of the render function in ShapnetBase: + Accepts any of the args of the render function in ShapeNetBase: model_ids: List[str] of model_ids of models intended to be rendered. categories: List[str] of categories intended to be rendered. categories and sample_nums must be specified at the same time. categories can be given diff --git a/pytorch3d/datasets/r2n2/utils.py b/pytorch3d/datasets/r2n2/utils.py index f82636b1..5a1042da 100644 --- a/pytorch3d/datasets/r2n2/utils.py +++ b/pytorch3d/datasets/r2n2/utils.py @@ -97,8 +97,8 @@ def compute_extrinsic_matrix(azimuth, elevation, distance): Copied from meshrcnn codebase: https://github.com/facebookresearch/meshrcnn/blob/master/shapenet/utils/coords.py#L96 - Compute 4x4 extrinsic matrix that converts from homogenous world coordinates - to homogenous camera coordinates. We assume that the camera is looking at the + Compute 4x4 extrinsic matrix that converts from homogeneous world coordinates + to homogeneous camera coordinates. We assume that the camera is looking at the origin. Used in R2N2 Dataset when computing calibration matrices. @@ -189,7 +189,7 @@ def _compute_idxs(vals, counts): Args: vals: tensor of binary values indicating voxel presence in a dense format. - counts: tensor of number of occurence of each value in vals. + counts: tensor of number of occurrence of each value in vals. Returns: idxs: A tensor of shape (N), where N is the number of nonzero voxels. @@ -379,7 +379,7 @@ def project_verts(verts, P, eps=1e-1): Copied from meshrcnn codebase: https://github.com/facebookresearch/meshrcnn/blob/master/shapenet/utils/coords.py#L159 - Project verticies using a 4x4 transformation matrix. + Project vertices using a 4x4 transformation matrix. Args: verts: FloatTensor of shape (N, V, 3) giving a batch of vertex positions or of @@ -403,7 +403,7 @@ def project_verts(verts, P, eps=1e-1): # Add an extra row of ones to the world-space coordinates of verts before # multiplying by the projection matrix. We could avoid this allocation by - # instead multiplying by a 4x3 submatrix of the projectio matrix, then + # instead multiplying by a 4x3 submatrix of the projection matrix, then # adding the remaining 4x1 vector. Not sure whether there will be much # performance difference between the two. ones = torch.ones(N, V, 1, dtype=dtype, device=device) diff --git a/pytorch3d/datasets/shapenet/shapenet_core.py b/pytorch3d/datasets/shapenet/shapenet_core.py index 78184be8..a8635fd9 100644 --- a/pytorch3d/datasets/shapenet/shapenet_core.py +++ b/pytorch3d/datasets/shapenet/shapenet_core.py @@ -37,7 +37,7 @@ class ShapeNetCore(ShapeNetBase): synset offsets or labels. A combination of both is also accepted. When no category is specified, all categories in data_dir are loaded. version: (int) version of ShapeNetCore data in data_dir, 1 or 2. - Default is set to be 1. Version 1 has 57 categories and verions 2 has 55 + Default is set to be 1. Version 1 has 57 categories and version 2 has 55 categories. Note: version 1 has two categories 02858304(boat) and 02992529(cellphone) that are hyponyms of categories 04530566(watercraft) and 04401088(telephone) @@ -63,7 +63,7 @@ class ShapeNetCore(ShapeNetBase): dict_file = "shapenet_synset_dict_v%d.json" % version with open(path.join(SYNSET_DICT_DIR, dict_file), "r") as read_dict: self.synset_dict = json.load(read_dict) - # Inverse dicitonary mapping synset labels to corresponding offsets. + # Inverse dictionary mapping synset labels to corresponding offsets. self.synset_inv = {label: offset for offset, label in self.synset_dict.items()} # If categories are specified, check if each category is in the form of either diff --git a/pytorch3d/datasets/shapenet_base.py b/pytorch3d/datasets/shapenet_base.py index 32d5c33b..6eca6f84 100644 --- a/pytorch3d/datasets/shapenet_base.py +++ b/pytorch3d/datasets/shapenet_base.py @@ -250,7 +250,7 @@ class ShapeNetBase(torch.utils.data.Dataset): Helper function for sampling a number of indices from the given category. Args: - sample_num: number of indicies to be sampled from the given category. + sample_num: number of indices to be sampled from the given category. category: category synset of the category to be sampled from. If not specified, sample from all models in the loaded dataset. """ diff --git a/pytorch3d/io/mtl_io.py b/pytorch3d/io/mtl_io.py index 79f65d01..6d3fa602 100644 --- a/pytorch3d/io/mtl_io.py +++ b/pytorch3d/io/mtl_io.py @@ -28,7 +28,7 @@ def make_mesh_texture_atlas( Args: material_properties: dict of properties for each material. If a material - does not have any properties it will have an emtpy dict. + does not have any properties it will have an empty dict. texture_images: dict of material names and texture images face_material_names: numpy array of the material name corresponding to each face. Faces which don't have an associated material will be an empty string. @@ -220,13 +220,13 @@ def make_material_atlas( For each grid cell we can now calculate the centroid `(c_y, c_x)` of the corresponding texture triangle: - - if `(x + y) < R`, then offsett the centroid of + - if `(x + y) < R`, then offset the centroid of triangle 0 by `(y, x) * (1/R)` - if `(x + y) > R`, then offset the centroid of triangle 8 by `((R-1-y), (R-1-x)) * (1/R)`. This is equivalent to updating the portion of Grid 1 - above the diagnonal, replacing `(y, x)` with `((R-1-y), (R-1-x))`: + above the diagonal, replacing `(y, x)` with `((R-1-y), (R-1-x))`: ..code-block::python diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index e6fe9d80..bb329fb4 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -109,13 +109,13 @@ def load_obj( Faces are interpreted as follows: :: - 5/2/1 describes the first vertex of the first triange + 5/2/1 describes the first vertex of the first triangle - 5: index of vertex [1.000000 1.000000 -1.000000] - 2: index of texture coordinate [0.749279 0.501284] - 1: index of normal [0.000000 0.000000 -1.000000] If there are faces with more than 3 vertices - they are subdivided into triangles. Polygonal faces are assummed to have + they are subdivided into triangles. Polygonal faces are assumed to have vertices ordered counter-clockwise so the (right-handed) normal points out of the screen e.g. a proper rectangular face would be specified like this: :: @@ -368,7 +368,7 @@ def _parse_face( face_normals.append(int(vert_props[2])) if len(vert_props) > 3: raise ValueError( - "Face vertices can ony have 3 properties. \ + "Face vertices can only have 3 properties. \ Face vert %s, Line: %s" % (str(vert_props), str(line)) ) diff --git a/pytorch3d/io/pluggable.py b/pytorch3d/io/pluggable.py index 6d1b4691..161233fa 100644 --- a/pytorch3d/io/pluggable.py +++ b/pytorch3d/io/pluggable.py @@ -33,7 +33,7 @@ and to save a point cloud you might do ``` pcl = Pointclouds(...) -IO().save_pointcloud(pcl, "output_poincloud.obj") +IO().save_pointcloud(pcl, "output_pointcloud.obj") ``` """ @@ -43,7 +43,7 @@ class IO: """ This class is the interface to flexible loading and saving of meshes and point clouds. - In simple cases the user will just initialise an instance of this class as `IO()` + In simple cases the user will just initialize an instance of this class as `IO()` and then use its load and save functions. The arguments of the initializer are not usually needed. @@ -53,7 +53,7 @@ class IO: Args: include_default_formats: If False, the built-in file formats will not be available. Then only user-registered formats can be used. - path_manager: Used to customise how paths given as strings are interpreted. + path_manager: Used to customize how paths given as strings are interpreted. """ def __init__( diff --git a/pytorch3d/io/ply_io.py b/pytorch3d/io/ply_io.py index 2df8461f..9fe557ba 100644 --- a/pytorch3d/io/ply_io.py +++ b/pytorch3d/io/ply_io.py @@ -380,7 +380,7 @@ def _try_read_ply_constant_list_ascii(f, definition: _PlyElementType): return data[:, 1:] -def _parse_heterogenous_property_ascii(datum, line_iter, property: _Property): +def _parse_heterogeneous_property_ascii(datum, line_iter, property: _Property): """ Read a general data property from an ascii .ply file. @@ -431,7 +431,7 @@ def _read_ply_element_ascii(f, definition: _PlyElementType): In simple cases where every element has the same size, 2D numpy array corresponding to the data. The rows are the different values. Otherwise a list of lists of values, where the outer list is - each occurence of the element, and the inner lists have one value per + each occurrence of the element, and the inner lists have one value per property. """ if not definition.count: @@ -454,7 +454,7 @@ def _read_ply_element_ascii(f, definition: _PlyElementType): datum = [] line_iter = iter(line_string.strip().split()) for property in definition.properties: - _parse_heterogenous_property_ascii(datum, line_iter, property) + _parse_heterogeneous_property_ascii(datum, line_iter, property) data.append(datum) if next(line_iter, None) is not None: raise ValueError("Too much data for an element.") @@ -669,7 +669,7 @@ def _read_ply_element_binary(f, definition: _PlyElementType, big_endian: bool) - In simple cases where every element has the same size, 2D numpy array corresponding to the data. The rows are the different values. Otherwise a list of lists/tuples of values, where the outer list is - each occurence of the element, and the inner lists have one value per + each occurrence of the element, and the inner lists have one value per property. """ if not definition.count: @@ -1027,7 +1027,7 @@ def _save_ply( Args: f: File object to which the 3D data should be written. verts: FloatTensor of shape (V, 3) giving vertex coordinates. - faces: LongTensor of shsape (F, 3) giving faces. + faces: LongTensor of shape (F, 3) giving faces. verts_normals: FloatTensor of shape (V, 3) giving vertex normals. ascii: (bool) whether to use the ascii ply format. decimal_places: Number of decimal places for saving if ascii=True. diff --git a/pytorch3d/loss/mesh_laplacian_smoothing.py b/pytorch3d/loss/mesh_laplacian_smoothing.py index 575a7c3e..571005ec 100644 --- a/pytorch3d/loss/mesh_laplacian_smoothing.py +++ b/pytorch3d/loss/mesh_laplacian_smoothing.py @@ -9,7 +9,7 @@ def mesh_laplacian_smoothing(meshes, method: str = "uniform"): Computes the laplacian smoothing objective for a batch of meshes. This function supports three variants of Laplacian smoothing, namely with uniform weights("uniform"), with cotangent weights ("cot"), - and cotangent cuvature ("cotcurv").For more details read [1, 2]. + and cotangent curvature ("cotcurv").For more details read [1, 2]. Args: meshes: Meshes object with a batch of meshes. diff --git a/pytorch3d/loss/point_mesh_distance.py b/pytorch3d/loss/point_mesh_distance.py index da4fcb59..bffe99e4 100644 --- a/pytorch3d/loss/point_mesh_distance.py +++ b/pytorch3d/loss/point_mesh_distance.py @@ -91,7 +91,7 @@ class _FacePointDistance(Function): max_tris: Scalar equal to maximum number of faces in the batch Returns: dists: FloatTensor of shape `(T,)`, where `dists[t]` is the squared - euclidean distance of `t`-th trianguar face to the closest point in the + euclidean distance of `t`-th triangular face to the closest point in the corresponding example in the batch idxs: LongTensor of shape `(T,)` indicating the closest point in the corresponding example in the batch. diff --git a/pytorch3d/ops/interp_face_attrs.py b/pytorch3d/ops/interp_face_attrs.py index da11b0df..e22392d0 100644 --- a/pytorch3d/ops/interp_face_attrs.py +++ b/pytorch3d/ops/interp_face_attrs.py @@ -21,7 +21,7 @@ def interpolate_face_attributes( pixel in the image. A value < 0 indicates that the pixel does not overlap any face and should be skipped. barycentric_coords: FloatTensor of shape (N, H, W, K, 3) specifying - the barycentric coordianates of each pixel + the barycentric coordinates of each pixel relative to the faces (in the packed representation) which overlap the pixel. face_attributes: packed attributes of shape (total_faces, 3, D), diff --git a/pytorch3d/ops/knn.py b/pytorch3d/ops/knn.py index 4f3df23a..bfab9781 100644 --- a/pytorch3d/ops/knn.py +++ b/pytorch3d/ops/knn.py @@ -147,7 +147,7 @@ def knn_points( p2_nn = knn_gather(p2, p1_idx, lengths2) which is a helper function that allows indexing any tensor of shape (N, P2, U) with - the indices `p1_idx` returned by `knn_points`. The outout is a tensor + the indices `p1_idx` returned by `knn_points`. The output is a tensor of shape (N, P1, K, U). """ diff --git a/pytorch3d/ops/perspective_n_points.py b/pytorch3d/ops/perspective_n_points.py index 9a3f73f6..89faf8c8 100644 --- a/pytorch3d/ops/perspective_n_points.py +++ b/pytorch3d/ops/perspective_n_points.py @@ -184,7 +184,7 @@ def _gen_pairs(input, dim=-2, reducer=lambda a, b: ((a - b) ** 2).sum(dim=-1)): def _kernel_vec_distances(v): - """Computes the coefficients for linearisation of the quadratic system + """Computes the coefficients for linearization of the quadratic system to match all pairwise distances between 4 control points (dim=1). The last dimension corresponds to the coefficients for quadratic terms Bij = Bi * Bj, where Bi and Bj correspond to kernel vectors. diff --git a/pytorch3d/ops/points_normals.py b/pytorch3d/ops/points_normals.py index 741465b3..0ec80780 100644 --- a/pytorch3d/ops/points_normals.py +++ b/pytorch3d/ops/points_normals.py @@ -28,7 +28,7 @@ def estimate_pointcloud_normals( **neighborhood_size**: The size of the neighborhood used to estimate the geometry around each point. **disambiguate_directions**: If `True`, uses the algorithm from [1] to - ensure sign consistency of the normals of neigboring points. + ensure sign consistency of the normals of neighboring points. Returns: **normals**: A tensor of normals for each input point @@ -83,7 +83,7 @@ def estimate_pointcloud_local_coord_frames( **neighborhood_size**: The size of the neighborhood used to estimate the geometry around each point. **disambiguate_directions**: If `True`, uses the algorithm from [1] to - ensure sign consistency of the normals of neigboring points. + ensure sign consistency of the normals of neighboring points. Returns: **curvatures**: The three principal curvatures of each point diff --git a/pytorch3d/ops/points_to_volumes.py b/pytorch3d/ops/points_to_volumes.py index 29e0ed88..4356eb42 100644 --- a/pytorch3d/ops/points_to_volumes.py +++ b/pytorch3d/ops/points_to_volumes.py @@ -140,7 +140,7 @@ def add_points_features_to_volume_densities_features( volume_features: Batch of input feature volumes of shape `(minibatch, feature_dim, D, H, W)` If set to `None`, the `volume_features` will be automatically - instantiatied with a correct size and filled with 0s. + instantiated with a correct size and filled with 0s. mode: The mode of the conversion of individual points into the volume. Set either to `nearest` or `trilinear`: `nearest`: Each 3D point is first rounded to the volumetric @@ -310,7 +310,7 @@ def splat_points_to_volumes( # minibatch x n_points x feature_dim -> minibatch x feature_dim x n_points points_features = points_features.permute(0, 2, 1).contiguous() - # XYZ = the upper-left volume index of the 8-neigborhood of every point + # XYZ = the upper-left volume index of the 8-neighborhood of every point # grid_sizes is of the form (minibatch, depth-height-width) grid_sizes_xyz = grid_sizes[:, [2, 1, 0]] diff --git a/pytorch3d/ops/sample_points_from_meshes.py b/pytorch3d/ops/sample_points_from_meshes.py index 9e6dac54..afc573f6 100644 --- a/pytorch3d/ops/sample_points_from_meshes.py +++ b/pytorch3d/ops/sample_points_from_meshes.py @@ -25,8 +25,9 @@ def sample_points_from_meshes( Tuple[torch.Tensor, torch.Tensor, torch.Tensor], ]: """ - Convert a batch of meshes to a pointcloud by uniformly sampling points on - the surface of the mesh with probability proportional to the face area. + Convert a batch of meshes to a batch of pointclouds by uniformly sampling + points on the surface of the mesh with probability proportional to the + face area. Args: meshes: A Meshes object with a batch of N meshes. @@ -54,7 +55,7 @@ def sample_points_from_meshes( .. code-block:: python - Poinclouds(samples, normals=normals, features=textures) + Pointclouds(samples, normals=normals, features=textures) """ if meshes.isempty(): raise ValueError("Meshes are empty.") @@ -71,7 +72,7 @@ def sample_points_from_meshes( num_meshes = len(meshes) num_valid_meshes = torch.sum(meshes.valid) # Non empty meshes. - # Intialize samples tensor with fill value 0 for empty meshes. + # Initialize samples tensor with fill value 0 for empty meshes. samples = torch.zeros((num_meshes, num_samples, 3), device=meshes.device) # Only compute samples for non empty meshes @@ -104,7 +105,7 @@ def sample_points_from_meshes( samples[meshes.valid] = w0[:, :, None] * a + w1[:, :, None] * b + w2[:, :, None] * c if return_normals: - # Intialize normals tensor with fill value 0 for empty meshes. + # Initialize normals tensor with fill value 0 for empty meshes. # Normals for the sampled points are face normals computed from # the vertices of the face in which the sampled point lies. normals = torch.zeros((num_meshes, num_samples, 3), device=meshes.device) diff --git a/pytorch3d/ops/utils.py b/pytorch3d/ops/utils.py index 3a6ba4a9..cbc7f3d5 100644 --- a/pytorch3d/ops/utils.py +++ b/pytorch3d/ops/utils.py @@ -27,7 +27,7 @@ def wmean( the last (spatial) dimension are assumed same; dim: dimension(s) in `x` to average over; keepdim: tells whether to keep the resulting singleton dimension. - eps: minumum clamping value in the denominator. + eps: minimum clamping value in the denominator. Returns: the mean tensor: * if `weights` is None => `mean(x, dim)`, diff --git a/pytorch3d/ops/vert_align.py b/pytorch3d/ops/vert_align.py index c53a1fb7..078f9678 100644 --- a/pytorch3d/ops/vert_align.py +++ b/pytorch3d/ops/vert_align.py @@ -15,7 +15,7 @@ def vert_align( ) -> torch.Tensor: """ Sample vertex features from a feature map. This operation is called - "perceptual feaure pooling" in [1] or "vert align" in [2]. + "perceptual feature pooling" in [1] or "vert align" in [2]. [1] Wang et al, "Pixel2Mesh: Generating 3D Mesh Models from Single RGB Images", ECCV 2018. @@ -45,7 +45,7 @@ def vert_align( Returns: feats_sampled: FloatTensor of shape (N, V, C) giving sampled features for each - vertex. If feats is a list, we return concatentated features in axis=2 of + vertex. If feats is a list, we return concatenated features in axis=2 of shape (N, V, sum(C_n)) where C_n = feats[n].shape[1]. If return_packed = True, the features are transformed to a packed representation of shape (sum(V), C) diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index 22887b1e..35db1d29 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -30,7 +30,7 @@ class CamerasBase(TensorProperties): The transformation from world -> view happens after applying a rotation (R) and translation (T) - NDC coordinate system: This is the normalized coordinate system that confines - in a volume the renderered part of the object or scene. Also known as view volume. + in a volume the rendered part of the object or scene. Also known as view volume. Given the PyTorch3D convention, (+1, +1, znear) is the top left near corner, and (-1, -1, zfar) is the bottom right far corner of the volume. The transformation from view -> NDC happens after applying the camera @@ -78,7 +78,7 @@ class CamerasBase(TensorProperties): def unproject_points(self): """ - Transform input points from NDC coodinates + Transform input points from NDC coordinates to the world / camera coordinates. Each of the input points `xy_depth` of shape (..., 3) is @@ -210,7 +210,7 @@ class CamerasBase(TensorProperties): For `CamerasBase.transform_points`, setting `eps > 0` stabilizes gradients since it leads to avoiding division - by excessivelly low numbers for points close to the + by excessively low numbers for points close to the camera plane. Returns @@ -235,7 +235,7 @@ class CamerasBase(TensorProperties): For `CamerasBase.transform_points`, setting `eps > 0` stabilizes gradients since it leads to avoiding division - by excessivelly low numbers for points close to the + by excessively low numbers for points close to the camera plane. Returns @@ -318,7 +318,7 @@ def OpenGLPerspectiveCameras( class FoVPerspectiveCameras(CamerasBase): """ A class which stores a batch of parameters to generate a batch of - projection matrices by specifiying the field of view. + projection matrices by specifying the field of view. The definition of the parameters follow the OpenGL perspective camera. The extrinsics of the camera (R and T matrices) can also be set in the @@ -405,7 +405,7 @@ class FoVPerspectiveCameras(CamerasBase): degrees: bool, set to True if fov is specified in degrees. Returns: - torch.floatTensor of the calibration matrix with shape (N, 4, 4) + torch.FloatTensor of the calibration matrix with shape (N, 4, 4) """ K = torch.zeros((self._N, 4, 4), device=self.device, dtype=torch.float32) ones = torch.ones((self._N), dtype=torch.float32, device=self.device) @@ -421,7 +421,7 @@ class FoVPerspectiveCameras(CamerasBase): min_x = -max_x # NOTE: In OpenGL the projection matrix changes the handedness of the - # coordinate frame. i.e the NDC space postive z direction is the + # coordinate frame. i.e the NDC space positive z direction is the # camera space negative z direction. This is because the sign of the z # in the projection matrix is set to -1.0. # In pytorch3d we maintain a right handed coordinate system throughout @@ -444,7 +444,7 @@ class FoVPerspectiveCameras(CamerasBase): def get_projection_transform(self, **kwargs) -> Transform3d: """ - Calculate the perpective projection matrix with a symmetric + Calculate the perspective projection matrix with a symmetric viewing frustrum. Use column major order. The viewing frustrum will be projected into ndc, s.t. (max_x, max_y) -> (+1, +1) @@ -586,7 +586,7 @@ def OpenGLOrthographicCameras( class FoVOrthographicCameras(CamerasBase): """ A class which stores a batch of parameters to generate a batch of - projection matrices by specifiying the field of view. + projection matrices by specifying the field of view. The definition of the parameters follow the OpenGL orthographic camera. """ @@ -612,7 +612,7 @@ class FoVOrthographicCameras(CamerasBase): max_y: maximum y coordinate of the frustrum. min_y: minimum y coordinate of the frustrum. max_x: maximum x coordinate of the frustrum. - min_x: minumum x coordinage of the frustrum + min_x: minimum x coordinate of the frustrum scale_xyz: scale factors for each axis of shape (N, 3). R: Rotation matrix of shape (N, 3, 3). T: Translation of shape (N, 3). @@ -649,7 +649,7 @@ class FoVOrthographicCameras(CamerasBase): znear: near clipping plane of the view frustrum. zfar: far clipping plane of the view frustrum. max_x: maximum x coordinate of the frustrum. - min_x: minumum x coordinage of the frustrum + min_x: minimum x coordinate of the frustrum max_y: maximum y coordinate of the frustrum. min_y: minimum y coordinate of the frustrum. scale_xyz: scale factors for each axis of shape (N, 3). @@ -693,7 +693,7 @@ class FoVOrthographicCameras(CamerasBase): scale_z = 2 / (far-near) mid_x = (max_x + min_x) / (max_x - min_x) mix_y = (max_y + min_y) / (max_y - min_y) - mid_z = (far + near) / (far−near) + mid_z = (far + near) / (far - near) K = [ [scale_x, 0, 0, -mid_x], @@ -811,7 +811,7 @@ class PerspectiveCameras(CamerasBase): If you wish to provide parameters in screen space, you NEED to provide the image_size = (imwidth, imheight). If you wish to provide parameters in NDC space, you should NOT provide - image_size. Providing valid image_size will triger a screen space to + image_size. Providing valid image_size will trigger a screen space to NDC space transformation in the camera. For example, here is how to define cameras on the two spaces. @@ -978,7 +978,7 @@ class OrthographicCameras(CamerasBase): If you wish to provide parameters in screen space, you NEED to provide the image_size = (imwidth, imheight). If you wish to provide parameters in NDC space, you should NOT provide - image_size. Providing valid image_size will triger a screen space to + image_size. Providing valid image_size will trigger a screen space to NDC space transformation in the camera. For example, here is how to define cameras on the two spaces. @@ -1120,7 +1120,7 @@ def _get_sfm_calibration_matrix( image_size=None, ) -> torch.Tensor: """ - Returns a calibration matrix of a perspective/orthograpic camera. + Returns a calibration matrix of a perspective/orthographic camera. Args: N: Number of cameras. @@ -1355,7 +1355,7 @@ def look_at_view_transform( Args: dist: distance of the camera from the object - elev: angle in degres or radians. This is the angle between the + elev: angle in degrees or radians. This is the angle between the vector from the object to the camera, and the horizontal plane y = 0 (xz-plane). azim: angle in degrees or radians. The vector from the object to the camera is projected onto a horizontal plane y = 0. @@ -1365,7 +1365,7 @@ def look_at_view_transform( degrees: boolean flag to indicate if the elevation and azimuth angles are specified in degrees or radians. eye: the position of the camera(s) in world coordinates. If eye is not - None, it will overide the camera position derived from dist, elev, azim. + None, it will override the camera position derived from dist, elev, azim. up: the direction of the x axis in the world coordinate system. at: the position of the object(s) in world coordinates. eye, up and at can be of shape (1, 3) or (N, 3). diff --git a/pytorch3d/renderer/implicit/raymarching.py b/pytorch3d/renderer/implicit/raymarching.py index b5164dab..bafb7da9 100644 --- a/pytorch3d/renderer/implicit/raymarching.py +++ b/pytorch3d/renderer/implicit/raymarching.py @@ -67,13 +67,13 @@ class EmissionAbsorptionRaymarcher(torch.nn.Module): rays_features: Per-ray feature values represented with a tensor of shape `(..., n_points_per_ray, feature_dim)`. eps: A lower bound added to `rays_densities` before computing - the absorbtion function (cumprod of `1-rays_densities` along + the absorption function (cumprod of `1-rays_densities` along each ray). This prevents the cumprod to yield exact 0 which would inhibit any gradient-based learning. Returns: features_opacities: A tensor of shape `(..., feature_dim+1)` - that concatenates two tensors alonng the last dimension: + that concatenates two tensors along the last dimension: 1) features: A tensor of per-ray renders of shape `(..., feature_dim)`. 2) opacities: A tensor of per-ray opacity values diff --git a/pytorch3d/renderer/implicit/raysampling.py b/pytorch3d/renderer/implicit/raysampling.py index 9536a42c..b1e40bd5 100644 --- a/pytorch3d/renderer/implicit/raysampling.py +++ b/pytorch3d/renderer/implicit/raysampling.py @@ -16,7 +16,7 @@ This file defines three raysampling techniques: class GridRaysampler(torch.nn.Module): """ - Samples a fixed number of points along rays which are regulary distributed + Samples a fixed number of points along rays which are regularly distributed in a batch of rectangular image grids. Points along each ray have uniformly-spaced z-coordinates between a predefined minimum and maximum depth. @@ -129,7 +129,7 @@ class GridRaysampler(torch.nn.Module): class NDCGridRaysampler(GridRaysampler): """ - Samples a fixed number of points along rays which are regulary distributed + Samples a fixed number of points along rays which are regularly distributed in a batch of rectangular image grids. Points along each ray have uniformly-spaced z-coordinates between a predefined minimum and maximum depth. diff --git a/pytorch3d/renderer/implicit/renderer.py b/pytorch3d/renderer/implicit/renderer.py index 9f2116bc..b8ef24e6 100644 --- a/pytorch3d/renderer/implicit/renderer.py +++ b/pytorch3d/renderer/implicit/renderer.py @@ -18,7 +18,7 @@ from .utils import _validate_ray_bundle_variables, ray_bundle_variables_to_ray_p # 1) The raysampler: # - samples rays from input cameras # - transforms the rays to world coordinates -# 2) The volumetric_function (which is a callable argument of the forwad pass) +# 2) The volumetric_function (which is a callable argument of the forward pass) # evaluates ray_densities and ray_features at the sampled ray-points. # 3) The raymarcher takes ray_densities and ray_features and uses a raymarching # algorithm to render each ray. @@ -64,7 +64,7 @@ class ImplicitRenderer(torch.nn.Module): the an feature vector for each ray point. Note that, in order to increase flexibility of the API, we allow multiple - other arguments to enter the volumentric function via additional + other arguments to enter the volumetric function via additional (optional) keyword arguments `**kwargs`. A typical use-case is passing a `CamerasBase` object as an additional keyword argument, which can allow the volumetric function to adjust its @@ -131,7 +131,7 @@ class ImplicitRenderer(torch.nn.Module): Args: cameras: A batch of cameras that render the scene. A `self.raysampler` takes the cameras as input and samples rays that pass through the - domain of the volumentric function. + domain of the volumetric function. volumetric_function: A `Callable` that accepts the parametrizations of the rendering rays and returns the densities and features at the respective 3D of the rendering rays. Please refer to @@ -229,7 +229,7 @@ class VolumeRenderer(torch.nn.Module): Args: cameras: A batch of cameras that render the scene. A `self.raysampler` takes the cameras as input and samples rays that pass through the - domain of the volumentric function. + domain of the volumetric function. volumes: An instance of the `Volumes` class representing a batch of volumes that are being rendered. @@ -247,7 +247,7 @@ class VolumeRenderer(torch.nn.Module): class VolumeSampler(torch.nn.Module): """ - A class that allows to sample a batch of volumes `Volumes` + A module to sample a batch of volumes `Volumes` at 3D points sampled along projection rays. """ @@ -255,7 +255,7 @@ class VolumeSampler(torch.nn.Module): """ Args: volumes: An instance of the `Volumes` class representing a - batch if volumes that are being rendered. + batch of volumes that are being rendered. sample_mode: Defines the algorithm used to sample the volumetric voxel grid. Can be either "bilinear" or "nearest". """ @@ -300,7 +300,7 @@ class VolumeSampler(torch.nn.Module): Returns: rays_densities: A tensor of shape `(minibatch, ..., num_points_per_ray, opacity_dim)` containing the - densitity vectors sampled from the volume at the locations of + density vectors sampled from the volume at the locations of the ray points. rays_features: A tensor of shape `(minibatch, ..., num_points_per_ray, feature_dim)` containing the diff --git a/pytorch3d/renderer/lighting.py b/pytorch3d/renderer/lighting.py index 49285cc4..d4e198d2 100644 --- a/pytorch3d/renderer/lighting.py +++ b/pytorch3d/renderer/lighting.py @@ -44,7 +44,7 @@ def diffuse(normals, color, direction) -> torch.Tensor: average/interpolated face coordinates. """ # TODO: handle multiple directional lights per batch element. - # TODO: handle attentuation. + # TODO: handle attenuation. # Ensure color and location have same batch dimension as normals normals, color, direction = convert_to_tensors_and_broadcast( @@ -107,7 +107,7 @@ def specular( meshes.verts_packed_to_mesh_idx() or meshes.faces_packed_to_mesh_idx(). """ # TODO: handle multiple directional lights - # TODO: attentuate based on inverse squared distance to the light source + # TODO: attenuate based on inverse squared distance to the light source if points.shape != normals.shape: msg = "Expected points and normals to have the same shape: got %r, %r" diff --git a/pytorch3d/renderer/mesh/rasterize_meshes.py b/pytorch3d/renderer/mesh/rasterize_meshes.py index 5d37d1da..6af4a0f3 100644 --- a/pytorch3d/renderer/mesh/rasterize_meshes.py +++ b/pytorch3d/renderer/mesh/rasterize_meshes.py @@ -17,7 +17,7 @@ from .clip import ( # TODO make the epsilon user configurable kEpsilon = 1e-8 -# Maxinum number of faces per bins for +# Maximum number of faces per bins for # coarse-to-fine rasterization kMaxFacesPerBin = 22 @@ -68,7 +68,7 @@ def rasterize_meshes( set it heuristically based on the shape of the input. This should not affect the output, but can affect the speed of the forward pass. faces_per_bin: Only applicable when using coarse-to-fine rasterization - (bin_size > 0); this is the maxiumum number of faces allowed within each + (bin_size > 0); this is the maximum number of faces allowed within each bin. If more than this many faces actually fall into a bin, an error will be raised. This should not affect the output values, but can affect the memory usage in the forward pass. @@ -138,7 +138,7 @@ def rasterize_meshes( num_faces_per_mesh = meshes.num_faces_per_mesh() # In the case that H != W use the max image size to set the bin_size - # to accommodate the num bins constraint in the coarse rasteizer. + # to accommodate the num bins constraint in the coarse rasterizer. # If the ratio of H:W is large this might cause issues as the smaller # dimension will have fewer bins. # TODO: consider a better way of setting the bin size. @@ -453,7 +453,7 @@ def rasterize_meshes_python( mesh_to_face_first_idx = clipped_faces.mesh_to_face_first_idx num_faces_per_mesh = clipped_faces.num_faces_per_mesh - # Intialize output tensors. + # Initialize output tensors. face_idxs = torch.full( (N, H, W, K), fill_value=-1, dtype=torch.int64, device=device ) @@ -662,7 +662,7 @@ def barycentric_coordinates_clip(bary): Clip negative barycentric coordinates to 0.0 and renormalize so the barycentric coordinates for a point sum to 1. When the blur_radius is greater than 0, a face will still be recorded as overlapping a pixel - if the pixel is outisde the face. In this case at least one of the + if the pixel is outside the face. In this case at least one of the barycentric coordinates for the pixel relative to the face will be negative. Clipping will ensure that the texture and z buffer are interpolated correctly. diff --git a/pytorch3d/renderer/mesh/rasterizer.py b/pytorch3d/renderer/mesh/rasterizer.py index 413a635e..e66acf3f 100644 --- a/pytorch3d/renderer/mesh/rasterizer.py +++ b/pytorch3d/renderer/mesh/rasterizer.py @@ -60,7 +60,7 @@ class RasterizationSettings: class MeshRasterizer(nn.Module): """ - This class implements methods for rasterizing a batch of heterogenous + This class implements methods for rasterizing a batch of heterogeneous Meshes. """ diff --git a/pytorch3d/renderer/mesh/textures.py b/pytorch3d/renderer/mesh/textures.py index d3345296..2ad3db3b 100644 --- a/pytorch3d/renderer/mesh/textures.py +++ b/pytorch3d/renderer/mesh/textures.py @@ -240,7 +240,7 @@ class TexturesBase: number of faces in the i-th mesh and C is the dimensional of the feature (C = 3 for RGB textures). You can use the utils function in structures.utils to convert the - packed respresentation to a list or padded. + packed representation to a list or padded. """ raise NotImplementedError() @@ -261,10 +261,10 @@ class TexturesBase: def __getitem__(self, index): """ Each texture class should implement a method - to get the texture properites for the + to get the texture properties for the specified elements in the batch. The TexturesBase._getitem(i) method - can be used as a helper funtion to retrieve the + can be used as a helper function to retrieve the class attributes for item i. Then, a new instance of the child class can be created with the attributes. @@ -496,7 +496,7 @@ class TexturesAtlas(TexturesBase): of the faces (in the packed representation) which overlap each pixel in the image. - barycentric_coords: FloatTensor of shape (N, H, W, K, 3) specifying - the barycentric coordianates of each pixel + the barycentric coordinates of each pixel relative to the faces (in the packed representation) which overlap the pixel. @@ -536,7 +536,7 @@ class TexturesAtlas(TexturesBase): For N meshes with {Fi} number of faces, it returns a tensor of shape sum(Fi)x3xD (D = 3 for RGB). You can use the utils function in structures.utils to convert the - packed respresentation to a list or padded. + packed representation to a list or padded. """ atlas_packed = self.atlas_packed() # assume each face consists of (v0, v1, v2). @@ -892,7 +892,7 @@ class TexturesUV(TexturesBase): of the faces (in the packed representation) which overlap each pixel in the image. - barycentric_coords: FloatTensor of shape (N, H, W, K, 3) specifying - the barycentric coordianates of each pixel + the barycentric coordinates of each pixel relative to the faces (in the packed representation) which overlap the pixel. @@ -1233,7 +1233,7 @@ class TexturesVertex(TexturesBase): Args: verts_features: list of (Vi, D) or (N, V, D) tensor giving a feature - vector with artbitrary dimensions for each vertex. + vector with arbitrary dimensions for each vertex. """ if isinstance(verts_features, (tuple, list)): correct_shape = all( @@ -1356,7 +1356,7 @@ class TexturesVertex(TexturesBase): def sample_textures(self, fragments, faces_packed=None) -> torch.Tensor: """ - Detemine the color for each rasterized face. Interpolate the colors for + Determine the color for each rasterized face. Interpolate the colors for vertices which form the face using the barycentric coordinates. Args: fragments: @@ -1366,7 +1366,7 @@ class TexturesVertex(TexturesBase): of the faces (in the packed representation) which overlap each pixel in the image. - barycentric_coords: FloatTensor of shape (N, H, W, K, 3) specifying - the barycentric coordianates of each pixel + the barycentric coordinates of each pixel relative to the faces (in the packed representation) which overlap the pixel. @@ -1389,7 +1389,7 @@ class TexturesVertex(TexturesBase): For N meshes with {Fi} number of faces, it returns a tensor of shape sum(Fi)x3xC (C = 3 for RGB). You can use the utils function in structures.utils to convert the - packed respresentation to a list or padded. + packed representation to a list or padded. """ verts_features_packed = self.verts_features_packed() faces_verts_features = verts_features_packed[faces_packed] diff --git a/pytorch3d/renderer/mesh/utils.py b/pytorch3d/renderer/mesh/utils.py index 3faf8f7a..3e9eb998 100644 --- a/pytorch3d/renderer/mesh/utils.py +++ b/pytorch3d/renderer/mesh/utils.py @@ -44,7 +44,7 @@ def _interpolate_zbuf( of the faces (in the packed representation) which overlap each pixel in the image. barycentric_coords: FloatTensor of shape (N, H, W, K, 3) specifying - the barycentric coordianates of each pixel + the barycentric coordinates of each pixel relative to the faces (in the packed representation) which overlap the pixel. meshes: Meshes object representing a batch of meshes. @@ -98,7 +98,7 @@ def _try_place_rectangle( Example: (We always have placed the first rectangle horizontally and other rectangles above it.) - Let's say the placed boxes 1-4 are layed out like this. + Let's say the placed boxes 1-4 are laid out like this. The coordinates of the points marked X are stored in occupied. It is to the right of the X's that we seek to place rect. diff --git a/pytorch3d/renderer/points/rasterize_points.py b/pytorch3d/renderer/points/rasterize_points.py index 0500e750..83265f40 100644 --- a/pytorch3d/renderer/points/rasterize_points.py +++ b/pytorch3d/renderer/points/rasterize_points.py @@ -8,7 +8,7 @@ from pytorch3d import _C # pyre-fixme[21]: Could not find name `_C` in `pytorch from pytorch3d.renderer.mesh.rasterize_meshes import pix_to_non_square_ndc -# Maxinum number of faces per bins for +# Maximum number of faces per bins for # coarse-to-fine rasterization kMaxPointsPerBin = 22 @@ -59,7 +59,7 @@ def rasterize_points( set it heuristically based on the shape of the input. This should not affect the output, but can affect the speed of the forward pass. points_per_bin: Only applicable when using coarse-to-fine rasterization - (bin_size > 0); this is the maxiumum number of points allowed within each + (bin_size > 0); this is the maximum number of points allowed within each bin. If more than this many points actually fall into a bin, an error will be raised. This should not affect the output values, but can affect the memory usage in the forward pass. @@ -95,7 +95,7 @@ def rasterize_points( radius = _format_radius(radius, pointclouds) # In the case that H != W use the max image size to set the bin_size - # to accommodate the num bins constraint in the coarse rasteizer. + # to accommodate the num bins constraint in the coarse rasterizer. # If the ratio of H:W is large this might cause issues as the smaller # dimension will have fewer bins. # TODO: consider a better way of setting the bin size. @@ -276,7 +276,7 @@ def rasterize_points_python( # Support variable size radius for each point in the batch radius = _format_radius(radius, pointclouds) - # Intialize output tensors. + # Initialize output tensors. point_idxs = torch.full( (N, H, W, K), fill_value=-1, dtype=torch.int32, device=device ) diff --git a/pytorch3d/renderer/utils.py b/pytorch3d/renderer/utils.py index b940bd21..e714e563 100644 --- a/pytorch3d/renderer/utils.py +++ b/pytorch3d/renderer/utils.py @@ -76,7 +76,7 @@ class TensorAccessor(nn.Module): if hasattr(self.class_object, name): return self.class_object.__dict__[name][self.index] else: - msg = "Attribue %s not found on %r" + msg = "Attribute %s not found on %r" return AttributeError(msg % (name, self.class_object.__name__)) diff --git a/pytorch3d/structures/meshes.py b/pytorch3d/structures/meshes.py index 445264c0..b5fc1baf 100644 --- a/pytorch3d/structures/meshes.py +++ b/pytorch3d/structures/meshes.py @@ -22,13 +22,13 @@ class Meshes(object): - has specific batch dimension. Packed - no batch dimension. - - has auxillary variables used to index into the padded representation. + - has auxiliary variables used to index into the padded representation. Example: Input list of verts V_n = [[V_1], [V_2], ... , [V_N]] where V_1, ... , V_N are the number of verts in each mesh and N is the - numer of meshes. + number of meshes. Input list of faces F_n = [[F_1], [F_2], ... , [F_N]] where F_1, ... , F_N are the number of faces in each mesh. @@ -100,7 +100,7 @@ class Meshes(object): | ]) | ----------------------------------------------------------------------------- - Auxillary variables for packed representation + Auxiliary variables for packed representation Name | Size | Example from above -------------------------------|---------------------|----------------------- @@ -139,7 +139,7 @@ class Meshes(object): # SPHINX IGNORE From the faces, edges are computed and have packed and padded - representations with auxillary variables. + representations with auxiliary variables. E_n = [[E_1], ... , [E_N]] where E_1, ... , E_N are the number of unique edges in each mesh. @@ -894,7 +894,7 @@ class Meshes(object): def _compute_packed(self, refresh: bool = False): """ Computes the packed version of the meshes from verts_list and faces_list - and sets the values of auxillary tensors. + and sets the values of auxiliary tensors. Args: refresh: Set to True to force recomputation of packed representations. @@ -1022,7 +1022,7 @@ class Meshes(object): # Remove duplicate edges: convert each edge (v0, v1) into an # integer hash = V * v0 + v1; this allows us to use the scalar version of # unique which is much faster than edges.unique(dim=1) which is very slow. - # After finding the unique elements reconstruct the vertex indicies as: + # After finding the unique elements reconstruct the vertex indices as: # (v0, v1) = (hash / V, hash % V) # The inverse maps from unique_edges back to edges: # unique_edges[inverse_idxs] == edges diff --git a/pytorch3d/structures/pointclouds.py b/pytorch3d/structures/pointclouds.py index e5194d24..929f6605 100644 --- a/pytorch3d/structures/pointclouds.py +++ b/pytorch3d/structures/pointclouds.py @@ -18,7 +18,7 @@ class Pointclouds(object): - has specific batch dimension. Packed - no batch dimension. - - has auxillary variables used to index into the padded representation. + - has auxiliary variables used to index into the padded representation. Example @@ -61,7 +61,7 @@ class Pointclouds(object): | ]) | ----------------------------------------------------------------------------- - Auxillary variables for packed representation + Auxiliary variables for packed representation Name | Size | Example from above -------------------------------|---------------------|----------------------- @@ -265,7 +265,7 @@ class Pointclouds(object): ) if d.device != self.device: raise ValueError( - "All auxillary inputs must be on the same device as the points." + "All auxiliary inputs must be on the same device as the points." ) if p > 0: if d.dim() != 2: @@ -291,7 +291,7 @@ class Pointclouds(object): ) if aux_input.device != self.device: raise ValueError( - "All auxillary inputs must be on the same device as the points." + "All auxiliary inputs must be on the same device as the points." ) aux_input_C = aux_input.shape[2] return None, aux_input, aux_input_C @@ -508,7 +508,7 @@ class Pointclouds(object): def padded_to_packed_idx(self): """ Return a 1D tensor x with length equal to the total number of points - such that points_packed()[i] is element x[i] of the flattened padded + such that points_packed()[i] is element x[i] of the flattened padded representation. The packed representation can be calculated as follows. @@ -573,7 +573,7 @@ class Pointclouds(object): def _compute_packed(self, refresh: bool = False): """ Computes the packed version from points_list, normals_list and - features_list and sets the values of auxillary tensors. + features_list and sets the values of auxiliary tensors. Args: refresh: Set to True to force recomputation of packed @@ -910,7 +910,7 @@ class Pointclouds(object): **neighborhood_size**: The size of the neighborhood used to estimate the geometry around each point. **disambiguate_directions**: If `True`, uses the algorithm from [1] to - ensure sign consistency of the normals of neigboring points. + ensure sign consistency of the normals of neighboring points. **normals**: A tensor of normals for each input point of shape `(minibatch, num_point, 3)`. If `pointclouds` are of `Pointclouds` class, returns a padded tensor. @@ -985,7 +985,7 @@ class Pointclouds(object): Args: new_points_padded: FloatTensor of shape (N, P, 3) new_normals_padded: (optional) FloatTensor of shape (N, P, 3) - new_features_padded: (optional) FloatTensors of shape (N, P, C) + new_features_padded: (optional) FloatTensor of shape (N, P, C) Returns: Pointcloud with updated padded representations diff --git a/pytorch3d/structures/volumes.py b/pytorch3d/structures/volumes.py index 928c9fac..7e4e633c 100644 --- a/pytorch3d/structures/volumes.py +++ b/pytorch3d/structures/volumes.py @@ -77,7 +77,7 @@ class Volumes(object): World coordinates: - These define the locations of the centers of the volume cells in the world coordinates. - - They are specifiied with the following mapping that converts + - They are specified with the following mapping that converts points `x_local` in the local coordinates to points `x_world` in the world coordinates: ``` diff --git a/pytorch3d/transforms/rotation_conversions.py b/pytorch3d/transforms/rotation_conversions.py index f2bfaa1b..b9050089 100644 --- a/pytorch3d/transforms/rotation_conversions.py +++ b/pytorch3d/transforms/rotation_conversions.py @@ -511,7 +511,7 @@ def quaternion_to_axis_angle(quaternions): def rotation_6d_to_matrix(d6: torch.Tensor) -> torch.Tensor: """ Converts 6D rotation representation by Zhou et al. [1] to rotation matrix - using Gram--Schmidt orthogonalisation per Section B of [1]. + using Gram--Schmidt orthogonalization per Section B of [1]. Args: d6: 6D rotation representation, of size (*, 6) diff --git a/pytorch3d/transforms/transform3d.py b/pytorch3d/transforms/transform3d.py index 8cbb3e9d..c954e749 100644 --- a/pytorch3d/transforms/transform3d.py +++ b/pytorch3d/transforms/transform3d.py @@ -190,7 +190,7 @@ class Transform3d: def compose(self, *others): """ - Return a new Transform3d with the tranforms to compose stored as + Return a new Transform3d with the transforms to compose stored as an internal list. Args: @@ -254,7 +254,7 @@ class Transform3d: independently without composing them. Returns: - A new Transform3D object contaning the inverse of the original + A new Transform3D object containing the inverse of the original transformation. """ @@ -302,7 +302,7 @@ class Transform3d: Args: points: Tensor of shape (P, 3) or (N, P, 3) eps: If eps!=None, the argument is used to clamp the - last coordinate before peforming the final division. + last coordinate before performing the final division. The clamping corresponds to: last_coord := (last_coord.sign() + (last_coord==0)) * torch.clamp(last_coord.abs(), eps), @@ -681,7 +681,7 @@ def _broadcast_bmm(a, b): b: torch tensor of shape (N, K, K) Returns: - a and b broadcast multipled. The output batch dimension is max(N, M). + a and b broadcast multiplied. The output batch dimension is max(N, M). To broadcast transforms across a batch dimension if M != N then expect that either M = 1 or N = 1. The tensor with batch dimension 1 is diff --git a/pytorch3d/vis/plotly_vis.py b/pytorch3d/vis/plotly_vis.py index 22e510e5..45d91c82 100644 --- a/pytorch3d/vis/plotly_vis.py +++ b/pytorch3d/vis/plotly_vis.py @@ -567,7 +567,7 @@ def _add_pointcloud_trace( pointclouds: Pointclouds object to render. It can be batched. trace_name: name to label the trace with. subplot_idx: identifies the subplot, with 0 being the top left. - ncols: the number of sublpots per row. + ncols: the number of subplots per row. max_points_per_pointcloud: the number of points to render, which are randomly sampled. marker_size: the size of the rendered points """ @@ -648,7 +648,7 @@ def _add_camera_trace( cameras: the Cameras object to render. It can be batched. trace_name: name to label the trace with. subplot_idx: identifies the subplot, with 0 being the top left. - ncols: the number of sublpots per row. + ncols: the number of subplots per row. camera_scale: the size of the wireframe used to render the Cameras object. """ cam_wires = get_camera_wireframe(camera_scale).to(cameras.device) diff --git a/tests/test_io_obj.py b/tests/test_io_obj.py index f0e6a2d7..d5b331de 100644 --- a/tests/test_io_obj.py +++ b/tests/test_io_obj.py @@ -328,7 +328,9 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase): with self.assertRaises(ValueError) as err: load_obj(obj_file) - self.assertTrue("Face vertices can ony have 3 properties" in str(err.exception)) + self.assertTrue( + "Face vertices can only have 3 properties" in str(err.exception) + ) def test_load_obj_error_invalid_vertex_indices(self): obj_file = "\n".join( @@ -631,7 +633,7 @@ class TestMeshObjIO(TestCaseMixin, unittest.TestCase): self.assertTrue(aux.normals is None) self.assertTrue(aux.verts_uvs is None) - def test_load_obj_mlt_no_image(self): + def test_load_obj_mtl_no_image(self): obj_filename = "obj_mtl_no_image/model.obj" filename = os.path.join(DATA_DIR, obj_filename) R = 8 diff --git a/tests/test_io_ply.py b/tests/test_io_ply.py index b60482fd..90efb1ff 100644 --- a/tests/test_io_ply.py +++ b/tests/test_io_ply.py @@ -317,7 +317,7 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase): file.close() self.assertLess(lengths[False], lengths[True], "ascii should be longer") - def test_heterogenous_property(self): + def test_heterogeneous_property(self): ply_file_ascii = "\n".join( [ "ply", @@ -670,7 +670,7 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase): with self.assertRaisesRegex(ValueError, msg): _load_ply_raw(StringIO("\n".join(lines2))) - # Heterogenous cases + # Heterogeneous cases lines2 = lines.copy() lines2.insert(4, "property double y") diff --git a/tests/test_points_alignment.py b/tests/test_points_alignment.py index b4377319..31da12e9 100644 --- a/tests/test_points_alignment.py +++ b/tests/test_points_alignment.py @@ -155,7 +155,7 @@ class TestICP(TestCaseMixin, unittest.TestCase): self.assertClose(s_init, s, atol=atol) self.assertClose(Xt_init, Xt, atol=atol) - def test_heterogenous_inputs(self, batch_size=10): + def test_heterogeneous_inputs(self, batch_size=10): """ Tests whether we get the same result when running ICP on a set of randomly-sized Pointclouds and on their padded versions. diff --git a/tests/test_points_to_volumes.py b/tests/test_points_to_volumes.py index c72deeb9..e169f585 100644 --- a/tests/test_points_to_volumes.py +++ b/tests/test_points_to_volumes.py @@ -230,9 +230,9 @@ class TestPointsToVolumes(TestCaseMixin, unittest.TestCase): def test_from_point_cloud(self, interp_mode="trilinear"): """ Generates a volume from a random point cloud sampled from faces - of a 3D cube. Since each side of the cube is homogenously colored with + of a 3D cube. Since each side of the cube is homogeneously colored with a different color, this should result in a volume with a - predefined homogenous color of the cells along its borders + predefined homogeneous color of the cells along its borders and black interior. The test is run for both cube and non-cube shaped volumes. """ diff --git a/tests/test_rasterize_points.py b/tests/test_rasterize_points.py index 77d2f84e..0ffb94fe 100644 --- a/tests/test_rasterize_points.py +++ b/tests/test_rasterize_points.py @@ -511,7 +511,7 @@ class TestRasterizePoints(TestCaseMixin, unittest.TestCase): ) # Note that the order is only deterministic here for CUDA if all points # fit in one chunk. This will the the case for this small example, but - # to properly exercise coordianted writes among multiple chunks we need + # to properly exercise coordinated writes among multiple chunks we need # to use a bigger test case. bin_points_expected[0, 0, 1, :2] = torch.tensor([0, 3]) bin_points_expected[0, 1, 0, 0] = torch.tensor([2]) diff --git a/tests/test_rasterize_rectangle_images.py b/tests/test_rasterize_rectangle_images.py index f732db29..4c9e4cae 100644 --- a/tests/test_rasterize_rectangle_images.py +++ b/tests/test_rasterize_rectangle_images.py @@ -62,7 +62,7 @@ verts0 = torch.tensor( ) faces0 = torch.tensor([[1, 0, 2], [4, 3, 5]], dtype=torch.int64) -# Points for a simple pointcloud. Get the vertices from a +# Points for a simple point cloud. Get the vertices from a # torus and apply rotations such that the points are no longer # symmerical in X/Y. torus_mesh = torus(r=0.25, R=1.0, sides=5, rings=2 * 5) @@ -771,7 +771,7 @@ class TestRasterizeRectangleImagesPointclouds(TestCaseMixin, unittest.TestCase): def test_render_pointcloud(self): """ - Test a textured poincloud is rendered correctly in a non square image. + Test a textured point cloud is rendered correctly in a non square image. """ device = torch.device("cuda:0") pointclouds = Pointclouds( diff --git a/tests/test_raymarching.py b/tests/test_raymarching.py index 9b77b01b..93952349 100644 --- a/tests/test_raymarching.py +++ b/tests/test_raymarching.py @@ -16,7 +16,7 @@ class TestRaymarching(TestCaseMixin, unittest.TestCase): n_rays=10, n_pts_per_ray=9, device="cuda", dtype=torch.float32 ): """ - Generate a batch of ray points with features, densities, and z-coodinates + Generate a batch of ray points with features, densities, and z-coordinates such that their EmissionAbsorption renderring results in feature renders `features_gt`, depth renders `depths_gt`, and opacity renders `opacities_gt`. diff --git a/tests/test_render_meshes.py b/tests/test_render_meshes.py index 8f8bd975..c585ecd1 100644 --- a/tests/test_render_meshes.py +++ b/tests/test_render_meshes.py @@ -1052,7 +1052,7 @@ class TestRenderMeshes(TestCaseMixin, unittest.TestCase): images[0, ...].sum().backward() fragments = rasterizer(mesh, raster_settings=raster_settings) - # Some of the bary coordinates are outisde the + # Some of the bary coordinates are outside the # [0, 1] range as expected because the blur is > 0 self.assertTrue(fragments.bary_coords.ge(1.0).any()) self.assertIsNotNone(atlas.grad) diff --git a/tests/test_render_volumes.py b/tests/test_render_volumes.py index 5ff22fc7..0dac3e51 100644 --- a/tests/test_render_volumes.py +++ b/tests/test_render_volumes.py @@ -531,7 +531,7 @@ class TestRenderVolumes(TestCaseMixin, unittest.TestCase): # get the EA raymarcher raymarcher = EmissionAbsorptionRaymarcher() - # intialize the renderer + # initialize the renderer renderer = VolumeRenderer( raysampler=raysampler, raymarcher=raymarcher, @@ -574,8 +574,8 @@ class TestRenderVolumes(TestCaseMixin, unittest.TestCase): def test_rotating_cube_volume_render(self): """ Generates 4 renders of 4 sides of a volume representing a 3D cube. - Since each side of the cube is homogenously colored with - a different color, this should result in 4 images of homogenous color + Since each side of the cube is homogeneously colored with + a different color, this should result in 4 images of homogeneous color with the depth of each pixel equal to a constant. """ diff --git a/tests/test_so3.py b/tests/test_so3.py index 315e11da..b7958e4f 100644 --- a/tests/test_so3.py +++ b/tests/test_so3.py @@ -148,8 +148,8 @@ class TestSO3(TestCaseMixin, unittest.TestCase): `so3_exponential_map(so3_log_map(so3_exponential_map(log_rot))) == so3_exponential_map(log_rot)` for a randomly generated batch of rotation matrix logarithms `log_rot`. - Unlike `test_so3_log_to_exp_to_log`, this test allows to check the - correctness of converting `log_rot` which contains values > math.pi. + Unlike `test_so3_log_to_exp_to_log`, this test checks the + correctness of converting a `log_rot` which contains values > math.pi. """ log_rot = 2.0 * TestSO3.init_log_rot(batch_size=batch_size) # check also the singular cases where rot. angle = {0, pi, 2pi, 3pi} diff --git a/website/pages/tutorials/index.js b/website/pages/tutorials/index.js index 21a3a54c..bdd5dcd4 100644 --- a/website/pages/tutorials/index.js +++ b/website/pages/tutorials/index.js @@ -28,7 +28,7 @@ class TutorialHome extends React.Component {

Here you can learn about the structure and applications of - Pytorch3D from examples which are in the form of ipython + PyTorch3D from examples which are in the form of ipython notebooks.

Run interactively