Update Captum tutorial dependencies for Captum 0.8.0#3868
Open
gtsitsik wants to merge 1 commit intopytorch:mainfrom
Open
Update Captum tutorial dependencies for Captum 0.8.0#3868gtsitsik wants to merge 1 commit intopytorch:mainfrom
gtsitsik wants to merge 1 commit intopytorch:mainfrom
Conversation
Pin Captum to 0.8.0, the last release retaining Captum Insights, and update the tutorial requirements accordingly. Captum 0.8.0 requires Python >=3.9 and torch >=1.10, so the tutorial now reflects those minimums and uses torchvision >=0.11.0 as the matching torchvision line for PyTorch 1.10. Remove the old matplotlib==3.3.4 requirement. Captum 0.8.0 uses the newer grid(visible=False) Matplotlib API, so the old workaround for the grid(b=False) argument rename is no longer needed. Update the original-image visualization example to pass a dummy attribution array instead of None. In Captum 0.8.0, visualize_image_attr normalizes attr before reaching the code that handles method="original_image", even though that code only displays the original image.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3868
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the Captum tutorial so that its dependency guidance and image visualization example are compatible with Captum 0.8.0.
Captum 0.8.0 is used because it is the last Captum release that still includes Captum Insights. Captum Insights was removed in Captum 0.9.0, so using the latest Captum release is no longer compatible with this tutorial.
Dependency rationale
The tutorial requirements were updated to:
These changes reflect Captum 0.8.0's Python/PyTorch requirements and the TorchVision version line corresponding to PyTorch 1.10.
The previous
matplotlib==3.3.4pin was removed. That pin was needed for older Captum visualization code that used Matplotlib's oldgrid(b=False)keyword. Matplotlib documents the rename of the firstAxes.grid/Axis.gridparameter frombtovisiblein version 3.5.0. Captum 0.8.0 already usesgrid(visible=False), so the old Matplotlib 3.3.4 workaround is no longer needed for this tutorial.Why the visualization call changed
The tutorial previously passed
Noneas the first argument tovisualize_image_attrwhen usingmethod="original_image". With Captum 0.8.0,visualize_image_attrnormalizes theattrargument before reaching the code that handlesmethod="original_image". Therefore,attr=Nonenow raises an error even though the original-image display itself does not use attribution values. The tutorial now passes a dummy attribution array of ones. This allows Captum's normalization step to succeed while preserving the intended output, becausemethod="original_image"only displays the original image.Additional note
The tutorial now also mentions that
visualizer.render()displays the Captum Insights widget inside a Jupyter Notebook. For terminal IPython or regular Python scripts, users can usevisualizer.serve(debug=True)instead and open the printed local URL in a browser.Fixes #3859
Related to #3860
Checklist