Repository: nerfstudio-project/nerfstudio

Issue:
AttributeError: 'SemanticDataManager' object has no attribute 'train_dataparser_outputs'
**Describe the bug**
When I try to run `semantic-nerfw` on the `friends` dataset by following the instructions on the official document. The training doesn't proceed and it gives me the `AttributeError` shown in the title

**To Reproduce**
Steps to reproduce the behavior:
1. download the `friends` dataset
2. run `ns-download-data friends`
3. run `ns-train semantic-nerfw`

**Traceback**
```
Traceback (most recent call last):
  File "/home/yiming/anaconda3/envs/nerfstudio/bin/ns-train", line 8, in <module>
    sys.exit(entrypoint())
  File "/home/yiming/nerfstudio/scripts/train.py", line 248, in entrypoint
    main(
  File "/home/yiming/nerfstudio/scripts/train.py", line 234, in main
    launch(
  File "/home/yiming/nerfstudio/scripts/train.py", line 173, in launch
    main_func(local_rank=0, world_size=world_size, config=config)
  File "/home/yiming/nerfstudio/scripts/train.py", line 88, in train_loop
    trainer.train()
  File "/home/yiming/nerfstudio/nerfstudio/engine/trainer.py", line 152, in train
    self.pipeline.datamanager.train_dataparser_outputs.save_dataparser_transform(
  File "/home/yiming/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1207, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'SemanticDataManager' object has no attribute 'train_dataparser_outputs'
```



Discussion:

Resolving patch:
diff --git a/nerfstudio/data/datamanagers/base_datamanager.py b/nerfstudio/data/datamanagers/base_datamanager.py
--- a/nerfstudio/data/datamanagers/base_datamanager.py
+++ b/nerfstudio/data/datamanagers/base_datamanager.py
@@ -314,6 +314,7 @@ def __init__(
         self.test_mode = test_mode
         self.test_split = "test" if test_mode in ["test", "inference"] else "val"
         self.dataparser = self.config.dataparser.setup()
+        self.train_dataparser_outputs = self.dataparser.get_dataparser_outputs(split="train")
 
         self.train_dataset = self.create_train_dataset()
         self.eval_dataset = self.create_eval_dataset()
@@ -321,7 +322,6 @@ def __init__(
 
     def create_train_dataset(self) -> InputDataset:
         """Sets up the data loaders for training"""
-        self.train_dataparser_outputs = self.dataparser.get_dataparser_outputs(split="train")
         return InputDataset(
             dataparser_outputs=self.train_dataparser_outputs,
             scale_factor=self.config.camera_res_scale_factor,
diff --git a/nerfstudio/data/datamanagers/semantic_datamanager.py b/nerfstudio/data/datamanagers/semantic_datamanager.py
--- a/nerfstudio/data/datamanagers/semantic_datamanager.py
+++ b/nerfstudio/data/datamanagers/semantic_datamanager.py
@@ -42,7 +42,7 @@ class SemanticDataManager(VanillaDataManager):  # pylint: disable=abstract-metho
 
     def create_train_dataset(self) -> SemanticDataset:
         return SemanticDataset(
-            dataparser_outputs=self.dataparser.get_dataparser_outputs(split="train"),
+            dataparser_outputs=self.train_dataparser_outputs,
             scale_factor=self.config.camera_res_scale_factor,
         )
 
diff --git a/nerfstudio/data/dataparsers/base_dataparser.py b/nerfstudio/data/dataparsers/base_dataparser.py
--- a/nerfstudio/data/dataparsers/base_dataparser.py
+++ b/nerfstudio/data/dataparsers/base_dataparser.py
@@ -82,7 +82,7 @@ def save_dataparser_transform(self, path: Path):
         """
         data = {
             "transform": self.dataparser_transform.tolist(),
-            "scale": self.dataparser_scale,
+            "scale": float(self.dataparser_scale),
         }
         if not path.parent.exists():
             path.parent.mkdir(parents=True)


Test patch: