nerf-toy
A 2D toy illustration of Neural Radiance Fields
Description • Features • Examples • References • License
| 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
- NeRF Paper
- Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains
- Neural Tangent Kernel: Convergence and Generalization in Neural Networks
- NeRF Video
License
MIT
Image Credits
Release files for nerf-toy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nerf_toy-1.0.0.tar.gz | 11.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nerf_toy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.7 kB
Release files / nerf_toy-1.0.0.tar.gz
| Download URL | nerf_toy-1.0.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5da18129a7d3bea14d803ffdde30dcaf36817616cc4a8e94196c35b0756fc1e3
|
|
BLAKE2b-256 checksum How to use checksums |
91f6c4345f6025f9de5c1ee9941b940ad065bb94a2e27d67c87df545716ea23b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / nerf_toy-1.0.0-py3-none-any.whl
| Download URL | nerf_toy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06db5c003de3b8628c39c2e0f1c043115376349f0f54b8cadf8e73706e4f5c65
|
|
BLAKE2b-256 checksum How to use checksums |
fbb4bc0bc378c81aeea51a400e8a8ef9e144d0d742848f045208704a7031ff25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|