Skip to main content

A 2D toy illustration of Neural Radiance Fields

Project description

Open Demo in Colab

Unit tests Build Python Versions PyPI Version PyPI status


nerf-toy

A 2D toy illustration of Neural Radiance Fields

DescriptionFeaturesExamplesReferencesLicense

Original No Mapping Basic Mapping Fourier Feature Mapping

Description

nerf-toy is a 2D toy illustration of the Neural Radiance Fields. Memorizing a 2D image using an MLP is a nice problem to understand before going into solving the problem NeRF tackles i.e. memorising a 3D scene given multiple view points.

The task is to produce the (r, g, b) value of an image as a function of (x,y) image coordinates. Our model is a coordinate-based multilayer perceptron.

This is implemented using 2D convolutions with a kernel size of (1, 1), which act as "pointwise" convolutions. This is equivalent to a densely connected multilayer perceptron for each coordinate. Also, we use batchnorm to speed up convergence.

The model is trained with the following input mappings $\gamma (\mathbf{v})$ for comparison :

  • No mapping: $\gamma(\mathbf{v})= \mathbf{v}$.

  • Basic mapping: $\gamma(\mathbf{v})=\left[ \cos(2 \pi \mathbf{v}),\sin(2 \pi \mathbf{v}) \right]^\mathrm{T}$.

  • Gaussian Fourier feature mapping: $\gamma(\mathbf{v})=\left[ \cos(2 \pi \mathbf B \mathbf{v}), \sin(2 \pi \mathbf B \mathbf{v}) \right]^\mathrm{T}$, where each entry in $\mathbf B \in \mathbb R^{m \times d}$ is sampled from $\mathcal N(0,\sigma^2)$

Features

  • Transforms: Basic, Positional Encoding and Gaussian Fourier Feature
  • Data loader for any input image, where filepath, image url or bytes can be passed as input
  • Keras based NeRF toy model, which can be customised based on number of layer and output channels
  • Metrics: PSNR , SSIM
  • Custom training callback: PredictionVideoSaverCallback, PlotLossesAndMetricsCallback
  • Utility functions to read and manipulate image

Examples

The demo notebook demonstrates the core idea with full model training from scratch.

Original No Mapping Basic Mapping Fourier Feature Mapping

It can be observed that directly regressing the (x, y) image coordinates results in blurry reconstructions.

Instead, lifting the input pixel coordinates (x, y) to higher dimensions via transformations (e.g. gaussian fourier feature) makes it easier for network to learn high frequency functions in low dimensional domains. Training with transformed (x, y) coordinates shows dramatic improvements in the results and can preserve the sharp edges in the image.

References

  1. NeRF Paper
  2. Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains
  3. Neural Tangent Kernel: Convergence and Generalization in Neural Networks
  4. NeRF Video

License

MIT

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

nerf_toy-0.0.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

nerf_toy-0.0.3-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file nerf_toy-0.0.3.tar.gz.

File metadata

  • Download URL: nerf_toy-0.0.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for nerf_toy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c0e8214085b02651386a484d2456043f950ae51c62d8cc9acb91fc4fd2c27e08
MD5 c17cd38d3ab9031a39aa06132d4eb70a
BLAKE2b-256 f00a00c4ea1e9c47ffa9d8e50278c7a5fec877e900bc0de6729dc2011f57b75a

See more details on using hashes here.

File details

Details for the file nerf_toy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nerf_toy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for nerf_toy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b94d41fdc4210a808d2d4b48204e6c975551d913b5c2ba78dd8d77861d46d2f3
MD5 99af566679c54e6887be5449560e93b0
BLAKE2b-256 206ef933793755d56c3b924916eef64b328de673f9c7ef38f35a133c65cd99f6

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