{"id":13738427,"url":"https://github.com/idiap/fullgrad-saliency","last_synced_at":"2025-05-09T00:08:41.278Z","repository":{"id":43946377,"uuid":"212531553","full_name":"idiap/fullgrad-saliency","owner":"idiap","description":"Full-gradient saliency maps","archived":false,"fork":false,"pushed_at":"2023-02-25T02:06:43.000Z","size":726,"stargazers_count":210,"open_issues_count":5,"forks_count":31,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-09T00:08:34.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-10-03T08:32:02.000Z","updated_at":"2025-04-29T14:19:32.000Z","dependencies_parsed_at":"2022-09-05T09:41:33.693Z","dependency_job_id":"99966ee1-fdf6-4e53-8ee6-85854955e2ca","html_url":"https://github.com/idiap/fullgrad-saliency","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Ffullgrad-saliency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Ffullgrad-saliency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Ffullgrad-saliency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiap%2Ffullgrad-saliency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiap","download_url":"https://codeload.github.com/idiap/fullgrad-saliency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166521,"owners_count":21864482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T03:02:22.149Z","updated_at":"2025-05-09T00:08:41.256Z","avatar_url":"https://github.com/idiap.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Full-Gradient Saliency Maps \n\nThis is the reference implementation of the FullGrad saliency method described in our NeurIPS 2019\npublication [\"Full-Gradient Representation for Neural Network\nVisualization\"](https://arxiv.org/abs/1905.00780).\n\nThis repository implements three methods: \n\n1) The reference `FullGrad` saliency method, which aggregates layerwise gradient maps multipled with the bias terms\n2) `Simple FullGrad`, which omits computation of bias parameters and simply aggregates layerwise gradient maps\n3) `Smooth FullGrad`, which aggregates noise averaged layerwise gradient maps with the bias terms  \n\nThe related\n`full-gradient decomposition` is implemented within `FullGrad`. Note that while `full-gradient\ndecomposition` applies to any ReLU neural network, `FullGrad` saliency is \u003cb\u003especific to\nCNNs\u003c/b\u003e.\n\nIn addition, the following methods from literature are also implemented:\n1. Input-gradient ([paper](https://arxiv.org/abs/1312.6034))\n2. Grad-CAM ([paper](https://arxiv.org/abs/1610.02391))\n3. SmoothGrad ([paper](https://arxiv.org/abs/1706.03825))\n\n## Examples\n| ![FullGrad](images/1_fullgrad.jpg) | ![SimpleFullGrad](images/1_simple_fullgrad.jpg) | ![SmoothFullGrad](images/1_smooth_fullgrad.jpg) |\n|:---:|:---:|:---:| \n| *FullGrad* | *Simple FullGrad* | *Smooth FullGrad* |\n\n\n| ![GradCAM](images/1_gradcam.jpg) | ![Input-Gradient](images/1_inputgrad.jpg) | ![SmoothGrad](images/1_smoothgrad.jpg) |\n|:---:|:---:|:---:| \n| *Grad-CAM* | *Input-Gradients* | *SmoothGrad* |\n\n\n## Usage\nSimply run  `python dump_images.py`, the saliency maps should be saved consequently in a results folder.\n\n## Interfaces\n\nThe FullGrad class has the following methods implemented.\n\n```python\nfrom saliency.fullGrad import FullGrad\n\n# Initialize FullGrad object\nfullgrad = FullGrad(model)\n\n# Check completeness property\n# done automatically while initializing object\nfullgrad.checkCompleteness()\n\n# Obtain fullgradient decomposition\ninput_gradient, bias_gradients = \nfullgrad.fullGradientDecompose(input_image, target_class)\n\n# Obtain saliency maps\nsaliency_map = fullgrad.saliency(input_image, target_class)\n```\n\nWe also introduce variants called `SimpleFullGrad` and `SmoothFullGrad` \nwhich have no completeness property or decomposition.\n\n```python\nfrom saliency.simple_fullgrad import SimpleFullGrad\nfrom saliency.smooth_fullgrad import SmoothFullGrad\n\n# Initialize Simple / Smooth FullGrad objects\nsimple_fullgrad = SimpleFullGrad(model)\nsmooth_fullgrad = SmoothFullGrad(model)\n\n# Obtain saliency maps\nsaliency_map_simple = simple_fullgrad.saliency(input_image, target_class)\nsaliency_map_smooth = smooth_fullgrad.saliency(input_image, target_class)\n```\n\nThis basic interface is retained for input-gradient, gradcam and smoothgrad methods as well.\n\n\n## Dependencies\n``` \ntorch torchvision cv2 numpy \n```\n\n## Research\nIf you found our work helpful for your research, please do consider citing us.\n```\n@inproceedings{srinivas2019fullgrad,\n    title={Full-Gradient Representation for Neural Network Visualization},\n    author={Srinivas, Suraj and Fleuret, François},\n    booktitle={Advances in Neural Information Processing Systems (NeurIPS)},\n    year={2019}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Ffullgrad-saliency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiap%2Ffullgrad-saliency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiap%2Ffullgrad-saliency/lists"}