A CUDA-enhanced package for common NeRF model operations
Project description
Nerfboost - CUDA-accelerated NeRF Model Training for AR/VR Experiences
nerfboost is a CUDA-accelerated Python package designed to make Neural Radiance Fields (NeRF) model training easier and more efficient, particularly for applications in augmented reality (AR) and virtual reality (VR). NeRF models are essential for generating high-quality, 3D scene reconstructions from 2D images or views, making them perfect for AR/VR experiences. nerfboost provides high-performance implementations of key NeRF operations, accelerating training and rendering times for AR/VR projects.
Source Code: GitHub Repository
Features
- CUDA-accelerated functions for efficient neural rendering tasks.
- Implements key operations for NeRF models like:
- Positional encoding
- Stratified, uniform, hierarchical, and inverse sampling
- Volume rendering
- MLP network processing
- Rendering loss computation
- Ray generation
- Easy integration with PyTorch using custom CUDA kernels.
Prerequisites
Ensure PyTorch is installed.
You can install Torch using the following command:
pip install torch
Installation
You can install nerfboost using the following command:
pip install nerfboost
Usage
Initialization
import nerfboost
Positional encoding
The positional encoding transforms input coordinates into a higher-dimensional space, crucial for NeRF models.
x = torch.randn(10, 3) # Input coordinates (e.g., 10 points in 3D space)
L = 10 # Number of encoding frequencies
encoded_positions = nerfboost.positional_encoding_cuda(x, L)
Stratified and Uniform Sampling
Stratified sampling generates sample points along a ray between near and far planes: Uniform sampling generates evenly spaced samples between near and far planes:
near = 0.1
far = 4.0
num_samples = 64
stratified_samples = nerfboost.stratified_sampling_cuda(near, far, num_samples)
unifrom_samples = nerfboost.uniform_sampling_cuda(near, far, num_samples)
Hierarchical Sampling
Refines samples based on coarse predictions:
coarse_samples = torch.randn(num_samples) # Coarse samples from the network
weights = torch.randn(num_samples) # Corresponding weights
num_fine_samples = 128
fine_samples = nerfboost.hierarchical_sampling_cuda(coarse_samples, weights, num_fine_samples)
Inverse Transform Sampling
Generates samples using inverse transform sampling based on the given probability distribution:
weights = torch.rand(64) # Probability distribution
num_samples = 128
samples = nerfboost.inverse_transform_sampling_cuda(weights, num_samples)
Volume Rendering
Computes the final color and density for each ray based on input densities, colors, and distances:
densities = torch.rand(64) # Density for each sample
colors = torch.rand(64, 3) # RGB color for each sample
distances = torch.rand(64) # Distance along the ray
final_colors = nerfboost.volume_rendering_cuda(densities, colors, distances)
MLP Network Processing
Processes sampled points through a multi-layer perceptron (MLP) network:
sampled_points = torch.randn(64, 3) # Points sampled along the rays
directions = torch.randn(64, 3) # Ray directions
weights = [torch.randn(3, 64), torch.randn(64, 64), torch.randn(64, 3)] # MLP weights
output = nerfboost.mlp_network_cuda(sampled_points, directions, weights)
Rendering Loss (MSE)
Computes the mean squared error (MSE) between the rendered image and the ground truth image:
rendered_image = torch.rand(256, 256, 3) # Rendered output
ground_truth_image = torch.rand(256, 256, 3) # Ground truth image
loss = nerfboost.rendering_loss_cuda(rendered_image, ground_truth_image)
Ray Generation
Generates rays for rendering using the camera intrinsics and resolution:
camera_intrinsics = torch.rand(3, 3) # Camera intrinsic matrix
H = 256 # Image height
W = 256 # Image width
origins, directions = nerfboost.generate_rays_cuda(camera_intrinsics, H, W)
License
This project is licensed under the MIT License.
Author
Akshay Pappu
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nerfboost-1.0.0.tar.gz.
File metadata
- Download URL: nerfboost-1.0.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1389e6955bd747990f21e5f5f20fbbbc462f26ce562364bcf97322eb400d1169
|
|
| MD5 |
aa42fdecd88173f035dca6df857f0c95
|
|
| BLAKE2b-256 |
31f3cf793dd017dbcf4add1a90b7bc935ba85aa55bac271b9d13e168f2460505
|
File details
Details for the file nerfboost-1.0.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: nerfboost-1.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 570.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92bbf57503926d18b53e97cb6188e091696f8b571a152435f63d3981de84eaaf
|
|
| MD5 |
8825cce82c4a029df1e4a4c6080a16bc
|
|
| BLAKE2b-256 |
154cdc2763f8e567fec3e660ad605e57e4124286b4f127c30bf3990e1c326192
|