feat2map icon indicating copy to clipboard operation
feat2map copied to clipboard

stack expects each tensor to be equal size, but got [256,835] at entry 0 and [256,829] at entry 1

Open SunJ1025 opened this issue 1 month ago • 7 comments

Thanks for your Great Work! When I try to train the model, I get the following error:“stack expects each tensor to be equal size, but got [256,835] at entry 0 and [256,829] at entry 1”. it should be that the input data size is not consistent, how should I correct it?

Thanks in advance for your answer!

SunJ1025 avatar May 08 '24 06:05 SunJ1025

I found the descriptors are not the same size, do you konw which step is wrong, leading to a different descriptor sizes?

SunJ1025 avatar May 08 '24 06:05 SunJ1025

Thank you for your interest in our work. The issue you got shows that you probably forgot to keep the threshold with Superpoint when running Hloc. Note that only when you have the same number of descriptors per image, you can train the framework with batch size > 1 (in the code the batch size is 8) Another simple solution is: change the batch size to 1 when training. It will work but I'm not sure it gonna show the best results.

You can change the config of superpoint as follows to get the same number of descriptors:

class SuperPoint(nn.Module):
    default_config = {
        'descriptor_dim': 256,
        'nms_radius': 4,
        'refinement_radius': 0,
        'do_quadratic_refinement': 0,
        'keypoint_threshold': 0.005, # please change to 0.0
        'max_keypoints': -1, # please change to number keypoints you need, ex: 2048
        'remove_borders': 4,
    }

thuanaislab avatar May 08 '24 07:05 thuanaislab

Thank you for your quick response!I'll have a try.

SunJ1025 avatar May 08 '24 08:05 SunJ1025

Sorry to bother you again, but I still have the same problem after modifying max_keypoints=2048, it seems that it's because too few descriptors are fetched, for example [256,835] [256,829], so max_keypoints can't be limited uniformly, do you have any idea about the reason for this?

SunJ1025 avatar May 09 '24 02:05 SunJ1025

I think you forgot to change the threshold of 'keypoint_threshold': 0.005 to 'keypoint_threshold': 0.0. Additionally, please change the config in Hloc at the parents configuration, the example I have shown above is just for a fast response but would not correctly set the Superpoint parameters for entire Hloc framework. This is why you still received the number of descriptors per image around 835 keypoints.

thuanaislab avatar May 09 '24 02:05 thuanaislab

Hello, I have tried to set 'keypoint_threshold': 0.0 in the configs of Hloc, I think the set of configs are right. Maybe it's that 2048 keypoints cannot be extracted from a single image, even if the threshold is set to 0. I‘m not sure if I understand correctly ?

SunJ1025 avatar May 10 '24 02:05 SunJ1025

As long as your image size is not too small, you can manage to get specific number of keypoints as you want.

thuanaislab avatar May 10 '24 02:05 thuanaislab