Prepares inputs and applies network 'fn'.
(inputs, viewdirs, fn, embed_fn, embeddirs_fn, netchunk=1024*64)
| 34 | |
| 35 | |
| 36 | def 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 | |
| 53 | def batchify_rays(rays_flat, chunk=1024*32, **kwargs): |
no test coverage detected