Prepares inputs and applies network 'fn'.
(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64)
| 21 | |
| 22 | |
| 23 | def run_network(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64): |
| 24 | """Prepares inputs and applies network 'fn'. |
| 25 | """ |
| 26 | inputs_flat = torch.reshape(inputs, [-1, inputs.shape[-1]]) |
| 27 | embedded = embed_fn(inputs_flat) |
| 28 | |
| 29 | if viewdirs is not None: |
| 30 | input_dirs = viewdirs[:,None].expand(inputs.shape) |
| 31 | input_dirs_flat = torch.reshape(input_dirs, [-1, input_dirs.shape[-1]]) |
| 32 | embedded_dirs = embeddirs_fn(input_dirs_flat) |
| 33 | embedded = torch.cat([embedded, embedded_dirs], -1) |
| 34 | |
| 35 | outputs_flat = batchify(fn, netchunk)(embedded) |
| 36 | outputs = torch.reshape(outputs_flat, list(inputs.shape[:-1]) + [outputs_flat.shape[-1]]) |
| 37 | return outputs |
| 38 | |
| 39 | def run_network_DNeRF(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64, epoch=None, no_DNeRF_viewdir=False): |
| 40 | """Prepares inputs and applies network 'fn'. |
no test coverage detected