Parskatt / DKM

[CVPR 2023] DKM: Dense Kernelized Feature Matching for Geometry Estimation
https://parskatt.github.io/DKM/
Other
378 stars 28 forks source link

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

Open lllabmaster opened 4 months ago

lllabmaster commented 4 months ago

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 commented 4 months ago

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

lllabmaster commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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)