Mip-NeRF: A Multiscale Representation for Anti-Aliasing Neural Radiance Fields.

Overview

mip-NeRF

This repository contains the code release for Mip-NeRF: A Multiscale Representation for Anti-Aliasing Neural Radiance Fields. This implementation is written in JAX, and is a fork of Google's JaxNeRF implementation. Contact Jon Barron if you encounter any issues.

rays

Abstract

The rendering procedure used by neural radiance fields (NeRF) samples a scene with a single ray per pixel and may therefore produce renderings that are excessively blurred or aliased when training or testing images observe scene content at different resolutions. The straightforward solution of supersampling by rendering with multiple rays per pixel is impractical for NeRF, because rendering each ray requires querying a multilayer perceptron hundreds of times. Our solution, which we call "mip-NeRF" (à la "mipmap"), extends NeRF to represent the scene at a continuously-valued scale. By efficiently rendering anti-aliased conical frustums instead of rays, mip-NeRF reduces objectionable aliasing artifacts and significantly improves NeRF's ability to represent fine details, while also being 7% faster than NeRF and half the size. Compared to NeRF, mip-NeRF reduces average error rates by 17% on the dataset presented with NeRF and by 60% on a challenging multiscale variant of that dataset that we present. mip-NeRF is also able to match the accuracy of a brute-force supersampled NeRF on our multiscale dataset while being 22x faster.

Installation

We recommend using Anaconda to set up the environment. Run the following commands:

# Clone the repo
git clone https://github.com/google/mipnerf.git
# Create a conda environment, note you can use python 3.6-3.8 as
# one of the dependencies (TensorFlow) hasn't supported python 3.9 yet.
conda create --name mipnerf python=3.6.13; conda activate mipnerf
# Prepare pip
conda install pip; pip install --upgrade pip
# Install requirements
pip install -r requirements.txt

[Optional] Install GPU and TPU support for Jax

# Remember to change cuda101 to your CUDA version, e.g. cuda110 for CUDA 11.0.
pip install --upgrade jax jaxlib==0.1.65+cuda101 -f https://storage.googleapis.com/jax-releases/jax_releases.html

Data

Then, you'll need to download the datasets from the NeRF official Google Drive. Please download and unzip nerf_synthetic.zip and nerf_llff_data.zip.

TODO(bmild): Add instructions for synthesizing the multiscale Blender dataset.

Running

Example scripts for training mip-NeRF on individual scenes from the three datasets used in the paper can be found in scripts/. You'll need to change the paths to point to wherever the datasets are located. Gin configuration files for our model and some ablations can be found in configs/. An example script for evaluating on the test set of each scene can be found in scripts/, after which you can use scripts/summarize.ipynb to produce error metrics across all scenes in the same format as was used in tables in the paper.

Citation

If you use this software package, please cite our paper:

