INNER CODE UNIT · Python
c
yashbhalgat/HashNeRF-pytorch · hash_encoding.py:54
c = c0*(1-weights[:,2][:,None]) + c1*weights[:,2][:,None]
return c
def forward(self, x):
# x is 3D point position: B x 3
x_embedded_all = []
for i in range(self.n_levels):
resolution = torch.floor(self.base_resolution * self.b**i)
voxel_min_vertex, voxel_max_vertex, hashed_voxel_indices, keep_mask = get_voxel_vertices(\
x, self.bounding_box, \
resolution, self.log2_hashmap_size)
voxel_embedds = self.embeddings[i](hashed_voxel_indices)
x_embedded = self.trilinear_interp(x, voxel_min_vertex, voxel_max_vertex, voxel_embedds)
x_embedded_all.append(x_embedded)