MCPcopy Create free account
hub / github.com/drinkingcoder/FlowFormer-Official / nerf_encoding

Function nerf_encoding

core/FlowFormer/common.py:14–19  ·  view source on GitHub ↗

x is of shape [*, 2]. The last dimension are two coordinates (x and y).

(x, L=6, NORMALIZE_FACOR=1/300)

Source from the content-addressed store, hash-verified

12import math
13
14def 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
21def sampler_gaussian(latent, mean, std, image_size, point_num=25):
22 # latent [B, H*W, D]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected