Skip to content

Update Captum tutorial dependencies for Captum 0.8.0#3868

Open
gtsitsik wants to merge 1 commit intopytorch:mainfrom
gtsitsik:main
Open

Update Captum tutorial dependencies for Captum 0.8.0#3868
gtsitsik wants to merge 1 commit intopytorch:mainfrom
gtsitsik:main

Conversation

@gtsitsik
Copy link
Copy Markdown

@gtsitsik gtsitsik commented May 5, 2026

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:

  • Python >=3.9
  • PyTorch >=1.10
  • TorchVision >=0.11.0
  • Captum ==0.8.0
  • Matplotlib >=3.5.0

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.4 pin was removed. That pin was needed for older Captum visualization code that used Matplotlib's old grid(b=False) keyword. Matplotlib documents the rename of the first Axes.grid / Axis.grid parameter from b to visible in version 3.5.0. Captum 0.8.0 already uses grid(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 None as the first argument to visualize_image_attr when using method="original_image". With Captum 0.8.0, visualize_image_attr normalizes the attr argument before reaching the code that handles method="original_image". Therefore, attr=None now 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, because method="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 use visualizer.serve(debug=True) instead and open the printed local URL in a browser.

Fixes #3859
Related to #3860

Checklist

  • The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

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.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 5, 2026

🔗 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 SEVs

There 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.

@meta-cla meta-cla Bot added the cla signed label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix broken Captum tutorial — remove retired Insights section, update requirements

1 participant