This is a pytorch implementation of paper Instant Neural Graphics Primitives with a Multiresolution Hash Encoding.
If you are good at learning concepts from code, this repo is for you!
The codebase is intentionally simplified to facilitate better understanding of the core concepts with comments showing each tensor's shape which I think makes the code much more readable.
In fact, if you are coming from my previous repo NeRF_from_scratch, you will see that this implementation mainly changes just the model.py without changing any ray marching or rendering or training loop. (Try git diff with initial commit)
The elegant part about this pytorch implementation is that to make the model work for 2D or 3D demo, you only need to set value of d
in conf.yaml
to either 2 or 3 and all functions behave exactly the same.
If you found this repo useful, please leave a star! ⭐️
- Multiresolution hash encoding
- Accelerated ray marching
- Early stopping
- (2D) image and (3D) scene reconstruction support
- SDF reconstruction support (in progress)
- Exponential stepping (to be implemented)
-
Clone the repository
git clone https://github.com/HrushikeshBudhale/NeRF_from_scratch.git
-
Create conda environment
conda create -n nerf python=3.10 conda activate nerf
-
Install dependencies
pip install -r requirements.txt
-
Download dataset
For 2D image reconstruction you can use megapixel Tokyo image. For 3D scene reconstruction you can use lego scene.
-
Set the dataset path and other parameters in
conf.yaml
. -
Run the code
python train_nerf.py python test_nerf.py
Rendered 2D image from the model (PSNR: 26.12)
Comparison of ground truth (left) with model's output (right)
PSNR score of the model