MCPcopy Create free account
hub / github.com/Jiawei-Yang/FreeNeRF / predict_density

Method predict_density

internal/models.py:211–235  ·  view source on GitHub ↗

Helper function to output density.

(rng, means, covs, coord_freq_mask=None)

Source from the content-addressed store, hash-verified

209 dense_layer = functools.partial(nn.Dense, kernel_init=self.weight_init)
210
211 def predict_density(rng, means, covs, coord_freq_mask=None):
212 """Helper function to output density."""
213 # Encode input positions
214 inputs = mip.integrated_pos_enc(
215 (means, covs), self.min_deg_point, self.max_deg_point)
216 ## ---- add freq reg mask ----- ##
217 if coord_freq_mask is not None:
218 inputs = inputs * coord_freq_mask
219 ## ---------------------------- ##
220 # Evaluate network to output density
221 x = inputs
222 for i in range(self.net_depth):
223 x = dense_layer(self.net_width)(x)
224 x = self.net_activation(x)
225 if i % self.skip_layer == 0 and i > 0:
226 x = jnp.concatenate([x, inputs], axis=-1)
227 raw_density = dense_layer(1)(x)[Ellipsis, 0] # Hardcoded to a single channel.
228 # Add noise to regularize the density predictions if needed.
229 if (rng is not None) and (self.density_noise > 0):
230 key, rng = random.split(rng)
231 raw_density += self.density_noise * random.normal(
232 key, raw_density.shape, dtype=raw_density.dtype)
233 # Apply bias and activation to raw density
234 density = self.density_activation(raw_density + self.density_bias)
235 return density, x
236
237 means, covs = samples
238 ## ---- split freq reg mask to coordinates and viewdirs ----- ##

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected