MCPcopy Create free account
hub / github.com/LeapLabTHU/ActiveNeRF / run_network

Function run_network

run_nerf.py:36–50  ·  view source on GitHub ↗

Prepares inputs and applies network 'fn'.

(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64)

Source from the content-addressed store, hash-verified

34
35
36def run_network(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64):
37 """Prepares inputs and applies network 'fn'.
38 """
39 inputs_flat = torch.reshape(inputs, [-1, inputs.shape[-1]])
40 embedded = embed_fn(inputs_flat)
41
42 if viewdirs is not None:
43 input_dirs = viewdirs[:,None].expand(inputs.shape)
44 input_dirs_flat = torch.reshape(input_dirs, [-1, input_dirs.shape[-1]])
45 embedded_dirs = embeddirs_fn(input_dirs_flat)
46 embedded = torch.cat([embedded, embedded_dirs], -1)
47
48 outputs_flat = batchify(fn, netchunk)(embedded)
49 outputs = torch.reshape(outputs_flat, list(inputs.shape[:-1]) + [outputs_flat.shape[-1]])
50 return outputs
51
52
53def batchify_rays(rays_flat, chunk=1024*32, **kwargs):

Callers 1

create_nerfFunction · 0.85

Calls 1

batchifyFunction · 0.85

Tested by

no test coverage detected