From e9a5a66a5487067115983a3320ef945c65f09b09 Mon Sep 17 00:00:00 2001 From: hyperzy <50564821+hyperzy@users.noreply.github.com> Date: Wed, 12 Jul 2023 00:02:48 +0800 Subject: [PATCH] Default fied_heads with instances will cause shared parameters (#2197) * - Bug report. Modified the default parameters of NeRFField to avoid shared RGBFieldHead * - Modified to ensure minimal changes * - Modified type checking --- nerfstudio/fields/vanilla_nerf_field.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nerfstudio/fields/vanilla_nerf_field.py b/nerfstudio/fields/vanilla_nerf_field.py index 96ef0dc56..c9d2bbb78 100644 --- a/nerfstudio/fields/vanilla_nerf_field.py +++ b/nerfstudio/fields/vanilla_nerf_field.py @@ -15,7 +15,7 @@ """Classic NeRF field""" -from typing import Dict, Optional, Tuple +from typing import Dict, Optional, Tuple, Type import torch from torch import Tensor, nn @@ -57,7 +57,7 @@ class NeRFField(Field): head_mlp_num_layers: int = 2, head_mlp_layer_width: int = 128, skip_connections: Tuple[int] = (4,), - field_heads: Optional[Tuple[FieldHead]] = (RGBFieldHead(),), + field_heads: Optional[Tuple[Type[FieldHead]]] = (RGBFieldHead,), use_integrated_encoding: bool = False, spatial_distortion: Optional[SpatialDistortion] = None, ) -> None: @@ -83,7 +83,7 @@ class NeRFField(Field): ) self.field_output_density = DensityFieldHead(in_dim=self.mlp_base.get_out_dim()) - self.field_heads = nn.ModuleList(field_heads) + self.field_heads = nn.ModuleList([field_head() for field_head in field_heads] if field_heads else []) # type: ignore for field_head in self.field_heads: field_head.set_in_dim(self.mlp_head.get_out_dim()) # type: ignore