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

colab tutorial? #28

Open
yejy53 opened this issue Aug 19, 2023 · 2 comments
Open

colab tutorial? #28

yejy53 opened this issue Aug 19, 2023 · 2 comments

Comments

@yejy53
Copy link

yejy53 commented Aug 19, 2023

Thank you for your analysis, can you post a colab tutorial?

@rayleizhu
Copy link
Owner

rayleizhu commented Aug 23, 2023

It is a good suggestion. However, it takes quite some effort to tidy up the visualization code and build a nice demo. I'm not sure when I will have the motivation to finish it, since I'm chasing the next CVPR deadline, and there are too many things to do.

I can give some tips for the implementation if you would like to do it by yourself:

  1. You can use register_forward_hook() to easily get the routing region indices and attention matrix, without modifying the model itself.
  2. You can use cv2.applyColorMap to convert attention score map to pseudo-colored heat map.
  3. You can then alpha blend the image and heatmap (i.e. alpha*image + (1-alpha)*heatmap) to get the visualization figure.

@yuxiongl
Copy link

Hello author, I am a newcomer in this field. Could you tell me the specific code for using [register_forward_hook()]. The model stages are nested too deeply. It is difficult for me to figure out the layer name. I don't know how to keep pointing out the middle value like model. bla. bla. bla.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants