Skip to main content

cnncam

Maintainer PyPI version linting: pylint License: MIT Lifecycle: experimental Github All Releases GitHub release TF NumPy

Introduction

An open python library for researchers and developers to generate GradCAM explanations for the tensorflow CNN models.

Other popular python ML frameworks will soon be supported by the cnn-cam library

Install

The below instructions assume you already have pip installed and exposed to the python environment where you want to run cnncam. Official instructions for installing pip can be found here

Run the below pip command in a shell of your choice.

pip install cnncam

Demo

We currently support two ways of obtaining GradCAM heatmaps:

  1. Display heatmap. If you're only interested in seeing the heatmap images for your model's prediction, you can run the below script:
from cnncam import display_heatmap

display_heatmap(model=model, # your keras model
                img=img, # your image
                predicted_class=pred, # your models prediction for the image 
                layer_name='block5_conv3', # the layer you would like to see GradCAM for 
                alpha=0.6 # opacity of heatmap overlayed on image
                )

alt text

See /examples for executable examples, including the above application of our implementation of GradCAM on VGG-16 with the ower of this repo's very cute cat, meso.

Metadata

Release files for cnncam 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 cnncam 1.0.0
File Size Uploaded
cnncam-1.0.0.tar.gz 5.3 kB Details

Built distribution (wheel)

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

Total release size: 11.0 kB

Release files / cnncam-1.0.0.tar.gz

Download URL cnncam-1.0.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
08bdc65dc3069587fafa6ca9419496ef891b3f20cb5a329e3d27f34452fe7aea
BLAKE2b-256 checksum
How to use checksums
f8271d7e9843f5a85d0a5987f4da41a15a27e81c400f1f9d26d201685de78cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.5

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

Download URL cnncam-1.0.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0d6da385a0d9dbf336ee0c352c5eaff16a62e35d75b8951af843258153dd261
BLAKE2b-256 checksum
How to use checksums
152a3b4cfa289534c247427e8bfb9083d80dc24798c5e79e81acf2628e1cde2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

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