• Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a simple template for practicing NeRF.

nerf-template

A simple template for practicing NeRF projects.

This is basically a clean and enhanced version of torch-ngp focusing on static NeRF reconstruction of realistic scenes.

Notable changes that improve performance:

  • dataset: random sampling from all training images at each step.
  • dataset: adaptive number of rays during training based on number of points evaluated.
  • model: proposal network for sampling points (non --cuda_ray mode).
  • model: spatial contraction for unbounded scenes.

Install

git clone https://github.com/ashawkey/nerf_template.git
cd nerf_template

Install with pip

pip install -r requirements.txt

Build extension (optional)

By default, we use load to build the extension at runtime. However, this may be inconvenient sometimes. Therefore, we also provide the setup.py to build each extension:

# install all extension modules
bash scripts/install_ext.sh

# if you want to install manually, here is an example:
cd raymarching
python setup.py build_ext --inplace # build ext only, do not install (only can be used in the parent directory)
pip install . # install to python path (you still need the raymarching/ folder, since this only install the built extension.)

Tested environments

  • Ubuntu 22 with torch 1.12 & CUDA 11.6 on a V100.

Usage

We majorly support COLMAP dataset like Mip-NeRF 360. Please download and put them under ./data.

For custom datasets:

# prepare your video or images under /data/custom, and run colmap (assumed installed):
python scripts/colmap2nerf.py --video ./data/custom/video.mp4 --run_colmap # if use video
python scripts/colmap2nerf.py --images ./data/custom/images/ --run_colmap # if use images

Basics

First time running will take some time to compile the CUDA extensions.

## -O: instant-ngp
# prune sampling points by maintaining a density grid
python main.py data/bonsai/ --workspace trial_bonsai_ngp --enable_cam_center --downscale 4 -O --background random --bound 8

## -O2: nerfstudio nerfacto
# use proposal network to predict sampling points
python main.py data/bonsai/ --workspace trial_bonsai_nerfacto --enable_cam_center --downscale 4 -O2

# MeRF network backbone
python main.py data/bonsai/ --workspace trial_bonsai_nerfacto --enable_cam_center --downscale 4 -O2 --backbone merf

Advanced Usage

### -O: equals
--fp16 --preload
--cuda_ray --mark_untrained
--adaptive_num_rays --random_image_batch

### -O2: equals
--fp16 --preload
--contract --bound 128
--adaptive_num_rays --random_image_batch 

### load checkpoint
--ckpt latest # by default we load the latest checkpoint in the workspace
--ckpt scratch # train from scratch.
--ckpt trial/checkpoints/xxx.pth # specify it by path

### training
--num_rays 4096 # number of rays to evaluate per training step
--adaptive_num_rays # ignore --num_rays and use --num_points to dynamically adjust number of rays.
--num_points 262144 # targeted number of points to evaluate per training step (to adjust num_rays)

### testing
--test # test, save video and mesh
--test_no_video # do not save video
--test_no_mesh # do not save mesh

### dataset related
--data_format [colmap|nerf] # dataset format
--enable_cam_center # use camera center instead of sparse point cloud center as the scene center (colmap dataset only) (only for 360-degree captured datasets, do not use this for forward-facing datasets!)
--enable_cam_near_far # estimate camera near & far from sparse points (colmap dataset only)

--bound 16 # scene bound set to [-16, 16]^3.
--scale 0.3 # camera scale, if not specified, automatically estimate one based on camera positions.

### visualization 
--vis_pose # viusalize camera poses and sparse points (sparse points are colmap dataset only)
--gui # open gui (only for testing, training in gui is not well supported!)

### balance between surface quality / rendering quality

# increase these weights to get better surface quality but worse rendering quality
--lambda_tv 1e-7 # total variation loss
--lambda_entropy 1e-3 # entropy on rendering weights (transparency, alpha), encourage them to be either 0 or 1

Please check the scripts directory for more examples on common datasets, and check main.py for all options.

Performance reference

Bonsai Counter Kitchen Room Bicycle Garden Stump
MipNeRF 360 (~days) 33.46 29.55 32.23 31.63 24.57 26.98 26.40
ours-ngp (~8 minutes) 28.99 25.18 26.42 28.58 21.31 23.70 22.73
ours-nerfacto (~12 minutes) 31.10 26.65 30.61 31.44 23.74 25.31 25.48

