maturk / dn-splatter

DN-Splatter: Depth and Normal Priors for Gaussian Splatting and Meshing
https://maturk.github.io/dn-splatter/
Apache License 2.0
305 stars 17 forks source link

‘NoneType' object is not subscriptable #13

Open StevenssW opened 2 months ago

StevenssW commented 2 months ago

Hello, I am new to python. I want to use custom data for training. When I train with the converted data using nerfstudio, I get the following error. My training parameters are: ns-train dn-splatter --data / home/stevenswang/StevenWork/NS/nerfstudio/test_dn_data/yizi2 \ --pipeline.model.use-depth-smooth-loss True \ --pipeline.model.use-sparse-loss True \ --pipeline.model.use-binary-opacities True \ May I ask what is the reason 13

pablovela5620 commented 2 months ago

it looks like you don't have a sensor_depth file, what does your transform.json file look like? Are you using a colmap database or something from polycam/spectacular ai?

StevenssW commented 2 months ago

it looks like you don't have a sensor_depth file, what does your transform.json file look like? Are you using a colmap database or something from polycam/spectacular ai?

Thank you very much for your answer. I generated transform.json through nerfstudio's : ns-process-data video --data --output-dir. I'm not sure if this is correct, but it seems that there is no : sensor_depth. transforms.json

pablovela5620 commented 2 months ago

You'll need to generate depth estimates, this requires either having sensor depth or scale aligned monocular depth. Info here https://github.com/maturk/dn-splatter?tab=readme-ov-file#generate-scale-aligned-mono-depth-estimates

StevenssW commented 2 months ago

Yes ,i find ,Thank you so much

ichsan2895 commented 2 months ago

Hey sorry, this command does not solve my problem: python dn_splatter/scripts/align_depth.py --data [path_to_data_root]

my path_to_data_root already like this:

<path_to_data_root>
|---transforms.json
|---sparse_pc.ply
|---image_path
|   |---<image 0>
|   |---<image 1>
|   |---...
|---sfm_depths
|   |---<sfm_depth 0>
|   |---<sfm_depth 1>
|   |---...
|---mono_depth
|   |---<mono_depth 0>.png
|   |---<mono_depth 0>_aligned.npy
|---colmap
    |---database.db
    |---sparse
        |---0
            |---cameras.bin
            |---images.bin
            |---points3D.bin
            |---project.ini
XuqianRen commented 2 months ago

@ichsan2895 Hi, what's the error you got?

ichsan2895 commented 2 months ago

@ichsan2895 Hi, what's the error you got?

same as @StevenssW

[14:48:58] Saving config to: outputs/unnamed/dn-splatter/2024-04-20_144858/config.yml           ]8;id=416186;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/configs/experiment_config.py\experiment_config.py]8;;\:]8;id=386917;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/configs/experiment_config.py#136\136]8;;\
Saving checkpoints to: outputs/unnamed/dn-splatter/2024-04-20_144858/nerfstudio_models         ]8;id=234053;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/engine/trainer.py\trainer.py]8;;\:]8;id=146316;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/engine/trainer.py#136\136]8;;\
[14:48:59] Caching / undistorting train images                                            ]8;id=91161;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py\full_images_datamanager.py]8;;\:]8;id=619176;file:///workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py#182\182]8;;\
Caching / undistorting train images ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
Traceback (most recent call last):
  File "/usr/local/bin/ns-train", line 8, in <module>
    sys.exit(entrypoint())
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/scripts/train.py", line 262, in entrypoint
    main(
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/scripts/train.py", line 247, in main
    launch(
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/scripts/train.py", line 189, in launch
    main_func(local_rank=0, world_size=world_size, config=config)
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/scripts/train.py", line 99, in train_loop
    trainer.setup()
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/engine/trainer.py", line 149, in setup
    self.pipeline = self.config.pipeline.setup(
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/configs/base_config.py", line 54, in setup
    return self._target(self, **kwargs)
  File "/workspace/NERFSTUDIO_v103/dn-splatter/dn_splatter/dn_pipeline.py", line 80, in __init__
    self.datamanager: DataManager = config.datamanager.setup(
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/configs/base_config.py", line 54, in setup
    return self._target(self, **kwargs)
  File "/workspace/NERFSTUDIO_v103/dn-splatter/dn_splatter/dn_datamanager.py", line 53, in __init__
    super().__init__(
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py", line 118, in __init__
    self.cached_train, self.cached_eval = self.cache_images(self.config.cache_images)
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py", line 184, in cache_images
    cached_train = list(
  File "/usr/local/lib/python3.10/dist-packages/rich/progress.py", line 168, in track
    yield from progress.track(
  File "/usr/local/lib/python3.10/dist-packages/rich/progress.py", line 1209, in track
    for value in sequence:
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py", line 138, in process_train_data
    data = self.train_dataset.get_data(idx, image_type=self.config.cache_images_type)
  File "/workspace/NERFSTUDIO_v103/nerfstudio/nerfstudio/data/datasets/base_dataset.py", line 137, in get_data
    metadata = self.get_metadata(data)
  File "/workspace/NERFSTUDIO_v103/dn-splatter/dn_splatter/data/dn_dataset.py", line 123, in get_metadata
    filepath = self.sensor_depth_filenames[data["image_idx"]]
TypeError: 'NoneType' object is not subscriptable

my command:

ns-train dn-splatter --logging.steps-per-log 200 --vis viewer+wandb --viewer.websocket-port 7007 \
    --pipeline.model.use-depth-loss True \
    --pipeline.model.use-depth-smooth-loss True \
    --pipeline.model.use-sparse-loss True \
    --pipeline.model.use-binary-opacities True \
    normal-nerfstudio \
    --data data/nerfstudio/$scene --downscale-factor 1
XuqianRen commented 2 months ago

Hi @ichsan2895 , if you use colmap pose, our framework will use mono-depth instead of sensor depth, and we use coolermap dataparser for colmap pose. The command should be like:

ns-train dn-splatter \
--pipeline.model.use-depth-loss True \
--pipeline.model.mono-depth-lambda 0.1 \
--pipeline.model.use-depth-smooth-loss True \
--pipeline.model.use-normal-loss True \
--pipeline.model.normal-supervision (mono/depth) \
coolermap --data [DATASET_PATH] --load_normals True

We will make the command more clear in the ReadMe.

Ch180907 commented 2 months ago

Hi @ichsan2895 , if you use colmap pose, our framework will use mono-depth instead of sensor depth, and we use coolermap dataparser for colmap pose. The command should be like:

ns-train dn-splatter \
--pipeline.model.use-depth-loss True \
--pipeline.model.mono-depth-lambda 0.1 \
--pipeline.model.use-depth-smooth-loss True \
--pipeline.model.use-normal-loss True \
--pipeline.model.normal-supervision (mono/depth) \
coolermap --data [DATASET_PATH]

We will make the command more clear in the ReadMe.

Hi,I met the same quession as https://github.com/maturk/dn-splatter/issues/13#issuecomment-2067799095 Then,I try to solve as you said. But I failed How should I do?