@misc{barron2021mipnerf,
      title={Mip-NeRF: A Multiscale Representation for Anti-Aliasing Neural Radiance Fields},
      author={Jonathan T. Barron and Ben Mildenhall and Matthew Tancik and Peter Hedman and Ricardo Martin-Brualla and Pratul P. Srinivasan},
      year={2021},
      eprint={2103.13415},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Acknowledgements

Thanks to Boyang Deng for JaxNeRF.

Comments
  • Question about mipnerf360

    Question about mipnerf360

    Hello! Sorry if this is the wrong place to post this question. In mipnerf, during inference, LLFF scenes have their near and far distances set as 0 and 1 with the use of NDC. However in mipnerf360, during training, without the usage of NDC, I assume near and far distances are used directly from the COLMAP calculations. If so, how do you set these values during inference? Has it got something to do with the contract(.) operator? Or perhaps I am approaching this wrongly?

    opened by Bingrong89 4
  • IPE explained

    IPE explained

    Hello. First of all, thank you for sharing this great work.

    I would like to kindly ask you to elaborate more on how did you derive the formulas for IPE.

    Why do you concatenate it this way? image

    How did you get the formula for the y_var? image

    I cannot quiet get it from the article. Thank you :)

    opened by theFilipko 4
  • Why positional encoding for viewing direction?

    Why positional encoding for viewing direction?

    Positional encoding (PE) or IPE is required to allow NeRF/MipNeRF learn high frequencies. I understand that volume density and color as a function of 3d point can have discontinuities, especially at object boundaries. However, for a given 3d position, the color as a function of viewing direction is a smooth function, right? I can't imagine a scenario where it may have high frequencies. So, why do we need PE for viewing direction?

    @jonbarron, I've pondered over this question for quite some time now, but didn't understand. Any intuition will be helpful.

    opened by NagabhushanSN95 3
  • Radii computation with and without NDC

    Radii computation with and without NDC

    The radii computation code is different for non-ndc and ndc spaces. In particular, without ndc, radii computation uses only dx derived from directions, but when ndc is enabled, (dx+dy)/2 is used, which is derived from ndc_origins. Can you please shed some light on why it is done so?

    opened by NagabhushanSN95 3
  • keras version match tensorflow

    keras version match tensorflow

    Hi, when I am trying to reproduce the result, I installed on cuda10.1 py3.6 tensorflow2.3.1, keras2.7.0

    Then I met the issue when I import tensorflow, and from keras import optimizers,

    "another metric with the same name already exists".

    I would like to know what's the version you use during your experiments?

    Thanks in advance!

    opened by hanxuel 3
  • origins and directions issues

    origins and directions issues

    hi,thanks for your exciting work.I have one question. In the code,the initialization values of directions are (x,y,1),so i think the values of origins should be (x,y,0).So,the values of directions are Xdirections=R*Xc+t,the values of origins are Xdirections-R[0:3,2].

    opened by haiz20060684 2
  • Is it safe to use unnormalized ray directions while sampling points?

    Is it safe to use unnormalized ray directions while sampling points?

    Hi,

    While sampling points along rays, the code uses rays.directions for the direction vectors instead of rays.viewdirs. https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/models.py#L70-L81

    Original NeRF uses normalized direction vectors for the sampling points. Can you clarify if we need to replace rays.directions with rays.viewdirs?

    opened by nitchith 2
  • Question about CPU OOM.

    Question about CPU OOM.

    I use the following command to train on multiscale datasets, but get "killed" output.

    bash ./scripts/train_multiblender.sh
    

    I have generated multiscale datesets, and changed the correct path in ./scripts/train_multiblender.sh. It works well on ./scripts/train_blender.sh with original datasets.

    My computer has 16G MEM and 4G SWAP and I'd like to know the minimum requirements.

    Thanks.

    opened by MZhao-ouo 2
  • Are the signs inverted on rgb padding?

    Are the signs inverted on rgb padding?

    After the sigmoid activation I noticed that you are doing this

    rgb = rgb * (1 + 2 * self.rgb_padding) - self.rgb_padding
    

    where rgb_padding = 0.001 by default.

    Is this intentional or did you mean to move the range to (rgb_padding, 1 - rgb_padding)?

    opened by samedii 2
  • Reconstructing using colmap poses

    Reconstructing using colmap poses

    If we estimate the poses of the lego dataset using colmap, will it work? I tried doing the same, and tried training it using train_llff.sh but it showed inconsistent results.

    opened by nishant34 2
  • Tiny typo in supplemental material

    Tiny typo in supplemental material

    Hi! Thanks for sharing the great work!

    I was just going through the paper and might find a tiny typo. So I am posting an issue in case you did not already notice. In the 1st section of supplemental material, I guess it should be (sinθ)^2 here instead of sinθ.

    Screen_2022-09-15_15-40-57

    opened by Leviosaaaa 1
  • Use normalized direction vector or not?

    Use normalized direction vector or not?

    AS you said: in https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L193

    BUT you use directions (not-norm) rather than viewdirs (unit-norm): https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L187-L195 This is different,right? https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/datasets.py#L194-L200 If you use directions (not-norm) ,dx (or radii) will be the same for different pixel rays in the image . If you use viewdirs (unit-norm), dx (or radii) will be smaller for pixel rays away from image center, and bigger for pixel rays around image center.

    opened by qhdqhd 1
  • Is dx (or base_radius of cone) all the same for rays of different pixel in a picture?

    Is dx (or base_radius of cone) all the same for rays of different pixel in a picture?

    `

    Distance from each unit-norm direction vector to its x-axis neighbor.
    
    dx = [
        np.sqrt(np.sum((v[:-1, :, :] - v[1:, :, :])**2, -1)) for v in directions
    ]
    
    dx = [np.concatenate([v, v[-2:-1, :]], 0) for v in dx]
    
    # Cut the distance in half, and then round it out so that it's
    # halfway between inscribed by / circumscribed about the pixel.
    
    radii = [v[..., None] * 2 / np.sqrt(12) for v in dx]`
    
    opened by qhdqhd 0
  • A confusion about the order of sin and cos in the IPE part

    A confusion about the order of sin and cos in the IPE part

    https://github.com/google/mipnerf/blob/84c969e0a623edd183b75693aed72a7e7c22902d/internal/mip.py#L183

    Hello author! I recently tried to reproduce the mip-nerf by myself, and found a doubt about the IPE part.

    In NeRF it is coded in the order of [(sinx,cosx),...], while Mip-NeRF seems to put the sinx-related ones together, followed by the cosx-related ones,[(sinx , ...),(cosx , ...)], as the following equation shows:

    image

    So I'm curious, have you tried coding in the same order as in NeRF, or does the current coding layout work better? Thank you so much! I just noticed this while writing the code, so I wanted to ask for some advice

    opened by YZsZY 3
  • scripts/train_blender.sh: line 31: 11426 Segmentation fault (core dumped)

    scripts/train_blender.sh: line 31: 11426 Segmentation fault (core dumped)

    Hi,

    I ran the command

    bash scripts/train_blender.sh
    

    and the terminal indicated the following error:

    scripts/train_blender.sh: line 31: 11426 Segmentation fault (core dumped) python -m train --data_dir=$DATA_DIR --train_dir=$TRAIN_DIR --gin_file=configs/blender.gin --logtostderr

    Could you tell me how to address it? Thanks

    opened by andrewsilver1997 0
  • average error matrics in paper

    average error matrics in paper

    hi,thanks for your exciting work.I have two question about avg matrics.

    first,I'm confused about the meaning of avg matric,will there be more advantages?

    second,I find that when you compute MSE from PSNR,the implementation ofthe code in is different from that in the paper. so I'm a bit confunsed. Can you help me ?

    opened by dlutzzw 2
