Skip to content
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

Fix: Masks having wrong dimension after undistortion (causes crash in splatfacto) #2987

Merged

Conversation

Zunhammer
Copy link
Contributor

@Zunhammer Zunhammer commented Mar 7, 2024

I noticed that masks in splatfacto are not working after undistortion. I get an error when masks are applied in the full images datamanager in line 881 (gt_img = gt_img * mask) as the shapes are (w, h, 3) and (w, h), however they need to be (w, h, 3) and (w, h, 1).
image

The resulting Error is: RuntimeError: The size of tensor a (3) must match the size of tensor b (3839) at non-singleton dimension 2
terminate called without an active exception

Please note that this issue is not present in nerfacto. Also it does not appear when using undistorted images (k- and p-params all 0)

I fixed it by adding the third dimension after undistortion. Tested both splatfacto and nerfacto as well, seems to be fixed to me.

@Zunhammer Zunhammer changed the title Fix: Masks having different dimension than colored images (leads to crash) Fix: Masks having wrong dimension after undistortion (causes crash) Mar 7, 2024
@Zunhammer Zunhammer changed the title Fix: Masks having wrong dimension after undistortion (causes crash) Fix: Masks having wrong dimension after undistortion (causes crash in splatfacto) Mar 8, 2024
Copy link
Collaborator

@maturk maturk left a comment

Choose a reason for hiding this comment

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

This looks reasonable, the masks should indeed be (h,w,1) in nerfstudio. I am guessing this peculiarity comes from the cv2 side again... since it should be ensured in the dataparser side here

@maturk maturk merged commit ae6c46c into nerfstudio-project:main Mar 8, 2024
2 checks passed
Michael-Spleenlab pushed a commit to Michael-Spleenlab/nerfstudio that referenced this pull request Apr 26, 2024
… splatfacto) (nerfstudio-project#2987)

* Add third dim to masks after undistortion to fix error in multiplying color images with masks.

* Revert auto format of imports to fix ruff error

---------

Co-authored-by: Nicolas Zunhammer <[email protected]>
ArpegorPSGH pushed a commit to ArpegorPSGH/nerfstudio that referenced this pull request Jun 22, 2024
… splatfacto) (nerfstudio-project#2987)

* Add third dim to masks after undistortion to fix error in multiplying color images with masks.

* Revert auto format of imports to fix ruff error

---------

Co-authored-by: Nicolas Zunhammer <[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.

2 participants