fix: composite RGBA onto background in loadCam for NeRF Synthetic data#1320
Open
Flocio wants to merge 1 commit into
Open
fix: composite RGBA onto background in loadCam for NeRF Synthetic data#1320Flocio wants to merge 1 commit into
Flocio wants to merge 1 commit into
Conversation
The Aug 2024 refactor removed the image field from CameraInfo, but loadCam reads raw RGBA from disk without alpha compositing. This causes training to mask rendered background via alpha_mask while evaluation does not, leading to PSNR ~2-3 on Blender scenes. Restore compositing in loadCam to match the behavior of readCamerasFromTransforms.
|
Have the same issue, problem has been solved. Love it !! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Aug 2024 refactor removed the image field from CameraInfo, but loadCam reads raw RGBA from disk without alpha compositing. This causes training to mask rendered background via alpha_mask while evaluation does not, leading to PSNR ~2-3 on Blender scenes. Restore compositing in loadCam to match the behavior of readCamerasFromTransforms.
Summary
This PR fixes a regression in the NeRF Synthetic data path when using RGBA images (Blender renders) together with
--white_background(or black background). After a refactor, the RGBA → RGB compositing step that was present in the older implementation was dropped from the actualloadCampath, which leads to incorrect backgrounds and slightly wrong metrics on NeRF Synthetic, while COLMAP-based datasets remain unaffected.Bug
loadCamno longer performs this compositing, so:--white_background).Fix
Re-introduce RGBA → RGB compositing in
loadCamfor the NeRF Synthetic RGBA case:This matches the alpha compositing logic that previously lived in
dataset_readers.py(using the standardRGB * alpha + bg * (1 - alpha)formula), but applies it on the currentloadCamcode path where images are actually loaded now.After this compositing,
Camera.__init__only sees RGB images andalpha_maskfalls back to all ones, which is consistent with the original behavior where both training and evaluation operate on a solid background image.Safety
The change is guarded by two conditions:
is_nerf_synthetic == Trueimage.mode == "RGBA"Therefore:
is_nerf_syntheticis false).image.mode != "RGBA").Validation
--white_background: