1. 04 Dec, 2023 1 commit
    • Jeremy Reizenstein's avatar
      lint · 83bacda8
      Jeremy Reizenstein authored
      Summary: Fix recent flake complaints
      
      Reviewed By: MichaelRamamonjisoa
      
      Differential Revision: D51811912
      
      fbshipit-source-id: 65183f5bc7058da910e4d5a63b2250ce8637f1cc
      83bacda8
  2. 20 Feb, 2023 1 commit
  3. 25 May, 2022 1 commit
    • Jeremy Reizenstein's avatar
      move targets · 34f648ed
      Jeremy Reizenstein authored
      Summary: Move testing targets from pytorch3d/tests/TARGETS to pytorch3d/TARGETS.
      
      Reviewed By: shapovalov
      
      Differential Revision: D36186940
      
      fbshipit-source-id: a4c52c4d99351f885e2b0bf870532d530324039b
      34f648ed
  4. 11 Apr, 2022 4 commits
    • Krzysztof Chalupka's avatar
      Submesh 3/n: Add submeshing functionality · 050f650a
      Krzysztof Chalupka authored
      Summary:
      Copypasting the docstring:
      ```
              Split a mesh into submeshes, defined by face indices of the original Meshes object.
      
              Args:
                face_indices:
                  Let the original mesh have verts_list() of length N.
                  Can be either
                    - List of length N. The n-th element is a list of length num_submeshes_n
                      (empty lists are allowed). Each element of the n-th sublist is a LongTensor
                      of length num_faces.
                    - List of length N. The n-th element is a possibly empty padded LongTensor of
                      shape (num_submeshes_n, max_num_faces).
      
              Returns:
                Meshes object with selected submeshes. The submesh tensors are cloned.
      
              Currently submeshing only works with no textures or with the TexturesVertex texture.
      
              Example:
      
              Take a Meshes object `cubes` with 4 meshes, each a translated cube. Then:
                  * len(cubes) is 4, len(cubes.verts_list()) is 4, len(cubes.faces_list()) is 4,
                  * [cube_verts.size for cube_verts in cubes.verts_list()] is [8, 8, 8, 8],
                  * [cube_faces.size for cube_faces in cubes.faces_list()] if [6, 6, 6, 6],
      
              Now let front_facet, top_and_bottom, all_facets be LongTensors of
              sizes (2), (4), and (12), each picking up a number of facets of a cube by specifying
              the appropriate triangular faces.
      
              Then let `subcubes = cubes.submeshes([[front_facet, top_and_bottom], [], [all_facets], []])`.
                  * len(subcubes) is 3.
                  * subcubes[0] is the front facet of the cube contained in cubes[0].
                  * subcubes[1] is a mesh containing the (disconnected) top and bottom facets of cubes[0].
                  * subcubes[2] is a clone of cubes[2].
                  * There are no submeshes of cubes[1] and cubes[3] in subcubes.
                  * subcubes[0] and subcubes[1] are not watertight. subcubes[2] is.
      ```
      
      Reviewed By: bottler
      
      Differential Revision: D35440657
      
      fbshipit-source-id: 8a6d2d300ce226b5b9eb440688528b5e795195a1
      050f650a
    • Krzysztof Chalupka's avatar
      Submesh 2/n: to_sorted · 8596fcac
      Krzysztof Chalupka authored
      Summary:
      Sort a mesh's vertices in alphabetical order, and resort the face coords accordingly. Textured meshes are not supported yet, but will be added down the stack.
      
      This, togehter with mesh equality, can be used to compare two meshes in a way invariant to vertex permutations, as shown in the unit tests.
      
      We do not want the submeshing mechanism to guarantee any particular vertex order, leaving that up to the implementation, so we need this function for testing.
      
      Reviewed By: bottler
      
      Differential Revision: D35440656
      
      fbshipit-source-id: 5a4dd921fdb00625a33da08b5fea79e20ac6402c
      8596fcac
    • Krzysztof Chalupka's avatar
      Submesh 1/n: Implement mesh equality · 7f097b06
      Krzysztof Chalupka authored
      Summary: Adding a mesh equality operator. Two Meshes objects m1, m2 are equal iff their vertex lists, face lists, and normals lists are equal. Textures meshes are not supported yet, but will be added for vertex textures down the stack.
      
      Reviewed By: bottler, nikhilaravi
      
      Differential Revision: D35440655
      
      fbshipit-source-id: 69974a59c091416afdb2892896859a189f5ebf3a
      7f097b06
    • Krzysztof Chalupka's avatar
      Submesh 0/n: Default to empty Meshes · aab95575
      Krzysztof Chalupka authored
      Summary:
      The default behavior of Meshes (with verts=None, faces=None) throws an exception:
      ```
      meshes = Meshes()
      > ValueError: Verts and Faces must be either a list or a tensor with shape (batch_size, N, 3) where N is either the maximum number of verts or faces respectively.
      ```
      
      Instead, let's default to an empty mesh, following e.g. PyTorch:
      ```
      empty_tensor = torch.FloatTensor()
      > torch.tensor([])
      ```
      
      this change is backwards-compatible (you can still init with verts=[], faces=[]).
      
      Reviewed By: bottler, nikhilaravi
      
      Differential Revision: D35443453
      
      fbshipit-source-id: d638a8fef49a089bf0da6dd2201727b94ceb21ec
      aab95575
  5. 04 Jan, 2022 1 commit
    • Jeremy Reizenstein's avatar
      Update license for company name · 9eeb456e
      Jeremy Reizenstein authored
      Summary: Update all FB license strings to the new format.
      
      Reviewed By: patricklabatut
      
      Differential Revision: D33403538
      
      fbshipit-source-id: 97a4596c5c888f3c54f44456dc07e718a387a02c
      9eeb456e
  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. 24 Jun, 2021 1 commit
    • 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
  8. 22 Jun, 2021 1 commit
    • 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
  9. 09 Jun, 2021 1 commit
    • 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
  10. 07 May, 2021 2 commits
    • Jeremy Reizenstein's avatar
      avoid running tests twice · 0ca839cc
      Jeremy Reizenstein authored
      Summary: Avoid test files explicitly importing TestCase objects from each other, because doing so causes the tests to be discovered twice by unittest discover. This means moving a few static functions out of their classes. I noticed this while trying to fix failures from yesterday.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28194679
      
      fbshipit-source-id: ac6e6585603bd4ef9c098cdd56891d94f8923ba6
      0ca839cc
    • Jeremy Reizenstein's avatar
      test_meshes numeric fixes · e3624b4e
      Jeremy Reizenstein authored
      Summary:
      A couple of tests are failing in open source after my changes yesterday because of numerical issues calculating normals. In particular we have meshes with very few vertices and several faces, where the normals should be zero but end up non-negligible after F.normalize. I have no idea why the different environments produce different results, so that the tests are passing internally.
      
      An example. Consider a mesh with the following faces:
      ```
      tensor([[4, 0, 2],
              [4, 1, 2],
              [3, 1, 0],
              [1, 3, 1],
              [3, 0, 1],
              [4, 0, 0],
              [4, 0, 2]])
      ```
      At vertex 3, there is one zero-area face and there are two other faces, which are back-to-back with each other. This vertex should have zero normal. The open source calculation produces a small but nonzero normal which varies unpredictably with changes in scale/offset, which can cause test failures.
      
      In this diff, the main change is to increase the number of vertices to make this less likely to happen. Also a small change to init_mesh to make it not generate a batch of empty meshes.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D28220984
      
      fbshipit-source-id: 79fdc62e5f5f8836de5a3a9980cfd6fe44590359
      e3624b4e
  11. 04 May, 2021 3 commits
    • Jeremy Reizenstein's avatar
      has_verts_normals for Meshes · 66b97a0c
      Jeremy Reizenstein authored
      Summary: Add ability to ask a Meshes if it already has normals. If it does, then requesting normals will not trigger a calculation. MeshesFormatInterpreters will therefore be able to decide whether to save normals.
      
      Reviewed By: theschnitz, nikhilaravi
      
      Differential Revision: D27765261
      
      fbshipit-source-id: 7c87dbf999d5616d20f5eb2c01039ee5ff65a830
      66b97a0c
    • Jeremy Reizenstein's avatar
      Allow setting verts_normals on Meshes · 2bbca5f2
      Jeremy Reizenstein authored
      Summary: Add ability to set the vertex normals when creating a Meshes, so that the pluggable loaders can return them from a file.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D27765258
      
      fbshipit-source-id: b5ddaa00de3707f636f94d9f74d1da12ecce0608
      2bbca5f2
    • Jeremy Reizenstein's avatar
      avoid recalculating normals for simple move · 502f15ac
      Jeremy Reizenstein authored
      Summary: If offset_verts_ is used to move meshes with a single vector, the normals won't change so don't need to recalculate. I am planning to allow user-specified vertex normals. This change means that user-specified vertex normals won't get overwritten when they don't need to be.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D27765256
      
      fbshipit-source-id: f6e4d308ac9ac023030325cb75a18d39b966cf88
      502f15ac
  12. 22 Jan, 2021 1 commit
    • Jeremy Reizenstein's avatar
      Allow single offset in offset_verts · ddebdfbc
      Jeremy Reizenstein authored
      Summary:
      It is common when trying things out to want to move a whole mesh or point cloud by the same amount. Here we allow the offset functions to broadcast.
      
      Also add a sanity check to join_meshes_as_scene which it is easy to call wrongly.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D25980593
      
      fbshipit-source-id: cdf1568e1317e3b81ad94ed4e608ba7eef81290b
      ddebdfbc
  13. 15 Dec, 2020 1 commit
  14. 25 Aug, 2020 1 commit
    • Jeremy Reizenstein's avatar
      align_corners and padding for TexturesUV · e25ccab3
      Jeremy Reizenstein authored
      Summary:
      Allow, and make default, align_corners=True for texture maps. Allow changing the padding_mode and set the default to be "border" which produces more logical results. Some new documentation.
      
      The previous behavior corresponds to padding_mode="zeros" and align_corners=False.
      
      Reviewed By: gkioxari
      
      Differential Revision: D23268775
      
      fbshipit-source-id: 58d6229baa591baa69705bcf97471c80ba3651de
      e25ccab3
  15. 17 Aug, 2020 1 commit
  16. 03 Jul, 2020 1 commit
    • Georgia Gkioxari's avatar
      fix pts scale, save ply · 2f0fd601
      Georgia Gkioxari authored
      Summary:
      Fix:
      * Scaling of point clouds for scalars
      * save_ply compatible cat
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D22298609
      
      fbshipit-source-id: abe94a5b64baf325587202d20adfc36912cc1478
      2f0fd601
  17. 23 May, 2020 1 commit
    • Georgia Gkioxari's avatar
      update padded in meshes · 1fb97f9c
      Georgia Gkioxari authored
      Summary:
      Three changes to Meshes
      
      1. `num_verts_per_mesh` and `num_faces_per_mesh` are assigned at construction time and are returned without the need for `compute_packed`
      2. `update_padded` updates `verts_padded` and shallow copies faces list and faces_padded and existing attributes from construction.
      3. `padded_to_packed_idx` does not need `compute_packed`
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D21653674
      
      fbshipit-source-id: dc6815a2e2a925fe4a834fe357919da2b2c14527
      1fb97f9c
  18. 11 Apr, 2020 1 commit
    • Georgia Gkioxari's avatar
      point mesh distances · 487d4d66
      Georgia Gkioxari authored
      Summary:
      Implementation of point to mesh distances. The current diff contains two types:
      (a) Point to Edge
      (b) Point to Face
      
      ```
      
      Benchmark                                       Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      POINT_MESH_EDGE_4_100_300_5000_cuda:0                2745            3138            183
      POINT_MESH_EDGE_4_100_300_10000_cuda:0               4408            4499            114
      POINT_MESH_EDGE_4_100_3000_5000_cuda:0               4978            5070            101
      POINT_MESH_EDGE_4_100_3000_10000_cuda:0              9076            9187             56
      POINT_MESH_EDGE_4_1000_300_5000_cuda:0               1411            1487            355
      POINT_MESH_EDGE_4_1000_300_10000_cuda:0              4829            5030            104
      POINT_MESH_EDGE_4_1000_3000_5000_cuda:0              7539            7620             67
      POINT_MESH_EDGE_4_1000_3000_10000_cuda:0            12088           12272             42
      POINT_MESH_EDGE_8_100_300_5000_cuda:0                3106            3222            161
      POINT_MESH_EDGE_8_100_300_10000_cuda:0               8561            8648             59
      POINT_MESH_EDGE_8_100_3000_5000_cuda:0               6932            7021             73
      POINT_MESH_EDGE_8_100_3000_10000_cuda:0             24032           24176             21
      POINT_MESH_EDGE_8_1000_300_5000_cuda:0               5272            5399             95
      POINT_MESH_EDGE_8_1000_300_10000_cuda:0             11348           11430             45
      POINT_MESH_EDGE_8_1000_3000_5000_cuda:0             17478           17683             29
      POINT_MESH_EDGE_8_1000_3000_10000_cuda:0            25961           26236             20
      POINT_MESH_EDGE_16_100_300_5000_cuda:0               8244            8323             61
      POINT_MESH_EDGE_16_100_300_10000_cuda:0             18018           18071             28
      POINT_MESH_EDGE_16_100_3000_5000_cuda:0             19428           19544             26
      POINT_MESH_EDGE_16_100_3000_10000_cuda:0            44967           45135             12
      POINT_MESH_EDGE_16_1000_300_5000_cuda:0              7825            7937             64
      POINT_MESH_EDGE_16_1000_300_10000_cuda:0            18504           18571             28
      POINT_MESH_EDGE_16_1000_3000_5000_cuda:0            65805           66132              8
      POINT_MESH_EDGE_16_1000_3000_10000_cuda:0           90885           91089              6
      --------------------------------------------------------------------------------
      
      Benchmark                                       Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      POINT_MESH_FACE_4_100_300_5000_cuda:0                1561            1685            321
      POINT_MESH_FACE_4_100_300_10000_cuda:0               2818            2954            178
      POINT_MESH_FACE_4_100_3000_5000_cuda:0              15893           16018             32
      POINT_MESH_FACE_4_100_3000_10000_cuda:0             16350           16439             31
      POINT_MESH_FACE_4_1000_300_5000_cuda:0               3179            3278            158
      POINT_MESH_FACE_4_1000_300_10000_cuda:0              2353            2436            213
      POINT_MESH_FACE_4_1000_3000_5000_cuda:0             16262           16336             31
      POINT_MESH_FACE_4_1000_3000_10000_cuda:0             9334            9448             54
      POINT_MESH_FACE_8_100_300_5000_cuda:0                4377            4493            115
      POINT_MESH_FACE_8_100_300_10000_cuda:0               9728            9822             52
      POINT_MESH_FACE_8_100_3000_5000_cuda:0              26428           26544             19
      POINT_MESH_FACE_8_100_3000_10000_cuda:0             42238           43031             12
      POINT_MESH_FACE_8_1000_300_5000_cuda:0               3891            3982            129
      POINT_MESH_FACE_8_1000_300_10000_cuda:0              5363            5429             94
      POINT_MESH_FACE_8_1000_3000_5000_cuda:0             20998           21084             24
      POINT_MESH_FACE_8_1000_3000_10000_cuda:0            39711           39897             13
      POINT_MESH_FACE_16_100_300_5000_cuda:0               5955            6001             84
      POINT_MESH_FACE_16_100_300_10000_cuda:0             12082           12144             42
      POINT_MESH_FACE_16_100_3000_5000_cuda:0             44996           45176             12
      POINT_MESH_FACE_16_100_3000_10000_cuda:0            73042           73197              7
      POINT_MESH_FACE_16_1000_300_5000_cuda:0              8292            8374             61
      POINT_MESH_FACE_16_1000_300_10000_cuda:0            19442           19506             26
      POINT_MESH_FACE_16_1000_3000_5000_cuda:0            36059           36194             14
      POINT_MESH_FACE_16_1000_3000_10000_cuda:0           64644           64822              8
      --------------------------------------------------------------------------------
      ```
      
      Reviewed By: jcjohnson
      
      Differential Revision: D20590462
      
      fbshipit-source-id: 42a39837b514a546ac9471bfaff60eefe7fae829
      487d4d66
  19. 29 Mar, 2020 1 commit
    • Patrick Labatut's avatar
      Address black + isort fbsource linter warnings · d57daa6f
      Patrick Labatut authored
      Summary: Address black + isort fbsource linter warnings from D20558374 (previous diff)
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20558373
      
      fbshipit-source-id: d3607de4a01fb24c0d5269634563a7914bddf1c8
      d57daa6f
  20. 23 Mar, 2020 1 commit
    • Jeremy Reizenstein's avatar
      use assertClose · 595aca27
      Jeremy Reizenstein authored
      Summary: use assertClose in some tests, which enforces shape equality. Fixes some small problems, including graph_conv on an empty graph.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20556912
      
      fbshipit-source-id: 60a61eafe3c03ce0f6c9c1a842685708fb10ac5b
      595aca27
  21. 17 Mar, 2020 1 commit
  22. 12 Mar, 2020 1 commit
    • Patrick Labatut's avatar
      Remove shebang line when not strictly required · 3c71ab64
      Patrick Labatut authored
      Summary: The shebang line `#!<path to interpreter>` is only required for Python scripts, so remove it on source files for class or function definitions. Additionally explicitly mark as executable the actual Python scripts in the codebase.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20095778
      
      fbshipit-source-id: d312599fba485e978a243292f88a180d71e1b55a
      3c71ab64
  23. 23 Jan, 2020 1 commit