Skip to content

Add pointcloud loading for blender parser #2902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gchhablani
Copy link
Contributor

This PR adds pointcloud loading for blender parser.

The reason this is needed is because the original gaussian splatting repo supports blender format along with colmap.

With random initialization,splatfacto performance is not great (see below for lego).

image

Here are the relevant lines of code where they initialize the gaussians from pointcloud if that helps.

Note:

  • I am not sure if transform_matrix and scaling_factor are needed here. If yes, any pointers on how it should be done will help.

Copy link
Collaborator

@brentyi brentyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gchhablani, thanks for the PR! Where are you getting the point cloud from? The point clouds are usually pulled from COLMAP, but we don't typically run COLMAP for synthetic data since the training images are just rendered from known poses.

For what it's worth, my splatfacto results with the default settings are also not great:
ns-train splatfacto --data ./data/blender/lego blender-data
image

But I can get much cleaner results by setting the background color of the model to white, which is a typical hack that NeRF methods evaluated on synthetic data use:
ns-train splatfacto --data ./data/blender/lego --pipeline.model.background-color white blender-data
image

@brentyi
Copy link
Collaborator

brentyi commented Feb 11, 2024

#2889 also seems related!

@gchhablani
Copy link
Contributor Author

gchhablani commented Feb 11, 2024

@brentyi
I agree, there might be ways to fix things for this particular dataset. For synthetic unbounded datasets, partial pointclouds might be useful. Would it not be great to directly load ply files for pointcloud initializations for other blender format datasets?

I have ply files for sparse/imperfect pointclouds for a scene which are in blender format.

@gchhablani
Copy link
Contributor Author

gchhablani commented Feb 11, 2024

Btw, I get the pointcloud from the original nerf dataset.

@brentyi
Copy link
Collaborator

brentyi commented Feb 11, 2024

Btw, I get the pointcloud from the original nerf dataset.

Did you generate these yourself? I wasn't aware of any point clouds released in the original dataset, and can't seem to find them either (eg in this Google Drive).

@gchhablani
Copy link
Contributor Author

@brentyi Thanks for asking me this :)
I wouldn't have checked otherwise.

I downloaded the synthetic data using this:

wget http://cseweb.ucsd.edu/~viscomp/projects/LF/papers/ECCV20/nerf/nerf_example_data.zip

Not sure where I had found this.

However, I checked the pointcloud since you asked.
And this is the pointcloud:

image

Interestingly, I get slightly better performance with this random cube, but this could be random too, of course:

image

@brentyi
Copy link
Collaborator

brentyi commented Feb 11, 2024

Assuming that's meant to be an RGB image: yeah, looks weird to me. It's interesting that the colors in the rendered eval image on the right look fine.

I'm not familiar with the tensorboard or wandb logging systems though.

@ichsan2895
Copy link

Hello, seems good PR. Please let me know some my thought

If I use my own blender model, where can I get sparse_pc.ply?

If I manually use ns-process-data images (which utilizes colmap) to get sparse_pc.ply, of course I will use nerfstudio dataparser instead of blender dataparser

@gchhablani
Copy link
Contributor Author

gchhablani commented Feb 11, 2024

@ichsan2895 @brentyi

The idea is to have it consistent with the original repo. I have some synthetic data for which I do have pointcloud in .ply but random init will not work on it.

Here is my use case:

  • I have a set of images, corresponding intrinsic and extrinsics, and a pointcloud with holes in them.
  • I converted them to Blender format with scripts to run with gaussian-splatting repository because that was the easiest thing.
  • Now, to run things with nerfstudio dataparser, I will have to understand a new format and repeat the process.

Would it not be easier to just have pointcloud support in blender dataparser?

Regardless, if this PR doesn't make sense, I'll close it.
However, I would greatly appreciate some pointers on how to integrate transform_matrix and scaling_factor so I can use it myself, at least. Thanks!

@f-dy
Copy link
Contributor

f-dy commented Feb 12, 2024

@brentyi @gchhablani to get reasonable result with the blender dataset, you should set random_scale (here https://github.com/nerfstudio-project/nerfstudio/blame/main/nerfstudio/models/splatfacto.py#L144 ) to the right value. It is 2.6, not 10 in 3DGS, see here https://github.com/graphdeco-inria/gaussian-splatting/blob/main/scene/dataset_readers.py#L240

That's something we noticed with @pa-la when working on #2889

I don't understand why it's 10 by default in nerfstudio? maybe for mipnerf360 scenes? I think we should set it to 2.6 by default, to be consistent with the original code.

Copy link
Collaborator

@brentyi brentyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in getting back here! I've been hesitant here because it feels like the aim here would be to support non-standard dataset formats (AFAIK there's no public datasets in the Blender format that also provide point clouds).

