• Stars
    star
    436
  • Rank 96,363 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

Mega-NeRF

This repository contains the code needed to train Mega-NeRF models and generate the sparse voxel octrees used by the Mega-NeRF-Dynamic viewer.

The codebase for the Mega-NeRF-Dynamic viewer can be found here.

Note: This is a preliminary release and there may still be outstanding bugs.

Citation

@InProceedings{Turki_2022_CVPR,
    author    = {Turki, Haithem and Ramanan, Deva and Satyanarayanan, Mahadev},
    title     = {Mega-NERF: Scalable Construction of Large-Scale NeRFs for Virtual Fly-Throughs},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {12922-12931}
}

Demo

Setup

conda env create -f environment.yml
conda activate mega-nerf

The codebase has been mainly tested against CUDA >= 11.1 and V100/2080 Ti/3090 Ti GPUs. 1080 Ti GPUs should work as well although training will be much slower.

Pretrained Models

Trained with 8 submodules (to compare with main paper)

Larger models (trained with 25 submodules with 512 channels each)

Data

Mill 19

  • The Building scene can be downloaded here.
  • The Rubble scene can be downloaded here.

UrbanScene 3D

  1. Download the raw photo collections from the UrbanScene3D dataset
  2. Download the refined camera poses for one of the scenes below:
  1. Run python scripts/copy_images.py --image_path $RAW_PHOTO_PATH --dataset_path $CAMERA_POSE_PATH

Quad 6k Dataset

  1. Download the raw photo collections from here.
  2. Download the refined camera poses
  3. Run python scripts/copy_images.py --image_path $RAW_PHOTO_PATH --dataset_path $CAMERA_POSE_PATH

Custom Data

We strongly recommend using PixSFM to refine camera poses for your own datasets. Mega-NeRF also assumes that the dataset is properly geo-referenced/aligned such that the second value of its ray_altitude_range parameter properly corresponds to ground level. If using PixSFM/COLMAP the model_aligner utility might be helpful, with Manhattan world alignment being a possible fallback option if GPS alignment is not possible. We provide a script to convert from PixSFM/COLMAP output to the format Mega-NeRF expects.

If creating a custom dataset manually, the expected directory structure is:

  • /coordinates.pt: Torch file that should contain the following keys:
    • 'origin_drb': Origin of scene in real-world units
    • 'pose_scale_factor': Scale factor mapping from real-world unit (ie: meters) to [-1, 1] range
  • '/{val|train}/rgbs/': JPEG or PNG images
  • '/{val|train}/metadata/': Image-specific image metadata saved as a torch file. Each image should have a corresponding metadata file with the following file format: {rgb_stem}.pt. Each metadata file should contain the following keys:
    • 'W': Image width
    • 'H': Image height
    • 'intrinsics': Image intrinsics in the following form: [fx, fy, cx, cy]
    • 'c2w': Camera pose. 3x3 camera matrix with the convention used in the original NeRF repo, ie: x: down, y: right, z: backwards, followed by the following transformation: torch.cat([camera_in_drb[:, 1:2], -camera_in_drb[:, :1], camera_in_drb[:, 2:4]], -1)

Training

  1. Generate the training partitions for each submodule: python scripts/create_cluster_masks.py --config configs/mega-nerf/${DATASET_NAME}.yml --dataset_path $DATASET_PATH --output $MASK_PATH --grid_dim $GRID_X $GRID_Y
    • Note: this can be run across multiple GPUs by instead running python -m torch.distributed.run --standalone --nnodes=1 --nproc_per_node $NUM_GPUS --max_restarts 0 scripts/create_cluster_masks.py <args>
  2. Train each submodule: python mega_nerf/train.py --config_file configs/mega-nerf/${DATASET_NAME}.yml --exp_name $EXP_PATH --dataset_path $DATASET_PATH --chunk_paths $SCRATCH_PATH --cluster_mask_path ${MASK_PATH}/${SUBMODULE_INDEX}
    • Note: training with against full scale data will write hundreds of GBs / several TBs of shuffled data to disk. You can downsample the training data using train_scale_factor option.
    • Note: we provide a utility script based on parscript to start multiple training jobs in parallel. It can run through the following command: CONFIG_FILE=configs/mega-nerf/${DATASET_NAME}.yaml EXP_PREFIX=$EXP_PATH DATASET_PATH=$DATASET_PATH CHUNK_PREFIX=$SCRATCH_PATH MASK_PATH=$MASK_PATH python -m parscript.dispatcher parscripts/run_8.txt -g $NUM_GPUS
  3. Merge the trained submodules into a unified Mega-NeRF model: python scripts/merge_submodules.py --config_file configs/mega-nerf/${DATASET_NAME}.yaml --ckpt_prefix ${EXP_PREFIX}- --centroid_path ${MASK_PATH}/params.pt --output $MERGED_OUTPUT

Evaluation

Single-GPU evaluation: python mega_nerf/eval.py --config_file configs/nerf/${DATASET_NAME}.yaml --exp_name $EXP_NAME --dataset_path $DATASET_PATH --container_path $MERGED_OUTPUT

Multi-GPU evaluation: python -m torch.distributed.run --standalone --nnodes=1 --nproc_per_node $NUM_GPUS mega_nerf/eval.py --config_file configs/nerf/${DATASET_NAME}.yaml --exp_name $EXP_NAME --dataset_path $DATASET_PATH --container_path $MERGED_OUTPUT

Octree Extraction (for use by Mega-NeRF-Dynamic viewer)

python scripts/create_octree.py --config configs/mega-nerf/${DATASET_NAME}.yaml --dataset_path $DATASET_PATH --container_path $MERGED_OUTPUT --output $OCTREE_PATH

Acknowledgements

Large parts of this codebase are based on existing work in the nerf_pl, NeRF++, and Plenoctree repositories. We use svox to serialize our sparse voxel octrees and the generated structures should be largely compatible with that codebase.

More Repositories

1

openface

Face recognition with deep neural networks.
Lua
14,985
star
2

coda

Coda is an advanced networked filesystem. It has been developed at CMU since 1987 by the systems group of M. Satyanarayanan in the SCS department.
C++
129
star
3

OpenTPOD

Open Toolkit for Painless Object Detection
CSS
118
star
4

gabriel

Wearable cognitive assistance using cloudlets
Java
65
star
5

diamond-android

Android library for running Diamond filters
C
56
star
6

elijah-cloudlet

Elijah cloudlet system
43
star
7

mega-nerf-viewer

C++
43
star
8

faceswap

Demo Application for Cloudlet
Java
34
star
9

vmnetx

Virtual Machine Network Execution
Python
31
star
10

elijah-openstack

Elijah OpenStack integration
Python
27
star
11

openrtist

Live video frames from the camera are stylized to look like famous paintings.
Java
22
star
12

deltaic

An efficient backup system supporting multiple data sources
Python
21
star
13

wireguard-tools

Pure python reimplementation of wireguard-tools
Python
19
star
14

opendiamond

Interactive search of non-indexed data
Python
19
star
15

elijah-provisioning

Cloudlet provisioning using VM synthesis
Python
18
star
16

gammaray

Distributed Streaming Virtual Machine Introspection
C
16
star
17

dronesearch

Bandwidth-efficient Live Video Analytics for Drones via Edge Computing
Python
13
star
18

vmnetx-android

VMNetX for Android
Java
8
star
19

openscout

Distributed Automated Situational Awareness
Python
7
star
20

change-detection

Python
6
star
21

nephele

nephele is a CLI utility that provides capabilities to create, manage, and migrate KVM virtual machines over the wide-area network.
JavaScript
6
star
22

optviewer

Web viewer for 3D data in image stacks
HTML
5
star
23

sinfonia

Manage discovery of cloudlets and deployment of backends for edge-native applications
Python
4
star
24

elijah-discovery-basic

Basic cloudlet registration and discovery
Python
4
star
25

steeleagle

Automated drone flights for visual inspection tasks
Python
4
star
26

matlabfind

MATLAB filter for OpenDiamond
C
3
star
27

PyEdgeSim

Python
3
star
28

hyperfind

Generic image search application for OpenDiamond
Java
3
star
29

diamond-core-filters

Common filters used by Diamond applications
C
3
star
30

GigaSight

GigaSight project
Java
2
star
31

gabriel-lego

Python
2
star
32

minirpc

A TCP-based remote procedure call library
C
2
star
33

diamond-example

Diamond example code
Python
2
star
34

isr-next

OpenISR reimagined on the VMNetX codebase
Python
2
star
35

gabriel-ikea

Wearable Cognitive Assistant for assembling an Ikea lamp
Python
2
star
36

quiltview

Crowd-sourced, query-driven video of the real world via Google Glass
Python
2
star
37

kimberley

Transient customization of mobile computing infrastructure
C
2
star
38

vmnetx-packaging

Distribution packaging for VMNetX
Shell
2
star
39

linux-coda

Coda kernel module to build out-of-tree for Linux kernels
C
2
star
40

coda-packaging

Packaging files for Coda releases
Shell
2
star
41

dermshare

DermShare web application and filters
Python
2
star
42

coda-git-conversion

Scripts and files to assist in the conversion of the Coda CVS repositories to Git
Python
2
star
43

cloudlet-launcher

Java
2
star
44

strangefind

A Diamond anomaly detection application
Java
2
star
45

opendiamond-java

Java client library for OpenDiamond
Java
2
star
46

django-s3

Amazon S3 storage for Django
Python
1
star
47

sinfonia-tier3

Manage discovery of cloudlets and deployment of backends for edge-native applications
Python
1
star
48

gabriel-instruction

Clients for wearable cognitive assistance applications that provide instructions
C#
1
star
49

sec19-scalable-edge-native-applications

Towards scalable edge-native applications
Jupyter Notebook
1
star
50

opentpod-tools

Collection of command line tools to assist with extracting, merging, and training datasets from a CVAT installation.
Python
1
star
51

coda-doc

Source for the Coda Distributed File System's documentation
PostScript
1
star
52

gabriel-pingpong

Python
1
star
53

quetzal

Detection of Tunable and Explainable Salient Changes
Python
1
star
54

gabriel-python-common

Python
1
star
55

gabriel-stirling-engine

Wearable Cognitive Assistant for Stirling Engine
Java
1
star
56

NetworkLatencySegmentation

Python
1
star
57

gmapview

Python
1
star
58

OpenWorkflow

A suite of tools for creating wearable cognitive assistants.
JavaScript
1
star
59

rtface

Cloudlet-based Privacy Mediator
Python
1
star
60

openisr

Internet Suspend/Resume
C
1
star