MCPcopy Create free account
hub / github.com/G-1nOnly/AniSDF / __init__

Method __init__

models/ide_encoder.py:62–97  ·  view source on GitHub ↗

Initialize integrated directional encoding (IDE) module. Args: deg_view: number of spherical harmonics degrees to use. Raises: ValueError: if deg_view is larger than 5.

(self, input_dim=3, deg_view=4)

Source from the content-addressed store, hash-verified

60 """
61
62 def __init__(self, input_dim=3, deg_view=4):
63 """Initialize integrated directional encoding (IDE) module.
64
65 Args:
66 deg_view: number of spherical harmonics degrees to use.
67
68 Raises:
69 ValueError: if deg_view is larger than 5.
70
71 """
72 super().__init__()
73 self.deg_view = deg_view
74
75 if deg_view > 5:
76 raise ValueError("Only deg_view of at most 5 is numerically stable.")
77
78 ml_array = get_ml_array(deg_view)
79 l_max = 2 ** (deg_view - 1)
80
81 # Create a matrix corresponding to ml_array holding all coefficients, which,
82 # when multiplied (from the right) by the z coordinate Vandermonde matrix,
83 # results in the z component of the encoding.
84 mat = np.zeros((l_max + 1, ml_array.shape[1]))
85 for i, (m, l) in enumerate(ml_array.T):
86 for k in range(l - m + 1):
87 mat[k, i] = sph_harm_coeff(l, m, k)
88
89 sigma = 0.5 * ml_array[1, :] * (ml_array[1, :] + 1)
90
91 self.register_buffer("mat", torch.Tensor(mat), False)
92 self.register_buffer("ml_array", torch.Tensor(ml_array), False)
93 self.register_buffer("pow_level", torch.arange(l_max + 1), False)
94 self.register_buffer("sigma", torch.Tensor(sigma), False)
95
96 self.n_input_dims = input_dim
97 self.n_output_dims = (2**deg_view - 1 + deg_view) * 2
98
99 def forward(self, xyz, roughness=0, **kwargs):
100 """Compute integrated directional encoding (IDE).

Callers

nothing calls this directly

Calls 2

get_ml_arrayFunction · 0.85
sph_harm_coeffFunction · 0.85

Tested by

no test coverage detected