1. 17 Aug, 2021 1 commit
    • Jeremy Reizenstein's avatar
      let build tests run in conda · ae1387b5
      Jeremy Reizenstein authored
      Summary: Much of the code is actually available during the conda tests, as long as we look in the right place. We enable some of them.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D30249357
      
      fbshipit-source-id: 01c57b6b8c04442237965f23eded594aeb90abfb
      ae1387b5
  2. 12 Aug, 2021 2 commits
    • Nikhila Ravi's avatar
      Ball Query · 103da633
      Nikhila Ravi authored
      Summary:
      Implementation of ball query from PointNet++.  This function is similar to KNN (find the neighbors in p2 for all points in p1). These are the key differences:
      -  It will return the **first** K neighbors within a specified radius as opposed to the **closest** K neighbors.
      - As all the points in p2 do not need to be considered to find the closest K, the algorithm is much faster than KNN when p2 has a large number of points.
      - The neighbors are not sorted
      - Due to the radius threshold it is not guaranteed that there will be K neighbors even if there are more than K points in p2.
      - The padding value for `idx` is -1 instead of 0.
      
      # Note:
      - Some of the code is very similar to KNN so it could be possible to modify the KNN forward kernels to support ball query.
      - Some users might want to use kNN with ball query - for this we could provide a wrapper function around the current `knn_points` which enables applying the radius threshold afterwards as an alternative. This could be called `ball_query_knn`.
      
      Reviewed By: jcjohnson
      
      Differential Revision: D30261362
      
      fbshipit-source-id: 66b6a7e0114beff7164daf7eba21546ff41ec450
      103da633
    • Jeremy Reizenstein's avatar
      Test website metadata · e5c58a8a
      Jeremy Reizenstein authored
      Summary: New test that notes and tutorials are listed in the website metadata, so that they will be included in the website build.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D30223799
      
      fbshipit-source-id: 2dca9730b54e68da2fd430a7b47cb7e18814d518
      e5c58a8a
  3. 09 Aug, 2021 1 commit
    • Nikhila Ravi's avatar
      Fix to allow cameras in the renderer forward pass · 80411783
      Nikhila Ravi authored
      Summary: Fix to resolve GitHub issue #796 - the cameras were being passed in the renderer forward pass instead of at initialization. The rasterizer was correctly using the cameras passed in the `kwargs` for the projection, but the `cameras` are still part of the `kwargs` for the `get_screen_to_ndc_transform` and `get_ndc_to_screen_transform` functions which is causing issues about duplicate arguments.
      
      Reviewed By: bottler
      
      Differential Revision: D30175679
      
      fbshipit-source-id: 547e88d8439456e728fa2772722df5fa0fe4584d
      80411783
  4. 02 Aug, 2021 1 commit
    • Georgia Gkioxari's avatar
      NDC/screen cameras API fix, compatibility with renderer · 0c32f094
      Georgia Gkioxari authored
      Summary:
      API fix for NDC/screen cameras and compatibility with PyTorch3D renderers.
      
      With this new fix:
      * Users can define cameras and `transform_points` under any coordinate system conventions. The transformation applies the camera K and RT to the input points, not regarding for PyTorch3D conventions. So this makes cameras completely independent from PyTorch3D renderer.
      
      * Cameras can be defined either in NDC space or screen space. For existing ones, FoV cameras are in NDC space. Perspective/Orthographic can be defined in NDC or screen space.
      
      * The interface with PyTorch3D renderers happens through `transform_points_ndc` which transforms points to the NDC space and assumes that input points are provided according to PyTorch3D conventions.
      
      * Similarly, `transform_points_screen` transforms points to screen space and again assumes that input points are under PyTorch3D conventions.
      
      * For Orthographic/Perspective cameras, if they are defined in screen space, the `get_ndc_camera_transform` allows points to be converted to NDC for use for the renderers.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D26932657
      
      fbshipit-source-id: 1a964e3e7caa54d10c792cf39c4d527ba2fb2e79
      0c32f094
  5. 19 Jul, 2021 2 commits
    • Jeremy Reizenstein's avatar
      restore build tests · 9e8d91eb
      Jeremy Reizenstein authored
      Summary: A bad env var check meant these tests were not being run. Fix that, and fix the copyright test for the new message format.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29734562
      
      fbshipit-source-id: a1a9bb68901b09c71c7b4ff81a04083febca8d50
      9e8d91eb
    • Alexey Sidnev's avatar
      Replace `torch.det()` with manual implementation for 3x3 matrix · bcee361d
      Alexey Sidnev authored
      Summary:
      # Background
      There is an unstable error during training (it can happen after several minutes or after several hours).
      The error is connected to `torch.det()` function in  `_check_valid_rotation_matrix()`.
      
      if I remove the function `torch.det()` in `_check_valid_rotation_matrix()` or remove the whole functions `_check_valid_rotation_matrix()` the error is disappeared (D29555876).
      
      # Solution
      Replace `torch.det()` with manual implementation for 3x3 matrix.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29655924
      
      fbshipit-source-id: 41bde1119274a705ab849751ece28873d2c45155
      bcee361d
  6. 13 Jul, 2021 1 commit
    • Roman Shapovalov's avatar
      Adding utility methods to TensorProperties · 0c02ae90
      Roman Shapovalov authored
      Summary:
      Context: in the code we are releasing with CO3D dataset, we use  `cuda()` on TensorProperties like Pointclouds and Cameras where we recursively move batch to a GPU. It would be good to push it to a release so we don’t need to depend on the nightly build.
      
      Additionally, I aligned the logic of `.to("cuda")` without device index to the one of `torch.Tensor` where the current device is populated to index. It should not affect any actual use cases but some tests had to be changed.
      
      Reviewed By: bottler
      
      Differential Revision: D29659529
      
      fbshipit-source-id: abe58aeaca14bacc68da3e6cf5ae07df3353e3ce
      0c02ae90
  7. 10 Jul, 2021 1 commit
  8. 09 Jul, 2021 1 commit
    • Patrick Labatut's avatar
      Use rotation matrices for OpenCV / PyTorch3D conversions · fef5bcd8
      Patrick Labatut authored
      Summary: Use rotation matrices for OpenCV / PyTorch3D conversions: this avoids hiding issues with conversions to / from axis-angle vectors and ensure new conversion functions have a consistent interface.
      
      Reviewed By: bottler, classner
      
      Differential Revision: D29634099
      
      fbshipit-source-id: 40b28357914eb563fedea60a965dcf69e848ccfa
      fef5bcd8
  9. 01 Jul, 2021 2 commits
    • Jeremy Reizenstein's avatar
      points2volumes benchmark run alone · 62ff77b4
      Jeremy Reizenstein authored
      Summary: Enable this benchmark to be run on its own, like others.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29522846
      
      fbshipit-source-id: c7b3b5c9a0fcdeeb79d8b2ec197684b4380aa547
      62ff77b4
    • Jeremy Reizenstein's avatar
      lint fixes · 61754b2f
      Jeremy Reizenstein authored
      Summary: Fixing recent lint problems.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29522647
      
      fbshipit-source-id: 9bd89fbfa512ecd7359ec355cf12b16fb7024b47
      61754b2f
  10. 28 Jun, 2021 2 commits
    • Jeremy Reizenstein's avatar
      work with old linalg · b8790474
      Jeremy Reizenstein authored
      Summary: solve and lstsq have moved around in torch. Cope with both.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29302316
      
      fbshipit-source-id: b34f0b923e90a357f20df359635929241eba6e74
      b8790474
    • Patrick Labatut's avatar
      Deprecate so3_exponential_map · 5284de6e
      Patrick Labatut authored
      Summary: Deprecate the `so3_exponential_map()` function in favor of its alias `so3_exp_map()`: this aligns with the naming of `so3_log_map()` and the recently introduced `se3_exp_map()` / `se3_log_map()` pair.
      
      Reviewed By: bottler
      
      Differential Revision: D29329966
      
      fbshipit-source-id: b6f60b9e86b2995f70b1fbeb16f9feea05c55de9
      5284de6e
  11. 24 Jun, 2021 2 commits
    • Nikhila Ravi's avatar
      Save UV texture with obj mesh · 542e2e7c
      Nikhila Ravi authored
      Summary: Add functionality to to save an `.obj` file with associated UV textures: `.png` image and `.mtl` file as well as saving verts_uvs and faces_uvs to the `.obj` file.
      
      Reviewed By: bottler
      
      Differential Revision: D29337562
      
      fbshipit-source-id: 86829b40dae9224088b328e7f5a16eacf8582eb5
      542e2e7c
    • Georgia Gkioxari's avatar
      refactor laplacian matrices · 07a5a68d
      Georgia Gkioxari authored
      Summary:
      Refactor of all functions to compute laplacian matrices in one file.
      Support for:
      * Standard Laplacian
      * Cotangent Laplacian
      * Norm Laplacian
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D29297466
      
      fbshipit-source-id: b96b88915ce8ef0c2f5693ec9b179fd27b70abf9
      07a5a68d
  12. 23 Jun, 2021 1 commit
  13. 22 Jun, 2021 2 commits
    • Patrick Labatut's avatar
      License lint codebase · af93f348
      Patrick Labatut authored
      Summary: License lint codebase
      
      Reviewed By: theschnitz
      
      Differential Revision: D29001799
      
      fbshipit-source-id: 5c59869911785b0181b1663bbf430bc8b7fb2909
      af93f348
    • Patrick Labatut's avatar
      Lint codebase · 7e43f29d
      Patrick Labatut authored
      Summary: Lint codebase
      
      Reviewed By: bottler
      
      Differential Revision: D29263057
      
      fbshipit-source-id: ac97f01d2a79fead3b09c2cbb21b50ce688a577d
      7e43f29d
  14. 21 Jun, 2021 7 commits
    • Jeremy Reizenstein's avatar
      remove requires_grad from random rotations · ce60d4b0
      Jeremy Reizenstein authored
      Summary: Because rotations and (rotation) quaternions live on curved manifolds, it doesn't make sense to optimize them directly. Having a prominent option to require gradient on random ones may cause people to try, and isn't particularly useful.
      
      Reviewed By: theschnitz
      
      Differential Revision: D29160734
      
      fbshipit-source-id: fc9e320672349fe334747c5b214655882a460a62
      ce60d4b0
    • Jeremy Reizenstein's avatar
      Test gltf texture without renderer. · 31c448a9
      Jeremy Reizenstein authored
      Summary:
      Change the cow gltf loading test to validate the texture values and not to validate the renderer output because it has an unstable pixel.
      
      Also a couple of lints.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29131260
      
      fbshipit-source-id: 5e11f066a2a638588aacb09776cc842173ef669f
      31c448a9
    • Jeremy Reizenstein's avatar
      Fix save_ply with noncontiguous faces · 354a1808
      Jeremy Reizenstein authored
      Summary: As noted in #710, save_ply was failing with some values of the faces tensor. It was assuming the faces were contiguous in using view() to change them. Here we avoid doing that.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D29159655
      
      fbshipit-source-id: 47214a7ce915bab8d81f109c2b97cde464fd57d8
      354a1808
    • David Novotny's avatar
      Conversion from OpenCV cameras · 8006842f
      David Novotny authored
      Summary: Implements a conversion function between OpenCV and PyTorch3D cameras.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D28992470
      
      fbshipit-source-id: dbcc9f213ec293c2f6938261c704aea09aad3c90
      8006842f
    • David Novotny's avatar
      SE3 exponential and logarithm maps. · b2ac2655
      David Novotny authored
      Summary:
      Implements the SE3 logarithm and exponential maps.
      (this is a second part of the split of D23326429)
      
      Outputs of `bm_se3`:
      ```
      Benchmark         Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      SE3_EXP_1                738             885            678
      SE3_EXP_10               717             877            698
      SE3_EXP_100              718             847            697
      SE3_EXP_1000             729            1181            686
      --------------------------------------------------------------------------------
      
      Benchmark          Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      SE3_LOG_1               1451            2267            345
      SE3_LOG_10              2185            2453            229
      SE3_LOG_100             2217            2448            226
      SE3_LOG_1000            2455            2599            204
      --------------------------------------------------------------------------------
      ```
      
      Reviewed By: patricklabatut
      
      Differential Revision: D27852557
      
      fbshipit-source-id: e42ccc9cfffe780e9cad24129de15624ae818472
      b2ac2655
    • David Novotny's avatar
      SO3 improvements for stable gradients. · 9f14e82b
      David Novotny authored
      Summary:
      Improves so3 functions to make gradient computation stable:
      - Instead of `torch.acos`, uses `acos_linear_extrapolation` which has finite gradients of reasonable magnitude for all inputs.
      - Adds tests for the latter.
      
      The tests of the finiteness of the gradient in `test_so3_exp_singularity`, `test_so3_exp_singularity`, `test_so3_cos_bound` would fail if the `so3` functions would call `torch.acos` instead of `acos_linear_extrapolation`.
      
      Reviewed By: bottler
      
      Differential Revision: D23326429
      
      fbshipit-source-id: dc296abf2ae3ddfb3942c8146621491a9cb740ee
      9f14e82b
    • David Novotny's avatar
      Linearly extrapolated acos. · dd45123f
      David Novotny authored
      Summary:
      Implements a backprop-safe version of `torch.acos` that linearly extrapolates the function outside bounds.
      
      Below is a plot of the extrapolated acos for different bounds:
      {F611339485}
      
      Reviewed By: bottler, nikhilaravi
      
      Differential Revision: D27945714
      
      fbshipit-source-id: fa2e2385b56d6fe534338d5192447c4a3aec540c
      dd45123f
  15. 18 Jun, 2021 3 commits
  16. 17 Jun, 2021 1 commit
    • Patrick Labatut's avatar
      Increase code coverage of shader · a8610e9d
      Patrick Labatut authored
      Summary: Increase code coverage of shader and re-include them in code coverage test
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D29097503
      
      fbshipit-source-id: 2791989ee1562cfa193f3addea0ce72d6840614a
      a8610e9d
  17. 15 Jun, 2021 1 commit
    • Nikhila Ravi's avatar
      Bug fix in rendering clipped meshes · c75ca04c
      Nikhila Ravi authored
      Summary:
      There was a bug when `z_clip_value` is not None but there are no faces which are actually visible in the image due to culling.  In `rasterize_meshes.py` a function `convert_clipped_rasterization_to_original_faces` is called to convert the clipped face indices etc back to the unclipped versions, but the case where there is no clipping was not handled correctly.
      
      Fixes Github Issue #632
      
      Reviewed By: bottler
      
      Differential Revision: D29116150
      
      fbshipit-source-id: fae82a0b4848c84b3ed7c7b04ef5c9848352cf5c
      c75ca04c
  18. 14 Jun, 2021 2 commits
    • Nikhila Ravi's avatar
      Lighting broadcasting bug fix · bc8361fa
      Nikhila Ravi authored
      Summary: Fixed multiple issues with shape broadcasting in lighting, shading and blending and updated the tests.
      
      Reviewed By: bottler
      
      Differential Revision: D28997941
      
      fbshipit-source-id: d3ef93f979344076b1d9098a86178b4da63844c8
      bc8361fa
    • Patrick Labatut's avatar
      Increase code coverage of subdivide_meshes · 780e2315
      Patrick Labatut authored
      Summary: Increase code coverage of subdivide_meshes and re-include it in code coverage test
      
      Reviewed By: bottler
      
      Differential Revision: D29097476
      
      fbshipit-source-id: 3403ae38a90c4b53f24188eed11faae202a235b5
      780e2315
  19. 11 Jun, 2021 2 commits
    • Nikhila Ravi's avatar
      Culling to frustrum bug fix · a0f79318
      Nikhila Ravi authored
      Summary:
      When `z_clip_value = None` and faces are outside the view frustum the shape of one of the tensors in `clip.py` is incorrect.
      
      `faces_num_clipped_verts` should be (F,) but it was (F,3).  Added a new test to ensure this case is handled.
      
      Reviewed By: bottler
      
      Differential Revision: D29051282
      
      fbshipit-source-id: 5f4172ba4d4a75d928404dde9abf48aef18c68bd
      a0f79318
    • Nikhila Ravi's avatar
      textures dimension check · ef162539
      Nikhila Ravi authored
      Summary:
      When textures are set on `Meshes` we need to check if the dimensions actually match that of the verts/faces in the mesh. There was a github issue where someone tried to set the attribute after construction of the `Meshes` object and ran into an error when trying to sample textures.
      
      The desired usage is to initialize the class with the textures (not set an attribute afterwards) but in any case we need to check the dimensions match before sampling textures.
      
      Reviewed By: bottler
      
      Differential Revision: D29020249
      
      fbshipit-source-id: 9fb8a5368b83c9ec53652df92b96fc8b2613f591
      ef162539
  20. 09 Jun, 2021 5 commits
    • Patrick Labatut's avatar
      Make Transform3d.to() not ignore dtype · 44508ed0
      Patrick Labatut authored
      Summary: Make Transform3d.to() not ignore a different dtype when device is the same and no copy is requested. Fix other methods where dtype is ignored.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28981171
      
      fbshipit-source-id: 4528e6092f4a693aecbe8131ede985fca84e84cf
      44508ed0
    • Patrick Labatut's avatar
      Tidy uses of torch.device in Volumes · 1f9661e1
      Patrick Labatut authored
      Summary:
      Tidy uses of `torch.device` in `Volumes`:
      - Allow `str` or `torch.device` in `Volumes.to()` method
      - Consistently use `torch.device` for internal type
      - Fix comparison of devices
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28970876
      
      fbshipit-source-id: c640cc22ced684a54cc450ac38a0f4b3435d47be
      1f9661e1
    • Patrick Labatut's avatar
      Tidy uses of torch.device in Pointclouds · 1db40ac5
      Patrick Labatut authored
      Summary:
      Tidy uses of `torch.device` in `Pointclouds`:
      - Allow `str` or `torch.device` in `Pointclouds.to()` method
      - Consistently use `torch.device` for internal type
      - Fix comparison of devices
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28970221
      
      fbshipit-source-id: 3ca7104d4c0d9b20b0cff4f00e3ce931c5f1528a
      1db40ac5
    • Patrick Labatut's avatar
      Tidy uses of torch.device in Meshes · 633d66f1
      Patrick Labatut authored
      Summary:
      Tidy uses of `torch.device` in `Meshes`:
      - Allow `str` or `torch.device` in `Meshes.to()` method
      - Consistently use `torch.device` for internal type
      - Fix comparison of devices
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28969461
      
      fbshipit-source-id: 16d3c1f5458954bb11fdf0efea88542e94dccd7a
      633d66f1
    • Patrick Labatut's avatar
      Tidy uses of torch.device in Transform3d · 13a0110b
      Patrick Labatut authored
      Summary:
      Tidy uses of `torch.device` in `Transforms3d`:
      - Allow `str` or `torch.device` in user-facing methods
      - Consistently use `torch.device` for internal types
      - Fix comparison of devices
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28929486
      
      fbshipit-source-id: bd1d6cc7ede3d8fd549fd3224a9b07eec53f8164
      13a0110b