Skip to content

Implement Grad-CAM explainability and tests - #3

Merged
RaykKretzschmar merged 36 commits into
mainfrom
dev-
Dec 9, 2025
Merged

Implement Grad-CAM explainability and tests#3
RaykKretzschmar merged 36 commits into
mainfrom
dev-

Conversation

@RaykKretzschmar

Copy link
Copy Markdown
Owner

No description provided.

@RaykKretzschmar

Copy link
Copy Markdown
Owner Author

Implemented 1D Grad-CAM with successful CI tests. Ready for merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements 1D Grad-CAM (Gradient-weighted Class Activation Mapping) explainability for spectral CNN models, providing visual interpretability of model predictions. The implementation includes comprehensive unit tests, documentation, and demonstration notebooks.

Key Changes:

  • New GradCAM1D utility class for generating attention heatmaps on 1D spectral data
  • Comprehensive test suite with edge case coverage for the Grad-CAM implementation
  • Resource management improvements with added close() method to dataset and test cleanup

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
spectra2prop/utils/explainability.py Implements the GradCAM1D class with automatic Conv1d layer detection, hook registration, and heatmap generation capabilities
tests/test_explainability.py Comprehensive test suite covering initialization, layer detection, heatmap generation, normalization, and hook management
tests/test_dataloader.py Adds proper resource cleanup by calling dataset.close() after tests complete
spectra2prop/data/dataloader.py Adds close() method to MGFDataset for proper file handle cleanup
notebooks/showcase.ipynb Demonstrates Grad-CAM usage with visualization examples for spectral data interpretation
.github/workflows/ci.yml Updates PYTHONPATH from src to . for correct test execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread notebooks/showcase.ipynb Outdated
Comment thread tests/test_explainability.py Outdated
Comment thread tests/test_explainability.py Outdated
Comment thread spectra2prop/utils/explainability.py Outdated
Comment thread tests/test_explainability.py
Comment thread spectra2prop/data/dataloader.py
Comment thread spectra2prop/utils/explainability.py
Comment thread notebooks/showcase.ipynb Outdated
Comment thread spectra2prop/utils/explainability.py
Comment thread spectra2prop/utils/explainability.py
RaykKretzschmar and others added 7 commits December 9, 2025 00:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@RaykKretzschmar I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you.

RaykKretzschmar and others added 3 commits December 9, 2025 11:31
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Add test coverage for automatic class selection in GradCAM heatmap generation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_explainability.py
Comment thread spectra2prop/data/dataloader.py
Comment thread notebooks/showcase.ipynb
Comment thread tests/test_explainability.py
Comment thread tests/test_explainability.py
Comment thread notebooks/showcase.ipynb

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@RaykKretzschmar I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

RaykKretzschmar and others added 2 commits December 9, 2025 13:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@RaykKretzschmar I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits December 9, 2025 12:27
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Add tearDown hook cleanup to prevent memory leaks in GradCAM tests

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@RaykKretzschmar I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits December 9, 2025 12:48
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Align DummySpectralCNN test model with real SpectralCNN tuple return signature
@RaykKretzschmar
RaykKretzschmar merged commit 0a91a1c into main Dec 9, 2025
2 checks passed
@RaykKretzschmar
RaykKretzschmar deleted the dev- branch December 9, 2025 16:42
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

Successfully merging this pull request may close these issues.

3 participants