Parskatt/DKM

`numpy.random.choice` to pytorch?

ducha-aiki opened this issue · 6 comments

Hi,

I have quickly checked the possibility to strip out training code and integrate the bare DKM into kornia.
It seems that the main blocker is numpy.random.choice

good_samples = np.random.choice(

And the Pytorch doesn't have it
pytorch/pytorch#16897

Is there a way we can use existing pytorch functionality to get a similar thing?

torch.multinomial(certainty, num_samples = min(expansion_factor*num, len(certainty)), replacement=False)

Seems like a good option

I think the main issue with np.random.choice missing in Pytorch is that you have to pipeline multinomial -> indexing instead of having it as a single function. However, as I'm just using it for indexes here anyway I think there is no major issue.

Could you please check if that works? And, btw, DKM is very welcomed in the shortly upcoming Image Matching Challenge 2023 (CVPR & Kaggle)

Sure, I'll check, and we'll provide a DKM baseline kernel to run for IMC. By the way @ducha-aiki, is Kaggle python 3.7 only? e.g. PyTorch 2.0 doesn't seem to have any binaries for cp37?

@Parskatt well, I more meant to take part and win the challenge :)
Regarding Python 3.7 - kaggle kernel is 3.7 only now, but given the EOL soon, we can safely bet they will upgrade in month or two.

Multinomial seems fine, should be in here #22 .