Owner
Google
Google ❤️ Open Source
Google
(Arxiv 2021) NeRF--: Neural Radiance Fields Without Known Camera Parameters

NeRF--: Neural Radiance Fields Without Known Camera Parameters Project Page | Arxiv | Colab Notebook | Data Zirui Wang¹, Shangzhe Wu², Weidi Xie², Min

Active Vision Laboratory 411 Dec 26, 2022
Unofficial & improved implementation of NeRF--: Neural Radiance Fields Without Known Camera Parameters

[Unofficial code-base] NeRF--: Neural Radiance Fields Without Known Camera Parameters [ Project | Paper | Official code base ] ⬅️ Thanks the original

Jianfei Guo 239 Dec 22, 2022
This repository contains a PyTorch implementation of "AD-NeRF: Audio Driven Neural Radiance Fields for Talking Head Synthesis".

AD-NeRF: Audio Driven Neural Radiance Fields for Talking Head Synthesis | Project Page | Paper | PyTorch implementation for the paper "AD-NeRF: Audio

null 551 Dec 29, 2022
Code release for DS-NeRF (Depth-supervised Neural Radiance Fields)

Depth-supervised NeRF: Fewer Views and Faster Training for Free Project | Paper | YouTube Pytorch implementation of our method for learning neural rad

null 524 Jan 8, 2023
A PyTorch implementation of NeRF (Neural Radiance Fields) that reproduces the results.

NeRF-pytorch NeRF (Neural Radiance Fields) is a method that achieves state-of-the-art results for synthesizing novel views of complex scenes. Here are

Yen-Chen Lin 3.2k Jan 8, 2023
D-NeRF: Neural Radiance Fields for Dynamic Scenes

D-NeRF: Neural Radiance Fields for Dynamic Scenes [Project] [Paper] D-NeRF is a method for synthesizing novel views, at an arbitrary point in time, of

Albert Pumarola 291 Jan 2, 2023
Code release for NeRF (Neural Radiance Fields)

NeRF: Neural Radiance Fields Project Page | Video | Paper | Data Tensorflow implementation of optimizing a neural representation for a single scene an

null 6.5k Jan 1, 2023
Pytorch implementation for A-NeRF: Articulated Neural Radiance Fields for Learning Human Shape, Appearance, and Pose

A-NeRF: Articulated Neural Radiance Fields for Learning Human Shape, Appearance, and Pose Paper | Website | Data A-NeRF: Articulated Neural Radiance F

Shih-Yang Su 172 Dec 22, 2022
A minimal TPU compatible Jax implementation of NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis

NeRF Minimal Jax implementation of NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis. Result of Tiny-NeRF RGB Depth

Soumik Rakshit 11 Jul 24, 2022
Point-NeRF: Point-based Neural Radiance Fields

Point-NeRF: Point-based Neural Radiance Fields Project Sites | Paper | Primary c

Qiangeng Xu 662 Jan 1, 2023
Unofficial pytorch-lightning implement of Mip-NeRF

mipnerf_pl Unofficial pytorch-lightning implement of Mip-NeRF, Here are some results generated by this repository (pre-trained models are provided bel

Jianxin Huang 159 Dec 23, 2022
This is the code for "HyperNeRF: A Higher-Dimensional Representation for Topologically Varying Neural Radiance Fields".

HyperNeRF: A Higher-Dimensional Representation for Topologically Varying Neural Radiance Fields This is the code for "HyperNeRF: A Higher-Dimensional

Google 702 Jan 2, 2023
Instant-nerf-pytorch - NeRF trained SUPER FAST in pytorch

instant-nerf-pytorch This is WORK IN PROGRESS, please feel free to contribute vi

null 94 Nov 22, 2022
With this package, you can generate mixed-integer linear programming (MIP) models of trained artificial neural networks (ANNs) using the rectified linear unit (ReLU) activation function

With this package, you can generate mixed-integer linear programming (MIP) models of trained artificial neural networks (ANNs) using the rectified linear unit (ReLU) activation function. At the moment, only TensorFlow sequential models are supported. Interfaces to either the Pyomo or Gurobi modeling environments are offered.

ChemEngAI 40 Dec 27, 2022
Eff video representation - Efficient video representation through neural fields

Neural Residual Flow Fields for Efficient Video Representations 1. Download MPI

null 41 Jan 6, 2023
This is the code for Deformable Neural Radiance Fields, a.k.a. Nerfies.

Deformable Neural Radiance Fields This is the code for Deformable Neural Radiance Fields, a.k.a. Nerfies. Project Page Paper Video This codebase conta

Google 1k Jan 9, 2023
Open source repository for the code accompanying the paper 'Non-Rigid Neural Radiance Fields Reconstruction and Novel View Synthesis of a Deforming Scene from Monocular Video'.

Non-Rigid Neural Radiance Fields This is the official repository for the project "Non-Rigid Neural Radiance Fields: Reconstruction and Novel View Synt

Facebook Research 296 Dec 29, 2022
Code for KiloNeRF: Speeding up Neural Radiance Fields with Thousands of Tiny MLPs

KiloNeRF: Speeding up Neural Radiance Fields with Thousands of Tiny MLPs Check out the paper on arXiv: https://arxiv.org/abs/2103.13744 This repo cont

Christian Reiser 373 Dec 20, 2022
PyTorch implementation for MINE: Continuous-Depth MPI with Neural Radiance Fields

MINE: Continuous-Depth MPI with Neural Radiance Fields Project Page | Video PyTorch implementation for our ICCV 2021 paper. MINE: Towards Continuous D

Zijian Feng 325 Dec 29, 2022