Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions surface_reconstruction/nksr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

cmake-build-debug
cmake-build-release

.premature_checkpoints

*.old
sync-pycg.sh
sync-dataloader.sh
ngc_mapping.json
playground/

# Sweep-related files
sweeps/
wandb/
wdb_sweep.py

zeus_config.yaml
assets/buda.ply
assets/waymo-pcd.ply
assets/scannet.ply
assets/las/

package/external/
.vscode/
91 changes: 91 additions & 0 deletions surface_reconstruction/nksr/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

Copyright (c) 2023, NVIDIA Corporation & affiliates. All rights reserved.


NVIDIA Source Code License for NKSR


=======================================================================

1. Definitions

“Licensor” means any person or entity that distributes its Work.

“Work” means (a) the original work of authorship made available under
this license, which may include software, documentation, or other files,
and (b) any additions to or derivative works thereof that are made
available under this license.

The terms “reproduce,” “reproduction,” “derivative works,” and
“distribution” have the meaning as provided under U.S. copyright law;
provided, however, that for the purposes of this license, derivative works
shall not include works that remain separable from, or merely link
(or bind by name) to the interfaces of, the Work.

Works are “made available” under this license by including in or with
the Work either (a) a copyright notice referencing the applicability of
this license to the Work, or (b) a copy of this license.

2. License Grant

2.1 Copyright Grant. Subject to the terms and conditions of this license,
each Licensor grants to you a perpetual, worldwide, non-exclusive,
royalty-free, copyright license to use, reproduce, prepare derivative
works of, publicly display, publicly perform, sublicense and distribute
its Work and any resulting derivative works in any form.

3. Limitations

3.1 Redistribution. You may reproduce or distribute the Work only if
(a) you do so under this license, (b) you include a complete copy of
this license with your distribution, and (c) you retain without
modification any copyright, patent, trademark, or attribution notices
that are present in the Work.

3.2 Derivative Works. You may specify that additional or different terms
apply to the use, reproduction, and distribution of your derivative
works of the Work (“Your Terms”) only if (a) Your Terms provide that the
use limitation in Section 3.3 applies to your derivative works, and (b)
you identify the specific derivative works that are subject to Your Terms.
Notwithstanding Your Terms, this license (including the redistribution
requirements in Section 3.1) will continue to apply to the Work itself.

3.3 Use Limitation. The Work and any derivative works thereof only may be
used or intended for use non-commercially. Notwithstanding the foregoing,
NVIDIA Corporation and its affiliates may use the Work and any derivative
works commercially. As used herein, “non-commercially” means for research
or evaluation purposes only.

3.4 Patent Claims. If you bring or threaten to bring a patent claim against
any Licensor (including any claim, cross-claim or counterclaim in a lawsuit)
to enforce any patents that you allege are infringed by any Work, then your
rights under this license from such Licensor (including the grant in
Section 2.1) will terminate immediately.

3.5 Trademarks. This license does not grant any rights to use any Licensor’s
or its affiliates’ names, logos, or trademarks, except as necessary to
reproduce the notices described in this license.

3.6 Termination. If you violate any term of this license, then your rights
under this license (including the grant in Section 2.1) will terminate
immediately.

4. Disclaimer of Warranty.

THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT.
YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE.

5. Limitation of Liability.

EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY,
WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY
LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE,
THE USE OR INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF
GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR DATA, COMPUTER FAILURE OR
MALFUNCTION, OR ANY OTHER DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

=======================================================================
20 changes: 20 additions & 0 deletions surface_reconstruction/nksr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Neural Kernel Surface Reconstruction (NKSR)

Idea: This is supposed to be a minimal implementation of NN-based surface reconstruction method.
Since the common belief is that NN-based methods are very scalable with more and more data, we should go with the very brute force network method instead of the more sophisticated ones (i.e. kernel solve).

## Installation

Prerequisites: Follow fVDB [official website](https://github.com/openvdb/fvdb-core) to install the conda environment of fVDB.

```bash
# Editable install
pip install --no-build-isolation -e .
```

## Usage

```bash
# Quick test
python examples/recons_simple.py
```
36 changes: 36 additions & 0 deletions surface_reconstruction/nksr/examples/recons_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION & AFFILIATES and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.

from pathlib import Path

import point_cloud_utils as pcu
import requests
import torch

import nksr_fvdb

if __name__ == "__main__":
device = torch.device("cuda:0")

bunny_mesh_path = Path.home() / "data" / "bunny.ply"
if not bunny_mesh_path.exists():
bunny_mesh_path.parent.mkdir(parents=True, exist_ok=True)
res = requests.get("https://huggingface.co/heiwang1997/nksr-checkpoints/resolve/main/data/buda.ply")
with bunny_mesh_path.open("wb") as f:
f.write(res.content)

bunny_v, bunny_n = pcu.load_mesh_vn(bunny_mesh_path)

input_xyz = torch.from_numpy(bunny_v).float().to(device)
input_normal = torch.from_numpy(bunny_n).float().to(device)

reconstructor = nksr_fvdb.Reconstructor(device, preset="ks-sdf")
field = reconstructor.reconstruct(input_xyz, input_normal, voxel_size=1.0)
mesh = field.extract_primal_mesh(depth=1)

# Do something with the mesh...
12 changes: 12 additions & 0 deletions surface_reconstruction/nksr/nksr_fvdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION & AFFILIATES and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.

from nksr_fvdb.reconstructor import Reconstructor

__version__ = "1.0.0"
__version_info__ = (1, 0, 0)
12 changes: 12 additions & 0 deletions surface_reconstruction/nksr/nksr_fvdb/fields/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION & AFFILIATES and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.


from .base_field import BaseField, EvaluationResult
from .layer_field import LayerField
from .neural_field import NeuralField
Loading