Computer vision · From scratch

Instant NGP from Scratch

A deliberately compact PyTorch implementation of Instant Neural Graphics Primitives, written to make the core ideas behind fast neural reconstruction easier to understand.

PyTorchHash encodingRay marchingNeRF
Instant NGP reconstruction result
A learned reconstruction produced by the simplified Instant NGP pipeline.

The goal

Production implementations of neural graphics primitives are fast, but their optimizations can obscure the underlying algorithm. I built this version for people who learn best by reading code, keeping the training and rendering path small and annotating tensor shapes throughout.

What is inside

The implementation covers the essential pieces of Instant NGP while remaining close to a conventional NeRF pipeline.

  • Multiresolution hash encoding for compact spatial features.
  • Accelerated ray marching with early stopping.
  • Both 2D image fitting and 3D scene reconstruction through one configurable dimensionality value.
  • A familiar PyTorch training loop designed for experimentation.

Result

The same code path can reconstruct a two-dimensional image or a three-dimensional scene by changing the configured dimensionality. In the documented 2D experiment, the model reaches a PSNR of 26.12 while preserving a readable implementation that is easy to modify.