But given how the uninvasive the changes are I'm fine with supporting it.

I think transform_matrix can be skipped (these are the camera poses? unless you're referring to something else), but the point should be scaled by scale_factor.

@@ -42,6 +43,11 @@ class BlenderDataParserConfig(DataParserConfig):
"""How much to scale the camera origins by."""
alpha_color: str = "white"
"""alpha color of background"""
ply_path: Path = Path("sparse_pc.ply")
"""Path to the pointcloud file relative to the data path."""
load_3D_points: bool = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we replace these two fields with just one:

ply_path: Optional[Path] = None

?

and indicate in the docstring that this is used for Gaussian splatting initialization?

@brentyi
Copy link
Collaborator

brentyi commented Feb 13, 2024

I don't understand why it's 10 by default in nerfstudio? maybe for mipnerf360 scenes? I think we should set it to 2.6 by default, to be consistent with the original code.

Maybe @kerrj can comment on this?

@kerrj
Copy link
Collaborator

kerrj commented Feb 13, 2024

I don't understand why it's 10 by default in nerfstudio? maybe for mipnerf360 scenes? I think we should set it to 2.6 by default, to be consistent with the original code.

We can change back to 2.6, the intention with setting to 10 was that if people use real datasets without points available (eg Polycam), initializing to 10 would give reasonable results on backgrounds sometimes, while 2.6 would look bad. I'm fine changing the default to 2.6, since point pipelines for other data inputs should be added now anyways.

@gchhablani
Copy link
Contributor Author

@brentyi I have updated the PR. Requesting for another review.

@jb-ye
Copy link
Collaborator

jb-ye commented Apr 11, 2024

@brentyi @kerrj Any follow up on this? It looks like a simple non-invasive change.

@jb-ye jb-ye force-pushed the add_metadata_to_blender_parser branch from 8973d5e to 349e372 Compare April 11, 2024 18:22
@brentyi
Copy link
Collaborator

brentyi commented Apr 11, 2024

Thanks for the bump; I fixed the scale factor and made the option opt-in. Should be okay with me now!

@brentyi brentyi merged commit c302cc5 into nerfstudio-project:main Apr 11, 2024
2 checks passed
jancoveeden added a commit to jancoveeden/nerfstudio that referenced this pull request Apr 23, 2024
commit d9b022b
Author: J.Y <[email protected]>
Date:   Fri Apr 19 14:03:55 2024 -0400

    Allow alpha transparency training for blender datasets input (nerfstudio-project#3088)

    Allow alpha transparency training for rgba input

    Co-authored-by: Justin Kerr <[email protected]>

commit eddf2d2
Author: Congrong Xu <[email protected]>
Date:   Thu Apr 18 17:37:50 2024 -0700

    Changes for trainer.py to support the Gradio webui (nerfstudio-project#3046)

    * changes for trainer to support webui

    * Update trainer to support webui

    * format

    * add a seperated shutdown() function to stop training

    * typo fix

    * get rid of _stop_viewer_server()

    * Update trainer.py

    * organize import

    ---------

    Co-authored-by: Brent Yi <[email protected]>

commit 45d8bb7
Author: Justin Kerr <[email protected]>
Date:   Wed Apr 17 23:54:43 2024 -0700

    updates to apply_pca_colormap (nerfstudio-project#3086)

    * improvements to pca_colormap: allow input pca matrix, optional ignore_zeros arg

    * typo

commit babf577
Author: Patrick Morgan <[email protected]>
Date:   Fri Apr 12 14:23:47 2024 -0700

    Fix call to detect ODM reconstruction file (nerfstudio-project#3018)

commit a64026f
Author: Justin Kerr <[email protected]>
Date:   Fri Apr 12 12:32:22 2024 -0700

    shift principle points by .5 in undistortion (nerfstudio-project#3071)

    * shift principle points by .5

    * fix ordering

    * add fisheye offset

commit c302cc5
Author: Gunjan Chhablani <[email protected]>
Date:   Thu Apr 11 16:41:14 2024 -0400

    Add pointcloud loading for blender parser (nerfstudio-project#2902)

    * Add pointcloud loading for blender parser

    * Fix argument

    * Fix docstring

    * Fix metadata in dataparsers

    * Add changes from review

    * Avoid changing default behavior

    * Apply `scale_factor` to loaded points

    ---------

    Co-authored-by: Brent Yi <[email protected]>

commit 03bdeff
Author: hyperzy <[email protected]>
Date:   Thu Apr 11 14:56:37 2024 -0400

    Fixed Unexpectedly huge RAM consumption of parallel datamanager (nerfstudio-project#3060)

    * Reduced the memory usage by caching image after the datamanager process starts

commit 4714ae7
Author: J.Y <[email protected]>
Date:   Thu Apr 11 14:37:02 2024 -0400

    write eval combined images for diagnostics (nerfstudio-project#3070)

commit eba72db
Author: Otto Seiskari <[email protected]>
Date:   Thu Apr 11 21:23:17 2024 +0300

    Camera pose optimization for Splatfacto (nerfstudio-project#2891)

    * Add pose optimization to Splatfacto

    * Disable Splatfacto pose optimization by default

    * Improve apply_to_camera for Gaussian Splatting pose optimization

    Do not chain modifications to camera_to_worlds to improve
    numerical stability and enable L2 rot/trans penalties.

    * Add separate mean and max rot/trans metrics to camera-opt

    * Tweak pose optimization hyperparameters

    Parameters used in the Gaussian Splatting on the Move paper v1

    * Unit test fix for new cameara_optimizer training metrics

    * Adjust splatfacto-big camera pose optimization parameters

    Same parameters as in normal Splatfacto

    ---------

    Co-authored-by: jh-surh <[email protected]>

commit 2d9bbe5
Author: dberga <[email protected]>
Date:   Thu Apr 11 04:04:33 2024 +0200

    fix exporter.py for FullImageDataManager and RandomCamerasDataManager (nerfstudio-project#3065)

    * fix exporter.py for FullImageDataManager and RandomCamerasDataManager

    * sort imports

    * ruff

    ---------

    Co-authored-by: Brent Yi <[email protected]>

commit c381fc8
Author: Justin Kerr <[email protected]>
Date:   Wed Apr 10 18:59:20 2024 -0700

    Fix custom elements nested under @Property (nerfstudio-project#3066)

    * patch custom elements bug

    * Skip `cached_property`

    * fomrat

    * comment, type hint

    ---------

    Co-authored-by: Brent Yi <[email protected]>

commit d1fc2ee
Author: Saurav Maheshkar <[email protected]>
Date:   Mon Apr 8 23:46:00 2024 +0100

    feat(ci): migrate to `uv` in CI (nerfstudio-project#3038)

    * feat(ci): migrate to `uv` in CI

    * feat(ci): drop upgrade strategy

    * feat(ci): use `uv` in docs workflow

    * fix(ci/doc): update sphinx build cmd

    * fix(ci/doc): specify python path

    * (experimental) simplify

    * remove venv

    * Revert line wrap change for doc.yml

    ---------

    Co-authored-by: Brent Yi <[email protected]>

commit 2b91715
Author: Sahil Jain <[email protected]>
Date:   Mon Apr 8 13:04:20 2024 -0400

    Fix config loading for Eyeful Tower dataset (nerfstudio-project#3054)

    Add test_filenames to transforms.json generated by eyeful_tower.py

commit 26804f8
Author: Ling Jing <[email protected]>
Date:   Tue Apr 9 00:07:21 2024 +0800

    Make colmapDataParser compatible with 360_v2 dataset format (nerfstudio-project#2860)

    * added an option to colmapdataparser to round up the image size when downscaling

    * add round mode and update ffmpeg command

    * [fix] wrong variable order

    * update format

    ---------

    Co-authored-by: Jing <[email protected]>

commit 911091c
Author: Jan-Niklas Dihlmann <[email protected]>
Date:   Mon Apr 8 16:17:56 2024 +0200

    Added SIGNeRF to Nerfstudio methods  (nerfstudio-project#3053)

    * feat: signerf as nerfstudio method

    * fix: formating issues and indexing
Michael-Spleenlab pushed a commit to Michael-Spleenlab/nerfstudio that referenced this pull request Apr 26, 2024
* Add pointcloud loading for blender parser

* Fix argument

* Fix docstring

* Fix metadata in dataparsers

* Add changes from review

* Avoid changing default behavior

* Apply `scale_factor` to loaded points

---------

Co-authored-by: Brent Yi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants