x is of shape [*, 2]. The last dimension are two coordinates (x and y).
(x, L=6, NORMALIZE_FACOR=1/300)
| 12 | import math |
| 13 | |
| 14 | def nerf_encoding(x, L=6, NORMALIZE_FACOR=1/300): |
| 15 | """ |
| 16 | x is of shape [*, 2]. The last dimension are two coordinates (x and y). |
| 17 | """ |
| 18 | freq_bands = 2.** torch.linspace(0, L, L-1).to(x.device) |
| 19 | return torch.cat([x*NORMALIZE_FACOR, torch.sin(3.14*x[..., -2:-1]*freq_bands*NORMALIZE_FACOR), torch.cos(3.14*x[..., -2:-1]*freq_bands*NORMALIZE_FACOR), torch.sin(3.14*x[..., -1:]*freq_bands*NORMALIZE_FACOR), torch.cos(3.14*x[..., -1:]*freq_bands*NORMALIZE_FACOR)], dim=-1) |
| 20 | |
| 21 | def sampler_gaussian(latent, mean, std, image_size, point_num=25): |
| 22 | # latent [B, H*W, D] |
nothing calls this directly
no outgoing calls
no test coverage detected