Skip to main content

Explainable CNNs

Torch Version Torchvision Version Python Version test workflow Price Maintained

📦 Flexible visualization package for generating layer-wise explanations for CNNs.

It is a common notion that a Deep Learning model is considered as a black box. Working towards this problem, this project provides flexible and easy to use pip package explainable-cnn that will help you to create visualization for any torch based CNN model. Note that it uses one of the data centric approach. This project focusses on making the internal working of the Neural layers more transparent. In order to do so, explainable-cnn is a plug & play component that visualizes the layers based on on their gradients and builds different representations including Saliency Map, Guided BackPropagation, Grad CAM and Guided Grad CAM.

Architechture

:star: Star us on GitHub — it helps!

Usage

Install the package

pip install explainable-cnn

To create visualizations, create an instance of CNNExplainer.

from explainable_cnn import CNNExplainer

x_cnn = CNNExplainer(...)

The following method calls returns numpy arrays corresponding to image for different types of visualizations.

saliency_map = x_cnn.get_saliency_map(...)

grad_cam = x_cnn.get_grad_cam(...)

guided_grad_cam = x_cnn.get_guided_grad_cam(...)

To see full list of arguments and their usage for all methods, please refer to this file

You may want to look at example usage in the example notebook.

Output

Below is a comparison of the visualization generated between GradCam and GuidedGradCam

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Ashutosh Hathidara

💻 🎨 🔬 🚧 ✅ ⚠️

Lalit Pandey

🔬 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

References

Metadata

Release files for explainable-cnn 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for explainable-cnn 1.0.0
File Size Uploaded Provenance Actions
explainable_cnn-1.0.0.tar.gz 11.8 kB Without provenance Details for explainable_cnn-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for explainable-cnn 1.0.0
File Interpreter ABI Platform Actions
explainable_cnn-1.0.0-py3-none-any.whl Python 3 none any Details for explainable_cnn-1.0.0-py3-none-any.whl

Total release size: 23.9 kB

Release files / explainable_cnn-1.0.0.tar.gz

Download URL explainable_cnn-1.0.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d3a91798f9d375ad6bcbfa85daa2ff7c5423c73ed0dcf896b93e790ab46dfdec
BLAKE2b-256 checksum
How to use checksums
ef25dea8254e598ab17e3e3b93273e8dc0ca1ea77a1d1c6556e81707f05425fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.12

Release files / explainable_cnn-1.0.0-py3-none-any.whl

Download URL explainable_cnn-1.0.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f4958c3252454b963d096b1d2040c6536108f7a49e785c861a62998e4f260a4
BLAKE2b-256 checksum
How to use checksums
84a5c8eafd5a9cdf79ba48db4238498c6d2a8865863f1dfc7ae4daa6a4a5d66e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.12

Security for explainable-cnn 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page