Skip to main content

Interactive NeRF rendering web viewer

Project description

nerfview

core-tests codecov

nerfview is a minimal* web viewer for interactive NeRF rendering. It is largely inspired by nerfstudio's viewer, but with a standalone packaging and simple API to quickly integrate into your own research projects.

*The whole package contains two files and is less than 400 lines of code.

Installation

For existing project, you can install it via pip:

pip install git+https://github.com/hangg7/nerfview.git

To run our examples, you can clone this repository and then install it locally:

git clone https://github.com/hangg7/nerfview
# Install torch first.
pip install torch
# Then this repo and dependencies for running examples. Note that `gsplat`
# requires compilation and this will take some time for the first time.
pip install -e ".[examples]"

Usage

nerfview is built on viser and provides a simple API for interactive viewing.

The canonical usage is as follows:

from typing import Tuple

import viser
import nerfview


def render_fn(
    camera_state: nerfview.CameraState, img_wh: Tuple[int, int]
) -> np.ndarray:
    # Parse camera state for camera-to-world matrix (c2w) and intrinsic (K) as
    # float64 numpy arrays.
    c2w = camera_state.c2w
    K = camera_state.get_K(img_wh)
    # Do your things and get an image as a uint8 numpy array.
    img = your_rendering_logic(...)
    return img

# Initialize a viser server and our viewer.
server = viser.ViserServer(verbose=False)
viewer = nerfview.Viewer(server=server, render_fn=render_fn, mode='rendering')

It will start a viser server and render the image from a camera that you can interact with.

Examples

We provide a few examples ranging from toy rendering to real-world NeRF training applications. Click on the dropdown to see more details. You can always ask for help message by the -h flag.

Rendering a dummy scene.

https://github.com/hangg7/nerfview/assets/10098306/53a41fac-bce7-4820-be75-f90483bc22a0

This example is the best starting point to understand the basic API.

python examples/00_dummy_rendering.py
Rendering a dummy training process.

https://github.com/hangg7/nerfview/assets/10098306/8b13ca4a-6aaa-46a7-a333-b889c2a4ac15

This example is the best starting point to understand the API for training time update.

python examples/01_dummy_training.py
Rendering a mesh scene.

https://github.com/hangg7/nerfview/assets/10098306/84c9993f-82a3-48fb-9786-b5205bffcd6f

This example showcases how to interactively render a mesh by directly serving rendering results from nvdiffrast.

# Only need to run once the first time.
bash examples/assets/download_dragon_mesh.sh
CUDA_VISIBLE_DEVICES=0 python examples/02_mesh_rendering.py
Rendering a pretrained 3DGS scene.

https://github.com/hangg7/nerfview/assets/10098306/7b526105-8b6f-431c-9b49-10c821a3bd36

This example showcases how to render a pretrained 3DGS model using gsplat. The scene is cropped such that it is smaller to download. It is essentially the simple_viewer example, which we include here to be self-contained.

# Only need to run once the first time.
bash examples/assets/download_gsplat_ckpt.sh
CUDA_VISIBLE_DEVICES=0 python examples/03_gsplat_rendering.py \
    --ckpt results/garden/ckpts/ckpt_6999_crop.pt
Rendering a 3DGS training process.

https://github.com/hangg7/nerfview/assets/10098306/640d4067-e410-49aa-86b8-325140dd73a8

This example showcases how to render while training 3DGS on mip-NeRF's garden scene using gsplat. It is essentially the simple_trainer example, which we include here to be self-contained.

# Only need to run once the first time.
bash examples/assets/download_colmap_garden.sh
CUDA_VISIBLE_DEVICES=0 python examples/04_gsplat_training.py \
    --data_dir examples/assets/colmap_garden/ \
    --data_factor 8 \
    --result_dir results/garden/

Acknowledgement

This project cannot exist without the great work of nerfstudio and viser. We rely on nvdiffrast for the mesh example and gsplat for the 3DGS examples. We thank the authors for their great work and open-source spirit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nerfview-0.0.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

nerfview-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nerfview-0.0.1.tar.gz.

File metadata

  • Download URL: nerfview-0.0.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.18

File hashes

Hashes for nerfview-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6d84b03d92920f3c923ef903e3912ac2354f8b7210dd360573a6a98e235fe8de
MD5 70599009dc71db455df5e740691580f8
BLAKE2b-256 3b774126b92e27e5342b455f31c8fb5291f50f8c9765975be53a0fb0a2085795

See more details on using hashes here.

File details

Details for the file nerfview-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nerfview-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.18

File hashes

Hashes for nerfview-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8909dfe7392b2a34b97c4f8e979c1716dcae2b3497d27be8e4c19118ebb41b9b
MD5 d4acc4f93a3d983935729b3cb25c8bd1
BLAKE2b-256 1765a1d66e8e8245239fae799ba09b5139ee8dc61dd5b6cda17ebe0af7f5f65d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page