Ours are tested on a V100. Please check the commands under scripts/ to reproduce.

Acknowledgement

This repository is based on:

More Repositories

1

stable-dreamfusion

Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion.
Python
7,270
star
2

torch-ngp

A pytorch CUDA extension implementation of instant-ngp (sdf and nerf), with a GUI.
Python
1,863
star
3

nerf2mesh

[ICCV2023] Delicate Textured Mesh Recovery from NeRF via Adaptive Surface Refinement
Python
743
star
4

RAD-NeRF

Real-time Neural Radiance Talking Portrait Synthesis via Audio-spatial Decomposition
Python
707
star
5

Drag3D

DragGAN meets GET3D for interactive mesh generation and editing.
Python
456
star
6

diff-gaussian-rasterization

Cuda
308
star
7

Segment-Anything-NeRF

Segment-anything interactively in NeRF.
Python
277
star
8

chatgpt_please_improve_my_paper_writing

a thin wrapper of chatgpt for improving paper writing.
Python
251
star
9

torch-merf

An unofficial pytorch implementation of MeRF
Python
137
star
10

dreamfields-torch

A pytorch implementation of dreamfields with modifications.
Python
134
star
11

fantasia3d.unofficial

An unofficial reproduction of Fantasia3D
Python
127
star
12

CCNeRF

[NeurIPS 2022] Compressible-composable NeRF via Rank-residual Decomposition.
Python
125
star
13

cubvh

CUDA Mesh BVH tools.
Cuda
121
star
14

jiif

[ACM MM 2021] Joint Implicit Image Function for Guided Depth Super-Resolution
Python
90
star
15

raytracing

A CUDA Mesh RayTracer with BVH acceleration, with python bindings and a GUI.
Cuda
83
star
16

volumentations

3D volume data augmentation package inspired by albumentations
Python
78
star
17

kiuikit

A maintained, reusable and trustworthy toolkit for computer vision tasks.
Python
42
star
18

envlight

Environment light tools.
Python
38
star
19

FocalLoss.pytorch

Implementation of focal loss in pytorch for unbalanced classification.
Python
35
star
20

dimr

[ECCV 2022] Disentangled Instance Mesh Reconstruction
Python
27
star
21

NotVeryFastNeRF

an unofficial and partial implementation of FastNeRF
Jupyter Notebook
25
star
22

note

notebook archive
PowerShell
19
star
23

3d_human_poser

a naive 3d human pose editor GUI.
Python
16
star
24

vscode-mesh-viewer

A 3D mesh viewer for vscode
JavaScript
16
star
25

CCA

CCA, DCCA, DCCAE, ConvCCA
Python
14
star
26

grid_put

An operation trying to do the opposite of F.grid_sample
Python
13
star
27

index_grid_sample

Extension to `F.grid_sample` that allows using batch index per grid point.
Cuda
12
star
28

made-in-heaven-timer

create timer videos at any speed.
Python
11
star
29

q10r

A simple web questionnaire application.
Python
6
star
30

ddddsr

A python library for end-to-end image super resolution.
Python
5
star
31

lightnet

light weight convolutional neural network implementation in one c++ file.
C++
5
star
32

bsp_cvae

Python
4
star
33

learn_matmul

Cuda
3
star
34

trojan-privoxy-client

for unraid proxy.
Dockerfile
2
star
35

numpytorch

Monkey-patched numpy with pytorch syntax
Python
2
star
36

point_seg_dist

a CUDA implementation of points to lines/segments distance
C
2
star
37

pytorch_ddp_examples

Python
1
star
38

uuunet

Python
1
star
39

fbxloader

FBX file loader for python (only supports geometry currently)
Python
1
star
40

unraid_tutorial

2021εΉ΄ηš„unraid搭建教程
1
star
41

Uncertainty

program to calculate uncertainty for Physics experiment.
Python
1
star
42

CapsNet.pytorch

reimplementation of capsule network for MNIST classification.
Python
1
star
43

nonsense

NoNSeNSe frontend.
JavaScript
1
star
44

JLGCN

Joing learning of graphs and features
Python
1
star
45

live-speech-recognition

A simple sliding window based real-time speech recognition example.
Python
1
star
46

dullPLYviewer

HTML
1
star
47

MaxClique

Heuristic algorithms to solve the max clique problem.
C++
1
star
48

hawtorch

pytorch extensions for code reuse
Python
1
star