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

Inference in batched mode: all values in certainty is zeros #59

Open
lllabmaster opened this issue May 2, 2024 · 4 comments
Open

Inference in batched mode: all values in certainty is zeros #59

lllabmaster opened this issue May 2, 2024 · 4 comments

Comments

@lllabmaster
Copy link

lllabmaster commented May 2, 2024

Hi, i have this problem:

image1.shape, image2.shape : 3, 256, 256

dkm_model = DKMv3_outdoor(device=device)
dkm_model.w_resized = 256
dkm_model.h_resized = 256
dkm_model.upsample_preds = False
warp, certainty = dkm_model.match(image1, image2, batched=True, device=device)

then all values in 'certainty' tensor is zeros (torch.sum(certainty) is 0.0), so this line code "matches, certainty = dkm_model.sample(warp, certainty)" will cause error:
603 expansion_factor = 4 if "balanced" in self.sample_mode else 1
--> 604 good_samples = torch.multinomial(certainty,
605 num_samples = min(expansion_factor*num, len(certainty)),
606 replacement=False)
607 good_matches, good_certainty = matches[good_samples], certainty[good_samples]
608 if "balanced" not in self.sample_mode:

RuntimeError: invalid multinomial distribution (sum of probabilities <= 0)

@Parskatt
Copy link
Owner

Parskatt commented May 2, 2024

Are the images imagenet normalized? Can you show the images here?

@lllabmaster
Copy link
Author

Are the images imagenet normalized? Can you show the images here?

Thank you very much, I got it. I havenot normalized the values to [0,1.0], thank you.

@Parskatt
Copy link
Owner

Parskatt commented May 3, 2024

Are the images imagenet normalized? Can you show the images here?

Thank you very much, I got it. I havenot normalized the values to [0,1.0], thank you.

Please make sure to also normalize from 0,1 by (x-imgnet_mean)/imgnet_std

@lllabmaster
Copy link
Author

Are the images imagenet normalized? Can you show the images here?

Thank you very much, I got it. I havenot normalized the values to [0,1.0], thank you.

Please make sure to also normalize from 0,1 by (x-imgnet_mean)/imgnet_std

yes, thanks, I did it. input/256.0 -> Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], inplace=True)

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

No branches or pull requests

2 participants