提交测试

This commit is contained in:
2024-01-16 17:22:21 +08:00
parent 92862c0372
commit 73635fda01
654 changed files with 178015 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
.. _kaolin.io.materials:
kaolin.io.materials
===================
.. currentmodule:: kaolin.io.materials
API
---
Functions
===================
API
---
.. automodule:: kaolin.io.materials
:members:
:exclude-members:
MaterialError,
MaterialLoadError,
MaterialFileError,
MaterialNotFoundError
Exceptions
----------
.. autoclass:: MaterialError
.. autoclass:: MaterialLoadError
.. autoclass:: MaterialFileError
.. autoclass:: MaterialNotFoundError

View File

@@ -0,0 +1,33 @@
.. _kaolin.io.obj:
kaolin.io.obj
=============
.. currentmodule:: kaolin.io.obj
API
---
Functions
---------
.. automodule:: kaolin.io.obj
:members:
:exclude-members:
return_type,
ignore_error_handler,
skip_error_handler,
default_error_handler,
create_missing_materials_error_handler,
MaterialError,
MaterialLoadError,
MaterialFileError,
MaterialNotFoundError
Error Handler
-------------
.. autofunction:: ignore_error_handler
.. autofunction:: skip_error_handler
.. autofunction:: default_error_handler
.. autofunction:: create_missing_materials_error_handler

View File

@@ -0,0 +1,26 @@
.. _kaolin.io:
kaolin.io
=========
IO directory contains all the functionalities to interact with data files.
:ref:`obj module<kaolin.io.obj>` and :ref:`usd module <kaolin.io.usd>` contains importer to .obj and o, importers / exporters to .usd(a) files,
:ref:`dataset module<kaolin.io.dataset>` contains helper features for caching data, and preprocessing whole datasets,
and :ref:`materials module<kaolin.io.materials>` contains Materials definition that should be used throughout Kaolin.
.. toctree::
:maxdepth: 2
:titlesonly:
kaolin.io.dataset
kaolin.io.materials
kaolin.io.gltf
kaolin.io.obj
kaolin.io.off
kaolin.io.render
kaolin.io.shapenet
kaolin.io.usd
kaolin.io.modelnet
kaolin.io.shrec
kaolin.io.utils

View File

@@ -0,0 +1,10 @@
kaolin.io.shapenet
==================
API
---
.. automodule:: kaolin.io.shapenet
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,38 @@
.. _kaolin.io.usd:
kaolin.io.usd
=============
Universal Scene Description
---------------------------
Universal Scene Description (USD) is an open-source 3D scene description file format developed by Pixar and designed to be versatile, extensible and interchangeable between different 3D tools.
Single models and animations as well as large organized scenes composed of any number of assets can be defined in USD, making it suitable for organizing entire datasets into interpretable,
subsets based on tags, class or other metadata label.
Kaolin includes base I/O operations for USD and also leverages this format to export 3D checkpoints. Use kaolin.io.usd to read and write USD files (try :code:`tutorials/usd_kitcheset.py`),
and :code:`kaolin.visualize.Timelapse` to export 3D checkpoints (try :code:`tutorials/visualize_main.py`).
As a first step to familiarizing yourself with USD, we suggest following this `tutorial <https://developer.nvidia.com/usd>`_.
More tutorials and documentation can be found `here <https://graphics.pixar.com/usd/docs/Introduction-to-USD.html>`_.
Viewing USD Files
~~~~~~~~~~~~~~~~~
USD files can be visualized with realtime pathtracing using the [Omniverse Kaolin App](https://docs.omniverse.nvidia.com/app_kaolin/app_kaolin/user_manual.html#training-visualizer).
Alternatively, you may use Pixar's USDView which can be obtained by visiting
`https://developer.nvidia.com/usd <https://developer.nvidia.com/usd>`_ and selecting the
corresponding platform under *USD Pre-Built Libraries and Tools*.
API
---
Functions
---------
.. automodule:: kaolin.io.usd
:members:
:exclude-members:
mesh_return_type

View File

@@ -0,0 +1,20 @@
.. _kaolin.metrics:
kaolin.metrics
==============
Metrics are differentiable operators that can be used to compute loss or accuracy.
We currently provide an IoU for voxelgrid, sided distance based metrics such as chamfer distance,
point_to_mesh_distance and other simple regularization such as uniform_laplacian_smoothing.
For tetrahedral mesh, we support the equivolume and AMIPS losses.
.. toctree::
:maxdepth: 2
:titlesonly:
kaolin.metrics.pointcloud
kaolin.metrics.render
kaolin.metrics.trianglemesh
kaolin.metrics.voxelgrid
kaolin.metrics.tetmesh

View File

@@ -0,0 +1,12 @@
.. _kaolin.metrics.tetmesh:
kaolin.metrics.tetmesh
======================
API
---
.. automodule:: kaolin.metrics.tetmesh
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,23 @@
.. _kaolin.non_commercial:
kaolin.non\_commercial
======================
License
-------
This submodule contains features under `NSCL license <https://github.com/NVIDIAGameWorks/kaolin/blob/master/LICENSE.NSCL>`_ restricted to non commercial usage for research and evaluation purposes.
API
---
.. autoclass:: kaolin.non_commercial.FlexiCubes
:members:
:special-members: __call__
.. automodule:: kaolin.non_commercial
:members:
:undoc-members:
:exclude-members: FlexiCubes
:show-inheritance:

View File

@@ -0,0 +1,83 @@
.. _kaolin.ops.batch:
kaolin.ops.batch
================
.. _batching:
Batching
--------
Batching data in 3D can be tricky due to the heterogeneous sizes.
For instance, point clouds can have different number of points, which means we can't always just concatenate the tensors on a batch axis.
Kaolin supports different batching strategies:
.. _exact:
Exact
~~~~~
Exact batching is the logical representation for homogeneous data.
For instance, if you sample the same numbers of points from a batch of meshes, you would just have a single tensor of shape :math:`(\text{batch_size}, \text{number_of_points}, 3)`.
.. _padded:
Padded
~~~~~~
Heterogeneous tensors are padded to identical dimensions with a constant value so that they can be concatenated on a batch axis. This is similar to padding for the batching of image data of different shapes.
.. note::
The last dimension must always be of the size of the element, e.g. 3 for 3D points (element of point clouds) or 1 for a grayscale pixel (element of grayscale textures).
For instance, for two textures :math:`T_0` and :math:`T_1` of shape :math:`(32, 32, 3)` and :math:`(64, 16, 3)`
the batched tensor will be of shape :math:`(2, max(32, 64), max(32, 16), 3) = (2, 64, 32, 3)` and the padding value will be :math:`0`. :math:`T_0` will be padded on the 1st axis by :math:`32` while :math:`T_1` will be padded on the 2nd axis by :math:`16`.
You can also enforce a specific maximum shape (if you want to have a fix memory consumption or use optimization like cudnn algorithm selection).
For instance, you can force :math:`T_0` and :math:`T_1` to be batched with a maximum shape of :math:`(128, 128)`, the batched tensor will be of shape :math:`(2, 128, 128, 3)`, :math:`T_0` will be padded on the 1st axis and 2nd axis by 96 and :math:`T_1` will be padded on the 1st axis by :math:`64` and on the 2nd axis by :math:`112`.
For more information on how to do padded batching check :func:`kaolin.ops.batch.list_to_padded`
Related attributes:
...................
.. _padded_shape_per_tensor:
* :attr:`shape_per_tensor`: 2D :class:`torch.LongTensor` stores the shape of each sub-tensor except the last dimension in the padded tensor. E.g., in the example above :attr:`shape_per_tensor` would be ``torch.LongTensor([[32, 32], [64, 16]])``. Refer to :func:`kaolin.ops.batch.get_shape_per_tensor` for more information.
.. _packed:
Packed
~~~~~~
Heterogeneous tensors are reshaped to 2D :math:`(-1, \text{last_dimension})` and concatenated on the first axis. This is similar to packed sentences in NLP.
.. note::
The last dimension must always be of the size of the element, e.g. 3 for 3D points (element of point clouds) or 1 for a grayscale pixel (element of grayscale textures).
For instance, for two textures :math:`T_0` and :math:`T_1` of shape :math:`(32, 32, 3)` and :math:`(64, 16, 3)`
The batched tensor will be of shape :math:`(32 * 32 + 64 * 16, 3)`. :math:`T_0` will be reshaped to :math:`(32 * 32, 3)` and :math:`T_1` will be reshaped :math:`(64 * 16, 3)`, before being concatenated on the first axis.
For more information on how to do padded batching check :func:`kaolin.ops.batch.list_to_packed`
Related attributes:
...................
.. _packed_shape_per_tensor:
* :attr:`shape_per_tensor`: 2D :class:`torch.LongTensor` stores the shape of each sub-tensor except the last dimension in the padded tensor. E.g., in the example above :attr:`shape_per_tensor` would be ``torch.LongTensor([[32, 32], [64, 16]])``. Refer to :func:`kaolin.ops.batch.get_shape_per_tensor` for more information.
.. _packed_first_idx:
* :attr:`first_idx`: 1D :class:`torch.LongTensor` stores the first index of each subtensor and the last index + 1 on the first axis in the packed tensor. E.g., in the example above :attr:`first_idx` would be ``torch.LongTensor([0, 1024, 2048])``. This attribute are used for delimiting each subtensor into the packed tensor, for instance, to slice or index. Refer to :func:`kaolin.ops.batch.get_first_idx` for more information.
API
---
.. automodule:: kaolin.ops.batch
:platform: Windows-x86_64, Linux-x86_64
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,12 @@
.. _kaolin.ops.conversions:
kaolin.ops.conversions
======================
API
---
.. automodule:: kaolin.ops.conversions
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,38 @@
.. _kaolin.ops.mesh:
kaolin.ops.mesh
***********************
A mesh is a 3D object representation consisting of a collection of vertices and polygons.
Triangular meshes
==================
Triangular meshes comprise of a set of triangles that are connected by their common edges or corners. In Kaolin, they are usually represented as a set of two tensors:
* ``vertices``: A :class:`torch.Tensor`, of shape :math:`(\text{batch_size}, \text{num_vertices}, 3)`, contains the vertices coordinates.
* ``faces``: A :class:`torch.LongTensor`, of shape :math:`(\text{batch_size}, \text{num_faces}, 3)`, contains the mesh topology, by listing the vertices index for each face.
Both tensors can be combined using :func:`kaolin.ops.mesh.index_vertices_by_faces`, to form ``face_vertices``, of shape :math:`(\text{batch_size}, \text{num_faces}, 3, 3)`, listing the vertices coordinate for each face.
Tetrahedral meshes
==================
A tetrahedron or triangular pyramid is a polyhedron composed of four triangular faces, six straight edges, and four vertex corners. Tetrahedral meshes inside Kaolin are composed of two tensors:
* ``vertices``: A :class:`torch.Tensor`, of shape :math:`(\text{batch_size}, \text{num_vertices}, 3)`, contains the vertices coordinates.
* ``tet``: A :class:`torch.LongTensor`, of shape :math:`(\text{batch_size}, \text{num_tet}, 4)`, contains the tetrahedral mesh topology, by listing the vertices index for each tetrahedron.
Both tensors can be combined, to form ``tet_vertices``, of shape :math:`(\text{batch_size}, \text{num_tet}, 4, 3)`, listing the tetrahedrons vertices coordinates for each face.
API
---
.. automodule:: kaolin.ops.mesh
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,23 @@
.. _kaolin.ops:
kaolin.ops
==========
Operators are primitive processing functions for batched 3D models (:ref:`meshes<kaolin.ops.mesh>`, :ref:`voxelgrids<kaolin.ops.voxelgrid>` and point clouds).
Tensor batching operators are in :ref:`kaolin.ops.batch`, conversions of 3D models between different representations are in :ref:`kaolin.ops.conversions`.
.. toctree::
:maxdepth: 2
:titlesonly:
kaolin.ops.batch
kaolin.ops.coords
kaolin.ops.conversions
kaolin.ops.pointcloud
kaolin.ops.gcn
kaolin.ops.mesh
kaolin.ops.random
kaolin.ops.reduction
kaolin.ops.spc
kaolin.ops.voxelgrid

View File

@@ -0,0 +1,12 @@
.. _kaolin.ops.spc:
kaolin.ops.spc
##############
API
---
.. automodule:: kaolin.ops.spc
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,15 @@
:orphan:
.. _kaolin.render.camera.Camera:
kaolin.render.camera.Camera
===========================
API
---
.. autoclass:: kaolin.render.camera.Camera
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.render.camera.CameraExtrinsics:
kaolin.render.camera.CameraExtrinsics
=====================================
API
---
.. autoclass:: kaolin.render.camera.CameraExtrinsics
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.render.camera.CameraIntrinsics:
kaolin.render.camera.CameraIntrinsics
=====================================
API
---
.. autoclass:: kaolin.render.camera.CameraIntrinsics
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.render.camera.ExtrinsicsRep:
kaolin.render.camera.ExtrinsicsRep
==================================
API
---
.. autoclass:: kaolin.render.camera.ExtrinsicsRep
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.render.camera.OrthographicIntrinsics:
kaolin.render.camera.OrthographicIntrinsics
===========================================
API
---
.. autoclass:: kaolin.render.camera.OrthographicIntrinsics
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.render.camera.PinholeIntrinsics:
kaolin.render.camera.PinholeIntrinsics
======================================
API
---
.. autoclass:: kaolin.render.camera.PinholeIntrinsics
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,36 @@
.. _kaolin.render.camera:
kaolin.render.camera
====================
Kaolin provides extensive camera API. For an overview, see the :ref:`Camera class docs <kaolin.render.camera.Camera>`.
API
---
Classes
^^^^^^^
* :ref:`Camera <kaolin.render.camera.Camera>`
* :ref:`CameraExtrinsics <kaolin.render.camera.CameraExtrinsics>`
* :ref:`CameraIntrinsics <kaolin.render.camera.CameraIntrinsics>`
* :ref:`PinholeIntrinsics <kaolin.render.camera.PinholeIntrinsics>`
* :ref:`OrthographicIntrinsics <kaolin.render.camera.OrthographicIntrinsics>`
* :ref:`ExtrinsicsRep <kaolin.render.camera.ExtrinsicsRep>`
Functions
^^^^^^^^^
.. automodule:: kaolin.render.camera
:members:
:exclude-members:
Camera,
CameraExtrinsics,
CameraIntrinsics,
PinholeIntrinsics,
OrthographicIntrinsics,
ExtrinsicsRep
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,13 @@
.. _kaolin.render:
kaolin.render
=============
.. toctree::
:maxdepth: 2
:titlesonly:
kaolin.render.camera
kaolin.render.lighting
kaolin.render.mesh
kaolin.render.spc

View File

@@ -0,0 +1,12 @@
.. _kaolin.render.spc:
kaolin.render.spc
=================
API
---
.. automodule:: kaolin.render.spc
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,27 @@
.. _kaolin.rep:
kaolin.rep
==========
This module includes higher-level Kaolin classes ("representations").
API
---
Classes
^^^^^^^
* :ref:`SurfaceMesh <kaolin.rep.SurfaceMesh>`
* :ref:`Spc <kaolin.rep.Spc>`
Other
^^^^^^^^^
.. automodule:: kaolin.rep
:members:
:exclude-members:
SurfaceMesh,
Spc
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,14 @@
:orphan:
.. _kaolin.rep.Spc:
kaolin.rep.Spc
===========================
API
---
.. autoclass:: kaolin.rep.Spc
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,146 @@
:orphan:
.. _kaolin.rep.SurfaceMesh:
SurfaceMesh
===========================
Tutorial
--------
For a walk-through of :class:`kaolin.rep.SurfaceMesh` features,
see `working_with_meshes.ipynb <https://github.com/NVIDIAGameWorks/kaolin/blob/master/examples/tutorial/working_with_meshes.ipynb>`_.
API
---
* :ref:`Overview <rubric mesh overview>`
* :ref:`Supported Attributes <rubric mesh attributes>`
* :ref:`Batching <rubric mesh batching>`
* :ref:`Attribute Access and Auto-Computability <rubric mesh attribute access>`
* :ref:`Inspecting and Copying <rubric mesh inspecting>`
* :ref:`Tensor Operations <rubric mesh tensor ops>`
.. autoclass:: kaolin.rep.SurfaceMesh
:members:
:undoc-members:
:member-order: bysource
:exclude-members: Batching, attribute_info_string, set_batching, to_batched, getattr_batched, cat,
vertices, face_vertices, normals, face_normals, vertex_normals, uvs, face_uvs, faces, face_normals_idx, face_uvs_idx,
material_assignments, materials, cuda, cpu, to, float_tensors_to, detach, get_attributes, has_attribute, has_or_can_compute_attribute,
probably_can_compute_attribute, get_attribute, get_or_compute_attribute, check_sanity, to_string, as_dict, describe_attribute,
unset_attributes_return_none, allow_auto_compute, batching, convert_attribute_batching
.. _rubric mesh batching:
.. rubric:: Supported Batching Strategies
``SurfaceMesh`` can be instantiated with any of the following batching
strategies, and supports conversions between batching strategies. Current
batching strategy of a ``mesh`` object can be read from ``mesh.batching`` or
by running ``print(mesh)``.
For example::
mesh = kaolin.io.obj.load_mesh(path)
print(mesh)
mesh.to_batched()
print(mesh)
.. autoclass:: kaolin.rep.SurfaceMesh.Batching
:members:
.. automethod:: attribute_info_string
.. automethod:: check_sanity
.. automethod:: set_batching
.. automethod:: to_batched
.. automethod:: getattr_batched
.. automethod:: cat
.. automethod:: convert_attribute_batching
.. _rubric mesh attribute access:
.. rubric:: Attribute Access
By default, ``SurfaceMesh`` will attempt to auto-compute missing attributes
on access. These attributes will be cached, unless their ancestors have
``requires_grad == True``. This behavior of the ``mesh`` object can be changed
at construction time (``allow_auto_compute=False``) or by setting
``mesh.allow_auto_compute`` later. In addition to this convenience API,
explicit methods for attribute access are also supported.
For example, using **convenience API**::
# Caching is enabled by default
mesh = kaolin.io.obj.load_mesh(path, with_normals=False)
print(mesh)
print(mesh.has_attribute('face_normals')) # False
fnorm = mesh.face_normals # Auto-computed
print(mesh.has_attribute('face_normals')) # True (cached)
# Caching is disabled when gradients need to flow
mesh = kaolin.io.obj.load_mesh(path, with_normals=False)
mesh.vertices.requires_grad = True # causes caching to be off
print(mesh.has_attribute('face_normals')) # False
fnorm = mesh.face_normals # Auto-computed
print(mesh.has_attribute('face_normals')) # False (caching disabled)
For example, using **explicit API**::
mesh = kaolin.io.obj.load_mesh(path, with_normals=False)
print(mesh.has_attribute('face_normals')) # False
fnorm = mesh.get_or_compute_attribute('face_normals', should_cache=False)
print(mesh.has_attribute('face_normals')) # False
.. automethod:: get_attributes
.. automethod:: has_attribute
.. automethod:: has_or_can_compute_attribute
.. automethod:: probably_can_compute_attribute
.. automethod:: get_attribute
.. automethod:: get_or_compute_attribute
.. _rubric mesh inspecting:
.. rubric:: Inspecting and Copying Meshes
To make it easier to work with, ``SurfaceMesh`` supports detailed print
statements, as well as ``len()``, ``copy()``, ``deepcopy()`` and can be converted
to a dictionary.
Supported operations::
import copy
mesh_copy = copy.copy(mesh)
mesh_copy = copy.deepcopy(mesh)
batch_size = len(mesh)
# Print default attributes
print(mesh)
# Print more detailed attributes
print(mesh.to_string(detailed=True, print_stats=True))
# Print specific attribute
print(mesh.describe_attribute('vertices'))
.. automethod:: to_string
.. automethod:: describe_attribute
.. automethod:: as_dict
.. _rubric mesh tensor ops:
.. rubric:: Tensor Operations
Convenience operations for device and type conversions of some or all member
tensors.
.. automethod:: cuda
.. automethod:: cpu
.. automethod:: to
.. automethod:: float_tensors_to
.. automethod:: detach
.. rubric:: Other

View File

@@ -0,0 +1,10 @@
.. _kaolin.utils:
kaolin.utils
============
.. toctree::
:maxdepth: 2
:titlesonly:
kaolin.utils.testing

View File

@@ -0,0 +1,14 @@
.. _kaolin.visualize:
kaolin.visualize
================
API
---
.. automodule:: kaolin.visualize
:members:
:inherited-members:
:undoc-members:
:show-inheritance:

14
docs/modules/module.rst_t Normal file
View File

@@ -0,0 +1,14 @@
{%- if show_headings -%}
.. _{{ basename }}:
{{ basename | e | heading }}
{%- endif %}
API
---
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}

View File

@@ -0,0 +1,34 @@
{%- macro automodule(modname, options) -%}
API
---
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
{%- endfor %}
{%- endmacro %}
{%- macro unfoldtree(docnames) -%}
{%- for docname in docnames %}
{{ docname }}
{%- endfor %}
{%- endmacro -%}
{%- if is_namespace %}
{{- [pkgname, "namespace"] | join(" ") | e | heading }}
{% else -%}
.. _{{ pkgname }}:
{{ pkgname | e | heading }}
{%- endif -%}
{%- if subpackages or submodules %}
.. toctree::
:maxdepth: {{ maxdepth }}
:titlesonly:
{% endif -%}
{{ unfoldtree(subpackages + submodules) }}
{% if not is_namespace -%}
{{ automodule(pkgname, automodule_options) }}
{% endif %}

8
docs/modules/toc.rst_t Normal file
View File

@@ -0,0 +1,8 @@
{{ header | heading }}
.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{%- endfor %}