Training a NeRF model
In this section, we are going to train a simple NeRF model on images generated from the synthetic cow model. We are only going to instantiate the NeRF model without worrying about how it is implemented. The implementation details are covered in the next section. A single neural network (NeRF model) is trained to represent a single 3D scene. The following codes can be found in train_nerf.py
, which can be found in this chapter’s GitHub repository. It is modified from a PyTorch3D tutorial. Let us go through the code to train a NeRF model on the synthetic cow scene:
- First, let us import the standard modules:
import torch import matplotlib.pyplot as plt
- Next, let us import the functions and classes used for rendering. These are
pytorch3d
data structures:from pytorch3d.renderer import ( FoVPerspectiveCameras, NDCMultinomialRaysampler, MonteCarloRaysampler, EmissionAbsorptionRaymarcher, ImplicitRenderer, ) from utils.helper_functions import (generate_rotating_nerf...