semantic_nerfw_configurability (#1467)

* fix semseg vis

* semantic configs

* change defaults

* Fix type

* format

* fix imports

* suggested fix for issue 1465

* fix docstring placement; avoid log spam and runtime errors

`nerfstudio\models\semantic_nerfw.py:81: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  self.colormap = torch.tensor(self.semantics.colors).to(self.device)`

* hide semantics output choice, since it kills the viewer

* revert some changes

* caps

* move both image and mask to GPU to avoid runtime error

as suggested in https://github.com/nerfstudio-project/nerfstudio/issues/1465#issuecomment-1441117562

---------

Co-authored-by: machenmusik <machenmusik@users.noreply.github.com>
This commit is contained in:
Nikhil Mohanandmachenmusik authored and GitHub committed 2023-02-22 22:21:04 -05:00
1 parent 69fdc7db9c
commit a91b92f89d
5 files changed
+25 -14

No files matched your search

+6 -7
View File
@@ -109,6 +109,7 @@ class TCNNNerfactoField(Field):
use_transient_embedding: bool = False,
use_semantics: bool = False,
num_semantic_classes: int = 100,
pass_semantic_gradients: bool = False,
use_pred_normals: bool = False,
use_average_appearance_embedding: bool = False,
spatial_distortion: Optional[SpatialDistortion] = None,
@@ -126,6 +127,7 @@ class TCNNNerfactoField(Field):
self.use_transient_embedding = use_transient_embedding
self.use_semantics = use_semantics
self.use_pred_normals = use_pred_normals
self.pass_semantic_gradients = pass_semantic_gradients
base_res = 16
features_per_level = 2
@@ -291,13 +293,10 @@ class TCNNNerfactoField(Field):
# semantics
if self.use_semantics:
density_embedding_copy = density_embedding.clone().detach()
semantics_input = torch.cat(
[
density_embedding_copy.view(-1, self.geo_feat_dim),
],
dim=-1,
)
semantics_input = density_embedding.view(-1, self.geo_feat_dim)
if not self.pass_semantic_gradients:
semantics_input = semantics_input.detach()
x = self.mlp_semantics(semantics_input).view(*outputs_shape, -1).to(directions)
outputs[FieldHeadNames.SEMANTICS] = self.field_head_semantics(x)