-
Notifications
You must be signed in to change notification settings - Fork 46
Add UI for Interactive Attention Exploration #64
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
base: main
Are you sure you want to change the base?
Conversation
|
I would personally like to make this feature optional as it introduces a bunch of new dependencies for the UI part. My proposal would be to add a optional dependency group to the pyproject.toml which can then be installed via |
…ed missing dependency response, added smoke test
|
Thank you, good point! Made the UI dependencies optional, added the error message on failed dependency imports and unified the naming to "attentionui". |
georg-wolflein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DEschweiler, thank you so much for your contribution, excellent work!
I slightly modified your PR to fix some typing issues that mypy showed and I changed last_attn_weights to not be an instance attribute but rather a variable within the forward() function (as this is the only place it was used). If you are happy with these changes (44386d9), your PR is ready to be merged!
By the way, could you provide a screenshot of the UI? This could be a nice addition to the main README.md ;)
|
Hi @georg-wolflein, thanks a lot for your modifications and approval! Attached you can find a screenshot of the napari-based UI. Do you want me to also upload it to the repository and add it to the readme? |
|
Hello @DEschweiler, By the end of this week I will review it and if ready, merge it into main. Unfortunately, I have to merge one quick fix for current gradcams and create a new stable version, 2.2.3, which should be done by Wednesday. Once ready, could you bring those changes to this branch as you have been doing with the latest updates? I am looking forward to try it as the screenshots from the UI seem really cool! Thank you very much for contributing. |
|
Hello @EzicStar, Cheers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @DEschweiler,
sorry again for taking so long to review this. I've just tried it and it looks great! I think that users will love it. I made some comments on the code for further improvements, but in general it looks really good. The next steps would be to decide whether to merge it directly into main branch or keep it in a separate one (still in STAMP repo and documented).
These are the difficulties for merging it directly into main:
- STAMP is used frequently on headless Linux systems that don't support user interfaces, and its development is focused on this. A solution to this approach would be for example to have this UI web with a client-server model, as Jupyter does. However, this would take a lot of rework as it is already built with pyqt5.
- The ViT model code becomes more complex and therefore more difficult to maintain, specially now that we have plans of adding regression and survival prediction.
Merging this on a separate branch which is referenced by the documentation on main's branch would still give visibility to this feature and make it easier to maintain, not requiring to takle this difficulties. What do you think @FWao, @georg-wolflein and @s1787956?
P.S: please bring changes from v2.3 and add documentation on the getting-started.md file so it is easier for users to use it.
Thank you for contributing :)
Best,
Juan Pablo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention UI logic should be in a separate script, as it happens with crossval and train.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The params are identical to the ones provided for gradcam heatmaps (current ones) so this is not needed. To decide whether to generate gradcam heatmaps or attention maps, a better option could be to add an optional field in heatmaps config to let the user decide which approach to use. It could be like this:
heatmaps:
# Whether to use GRADCAM based heatmaps or (introduce description of this implementation here, also please inform that you require and extra dependency).
attention_ui: False| default_slide_mpp=config.heatmaps.default_slide_mpp, | ||
| ) | ||
|
|
||
| case "attentionui": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the other comment, this new section could be integrated into heatmaps one adding one more optional field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find that adding 2 new forward functions to self attention increases code complexity, making it more difficult to maintain. The same goes for the return weights logics in MultiHeadALiBi. Is there a way to make it simpler and more decoupled?

As part of the TransformLiver project, a user interface for interactively exploring attention (class token and tile-to-tile) was added. A hook was installed to extract attention from the ViT, the command "STAMP attention_ui" was added to the CLI functionality, and the default config was extended accordingly.