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

Speed up PairPixelSampler #3452

Conversation

nepfaff
Copy link
Contributor

@nepfaff nepfaff commented Sep 27, 2024

This speeds up the extremely slow PairPixelSampler. The main issue seems to be with mask erosion being slow. I managed to speed it up a bit but it still isn't great. I also added the functionality from #2585 to PairPixelSampler.

Before any of the changes:
Screenshot from 2024-09-26 19-08-25

With only erosion:
image

With both erosion and rejection sampling:
image

This is an initial step towards #3446

@nepfaff
Copy link
Contributor Author

nepfaff commented Sep 27, 2024

Not sure about the test failure:

ERROR: failed to authorize: failed to fetch oauth token: unexpected status from GET request to [https://auth.docker.io/token?](https://auth.docker.io/token?scope=repository%3Adocker%2Fdockerfile%3Apull&service=registry.docker.io:)

@nepfaff nepfaff changed the title Add rejection sample mask option to PairPixelSampler Speed up PairPixelSampler Sep 28, 2024
@nepfaff nepfaff marked this pull request as draft September 28, 2024 19:32
@nepfaff nepfaff marked this pull request as ready for review September 28, 2024 19:50

unique_vals = torch.unique(tensor)
if any(val not in (0, 1) for val in unique_vals) or tensor.dtype != torch.float32:
if not (tensor.dtype == torch.float32 and torch.all((tensor == 0) | (tensor == 1))):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet, this is so much cleaner

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.

This looks great to me, thanks!

Is there a reason we aren't also using the rejection sampling for the PatchPixelSampler? Maybe not in this PR, but now the rejection sampling is its own separate fn it seems like it would be a drop-in replacement.

@nepfaff
Copy link
Contributor Author

nepfaff commented Sep 30, 2024

Is there a reason we aren't also using the rejection sampling for the PatchPixelSampler? Maybe not in this PR, but now the rejection sampling is its own separate fn it seems like it would be a drop-in replacement.

There is no reason, and it is a drop-in replacement. However, I agree that a separate PR seems better here. I opened one here (rebased this branch and started the new PR from it).

@akristoffersen akristoffersen merged commit 4c7297c into nerfstudio-project:main Oct 1, 2024
3 checks passed
@nepfaff nepfaff deleted the rejection_sample_mask_for_pair_sampler branch October 1, 2024 08:59
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