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

RuntimeError in visualize_attn_maps during evaluate phase with cub_all Dataset: Invalid Shape for Input #14

Closed
Eureka7-sanshun opened this issue Jan 1, 2025 · 4 comments

Comments

@Eureka7-sanshun
Copy link

Hi,
Sorry to bother you, and thank you for your great work! I find your research really meaningful and impactful. I have encountered a small issue while running the code and would appreciate your help.
I am running the code with the cub_all dataset and default setting height=11 and width=9. However, I encountered the following error during the evaluate phase in the visualize_attn_maps function:

RuntimeError: shape '[100, -1]' is invalid for input of size 1980
The error occurs in the visualize.py file at the following line:
StableKeypoints-main/unsupervised_keypoints/visualize.py", line 255, in visualize_attn_maps
est_points = ((points.view(num_images, -1)-0.5) @ regressor)+0.5

The error happens during the evaluate phase when visualizing the attention maps using the visualize_attn_maps function.
I’m using the cub_all dataset, and I’ve set height=11 and width=9, but this causes the RuntimeError due to shape incompatibility.
It seems that the issue is related to reshaping the points tensor (via view(num_images, -1)) in the code, and this mismatch might be due to the specific size of the cub_all dataset.
Is there an official setting or configuration for height and width that resolves this issue, particularly for the cub_all dataset? Could you recommend the correct values to use?

@ehedlin
Copy link
Collaborator

ehedlin commented Jan 1, 2025

If it is points.view(num_images, -1) this might be because the total number of elements in the tensor might not be divisible by num_images. Can you pass in num_images=99 since your height and width are 9x11? It would have been simpler not to require that argument from a simplicity standpoint.

If not it could also be due to regressor not being the expected shape. Could you print the shapes going into that line?

@Eureka7-sanshun
Copy link
Author

Hi,Thank you for your response and suggestions! I tried modifying the settings to height=2 and width=50, and with these changes, the code runs successfully. It seems the default settings were causing the issue.
For additional context, the shape of the regressor tensor is (20, 30) in my case.
Would you say that this modification is an acceptable solution for using the cub_all dataset, or do you recommend any other specific settings to ensure optimal results?
Thank you again for your time and help!

@ehedlin
Copy link
Collaborator

ehedlin commented Jan 7, 2025

This is just for the visualizer, so its not necessary for evaluation. I will push a change to not visualize by default for simplicity.

@Eureka7-sanshun
Copy link
Author

Thank you so much for the clarification and for addressing this issue!Your work has been incredibly inspiring and helpful for my research.

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