Skip to content

Conversation

nepfaff
Copy link
Contributor

@nepfaff nepfaff commented Sep 30, 2024

See #3452 for context.

NOTE: This must be merged after #3452. I wanted to specify the #3452 branch as the base branch but somehow couldn't find it in the GitHub UI...

@nepfaff
Copy link
Contributor Author

nepfaff commented Sep 30, 2024

+@akristoffersen for review please

if isinstance(mask, Tensor) and not self.config.ignore_mask:
sub_bs = batch_size // (self.config.patch_size**2)
half_patch_size = int(self.config.patch_size / 2)
m = erode_mask(mask.permute(0, 3, 1, 2).float(), pixel_radius=half_patch_size)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is making me realize, instead of eroding, it might be better to just rejection sample patches across the image, rejecting if the whole patch isn't within the mask. Could be faster if the masks are large and the patches are small.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is probably true. I didn't really look into the functionality of the PatchPixelSampler yet but can find some time to do so later this week.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. That could also go in a separate PR for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, sounds good

@akristoffersen akristoffersen self-requested a review October 1, 2024 02:29
Copy link
Contributor

@akristoffersen akristoffersen left a comment

Choose a reason for hiding this comment

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

LGTM, will merge once you rebase.

@nepfaff nepfaff force-pushed the rejection_sample_mask_for_patch_pixel_sampler branch from 0f8bfb1 to 688ba70 Compare October 1, 2024 08:58
@akristoffersen akristoffersen merged commit 56556d2 into nerfstudio-project:main Oct 1, 2024
3 checks passed
@nepfaff nepfaff deleted the rejection_sample_mask_for_patch_pixel_sampler branch October 2, 2024 09:30
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