mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 23:08:44 +08:00
Interpolation config for tcnn hashgrid (#1058)
* Interpolation config for tcnn hashgrid * Fixed ns-dev-test issues Co-authored-by: Alexander Demidko <ademidko@matterport.com>
This commit is contained in:
1 parent
c2ad46d60e
commit
bcbddf42d6
1 file changed
+19
-8
@@ -228,6 +228,7 @@ class HashEncoding(Encoding):
|
|||||||
features_per_level: Number of features per level.
|
features_per_level: Number of features per level.
|
||||||
hash_init_scale: Value to initialize hash grid.
|
hash_init_scale: Value to initialize hash grid.
|
||||||
implementation: Implementation of hash encoding. Fallback to torch if tcnn not available.
|
implementation: Implementation of hash encoding. Fallback to torch if tcnn not available.
|
||||||
|
interpolation: Interpolation override for tcnn hashgrid. Not supported for torch unless linear.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -239,6 +240,7 @@ class HashEncoding(Encoding):
|
|||||||
features_per_level: int = 2,
|
features_per_level: int = 2,
|
||||||
hash_init_scale: float = 0.001,
|
hash_init_scale: float = 0.001,
|
||||||
implementation: Literal["tcnn", "torch"] = "tcnn",
|
implementation: Literal["tcnn", "torch"] = "tcnn",
|
||||||
|
interpolation: Optional[Literal["Nearest", "Linear", "Smoothstep"]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
super().__init__(in_dim=3)
|
super().__init__(in_dim=3)
|
||||||
@@ -260,18 +262,27 @@ class HashEncoding(Encoding):
|
|||||||
if not TCNN_EXISTS and implementation == "tcnn":
|
if not TCNN_EXISTS and implementation == "tcnn":
|
||||||
print_tcnn_speed_warning("HashEncoding")
|
print_tcnn_speed_warning("HashEncoding")
|
||||||
elif implementation == "tcnn":
|
elif implementation == "tcnn":
|
||||||
|
encoding_config = {
|
||||||
|
"otype": "HashGrid",
|
||||||
|
"n_levels": self.num_levels,
|
||||||
|
"n_features_per_level": self.features_per_level,
|
||||||
|
"log2_hashmap_size": self.log2_hashmap_size,
|
||||||
|
"base_resolution": min_res,
|
||||||
|
"per_level_scale": growth_factor,
|
||||||
|
}
|
||||||
|
if interpolation is not None:
|
||||||
|
encoding_config["interpolation"] = interpolation
|
||||||
|
|
||||||
self.tcnn_encoding = tcnn.Encoding(
|
self.tcnn_encoding = tcnn.Encoding(
|
||||||
n_input_dims=3,
|
n_input_dims=3,
|
||||||
encoding_config={
|
encoding_config=encoding_config,
|
||||||
"otype": "HashGrid",
|
|
||||||
"n_levels": self.num_levels,
|
|
||||||
"n_features_per_level": self.features_per_level,
|
|
||||||
"log2_hashmap_size": self.log2_hashmap_size,
|
|
||||||
"base_resolution": min_res,
|
|
||||||
"per_level_scale": growth_factor,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not TCNN_EXISTS or self.tcnn_encoding is None:
|
||||||
|
assert (
|
||||||
|
interpolation is None or interpolation == "Linear"
|
||||||
|
), f"interpolation '{interpolation}' is not supported for torch encoding backend"
|
||||||
|
|
||||||
def get_out_dim(self) -> int:
|
def get_out_dim(self) -> int:
|
||||||
return self.num_levels * self.features_per_level
|
return self.num_levels * self.features_per_level
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user