hturki / pynerf

Pyramidal Neural Radiance Fields
56 stars 6 forks source link

ns-train pynerf --vis viewer+wandb colmap --data data/xxx #6

Open wanger-666 opened 8 months ago

wanger-666 commented 8 months ago

Traceback (most recent call last): File "F:\miniconda3\envs\nerfstudio-gs\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "F:\miniconda3\envs\nerfstudio-gs\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "F:\miniconda3\envs\nerfstudio-gs\Scripts\ns-train.exe__main.py", line 7, in File "D:\nerfstudio-gs\nerfstudio\nerfstudio\scripts\train.py", line 262, in entrypoint main( File "D:\nerfstudio-gs\nerfstudio\nerfstudio\scripts\train.py", line 247, in main launch( File "D:\nerfstudio-gs\nerfstudio\nerfstudio\scripts\train.py", line 189, in launch main_func(local_rank=0, world_size=world_size, config=config) File "D:\nerfstudio-gs\nerfstudio\nerfstudio\scripts\train.py", line 99, in train_loop trainer.setup() File "D:\nerfstudio-gs\nerfstudio\nerfstudio\engine\trainer.py", line 147, in setup self.pipeline = self.config.pipeline.setup( File "D:\nerfstudio-gs\nerfstudio\nerfstudio\configs\base_config.py", line 54, in setup return self._target(self, **kwargs) File "D:\nerfstudio-gs\nerfstudio\nerfstudio\pipelines\base_pipeline.py", line 258, in init self.datamanager: DataManager = config.datamanager.setup( File "D:\nerfstudio-gs\nerfstudio\nerfstudio\configs\base_config.py", line 54, in setup return self._target(self, **kwargs) File "D:\nerfstudio-gs\nerfstudio\pynerf\pynerf\data\datamanagers\random_subset_datamanager.py", line 96, in init self.train_ray_generator = RayGenerator(self.train_dataparser_outputs.cameras.to(self.device), TypeError: init__() takes 2 positional arguments but 3 were given

hturki commented 8 months ago

What version of nerfstudio are you using? The current code in this repo should work for v3.4.0, but I think there were recent changes on nerfstudio's main branch that changed the data API a bit.

wanger-666 commented 8 months ago

My version is when "Add PyNeRF external method #2734" was merged on January 10, 2024.The version number v3.4.0 hasn't changed in a long time.

hturki commented 8 months ago

Understood and agreed that it's not ideal, it's just that the data API has since changed and I'm hesitant to change the main branch of this repo until another tagged release comes out. If you want to use nerfstudio main, you can try modifying the constructors accordingly (ie: remove the camera optimizer arg):

+++ b/pynerf/data/datamanagers/random_subset_datamanager.py
@@ -93,8 +93,7 @@ class RandomSubsetDataManager(DataManager):

         self.train_camera_optimizer = self.config.camera_optimizer.setup(
             num_cameras=self.train_dataparser_outputs.cameras.size, device=self.device)
-        self.train_ray_generator = RayGenerator(self.train_dataparser_outputs.cameras.to(self.device),
-                                                self.train_camera_optimizer)
+        self.train_ray_generator = RayGenerator(self.train_dataparser_outputs.cameras.to(self.device))

         fields_to_load = {RGB}
         for additional_field in {DEPTH, WEIGHT, TRAIN_INDEX}:
@@ -117,8 +116,7 @@ class RandomSubsetDataManager(DataManager):
         self.eval_dataset = InputDataset(self.eval_dataparser_outputs)
         self.eval_camera_optimizer = self.config.camera_optimizer.setup(
             num_cameras=self.eval_dataparser_outputs.cameras.size, device=self.device)
-        self.eval_ray_generator = RayGenerator(self.eval_dataparser_outputs.cameras.to(self.device),
-                                               self.eval_camera_optimizer)
+        self.eval_ray_generator = RayGenerator(self.eval_dataparser_outputs.cameras.to(self.device))

         self.eval_image_metadata = self._get_image_metadata(self.eval_dataparser_outputs)
         self.eval_batch_dataset = RandomSubsetDataset(
hturki commented 8 months ago

if that works for you, I could maybe wrap the constructors with a try-catch to test out both constructors (and handle both versions) in the interim?

fabfabsto commented 8 months ago
+++ b/pynerf/data/datamanagers/random_subset_datamanager.py
@@ -93,8 +93,7 @@ class RandomSubsetDataManager(DataManager):

         self.train_camera_optimizer = self.config.camera_optimizer.setup(
             num_cameras=self.train_dataparser_outputs.cameras.size, device=self.device)
-        self.train_ray_generator = RayGenerator(self.train_dataparser_outputs.cameras.to(self.device),
-                                                self.train_camera_optimizer)
+        self.train_ray_generator = RayGenerator(self.train_dataparser_outputs.cameras.to(self.device))

         fields_to_load = {RGB}
         for additional_field in {DEPTH, WEIGHT, TRAIN_INDEX}:
@@ -117,8 +116,7 @@ class RandomSubsetDataManager(DataManager):
         self.eval_dataset = InputDataset(self.eval_dataparser_outputs)
         self.eval_camera_optimizer = self.config.camera_optimizer.setup(
             num_cameras=self.eval_dataparser_outputs.cameras.size, device=self.device)
-        self.eval_ray_generator = RayGenerator(self.eval_dataparser_outputs.cameras.to(self.device),
-                                               self.eval_camera_optimizer)
+        self.eval_ray_generator = RayGenerator(self.eval_dataparser_outputs.cameras.to(self.device))

         self.eval_image_metadata = self._get_image_metadata(self.eval_dataparser_outputs)
         self.eval_batch_dataset = RandomSubsetDataset(

This works for me! I'm running nerfstudio 1.0.0. Many thanks!

JamesAscroft commented 6 months ago

How exactly do I go about implimenting this change in code?