eric-yyjau / pytorch-superpoint

Superpoint Implemented in PyTorch: https://arxiv.org/abs/1712.07629
MIT License
790 stars 167 forks source link

why need to crop to the same length? #55

Open P66094125 opened 3 years ago

P66094125 commented 3 years ago

hi, eric-yyjau

why need to crop to the same length?

crop to the same length

shuffle = True
if not shuffle: print("shuffle: ", shuffle)
choice = crop_or_pad_choice(uv_b_matches.shape[0], num_matching_attempts, shuffle=shuffle)
choice = torch.tensor(choice ,dtype=torch.bool) #.type(torch.bool)
uv_a = uv_a[choice]
uv_b_matches = uv_b_matches[choice]

by the way, here is the error about it:

Traceback (most recent call last): File "train4.py", line 150, in args.func(config, output_dir, args) File "train4.py", line 102, in train_joint train_agent.train() File "C:\Users\User\Desktop\python\STUDY_CNN_imagematching\pytorch-superpoint-master-venv\Train_model_frontend.py", line 277, in train loss_out = self.train_val_sample(sample_train, self.n_iter, True) File "C:\Users\User\Desktop\python\STUDY_CNN_imagematching\pytorch-superpoint-master-venv\Train_model_heatmap.py", line 315, in train_val_sample self.desc_params File "C:\Users\User\Desktop\python\STUDY_CNN_imagematching\pytorch-superpoint-master-venv\utils\loss_functions\sparse_loss.py", line 243, in batch_descriptor_loss_sparse homographies[i].type(torch.float32), options) File "C:\Users\User\Desktop\python\STUDY_CNN_imagematching\pytorch-superpoint-master-venv\utils\loss_functions\sparse_loss.py", line 186, in descriptor_loss_sparse uv_a = uv_a[choice] IndexError: The shape of the mask [1000] at index 0 does not match the shape of the indexed tensor [873, 2] at index 0

eric-yyjau commented 3 years ago

Hi @P66094125,

For only SuperPoint, it is not necessary to sample to the same length. It is used in our DeepFEPE paper when connecting to the downstream task.

I think the indexing may need update. torch.index_select — PyTorch 1.9.1 documentation https://pytorch.org/docs/stable/generated/torch.index_select.html

Sorry I don't have a way to test it at this moment.

P66094125 commented 2 years ago

Thank you for your answer, eric-yyjau.