{"id":18644877,"url":"https://github.com/zuruoke/class-activation-map","last_synced_at":"2025-11-05T02:30:35.151Z","repository":{"id":113055040,"uuid":"264700197","full_name":"zuruoke/Class-Activation-Map","owner":"zuruoke","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-28T20:39:56.000Z","size":10800,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T11:33:21.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuruoke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-17T15:37:54.000Z","updated_at":"2020-05-28T20:39:58.000Z","dependencies_parsed_at":"2023-03-24T23:03:04.560Z","dependency_job_id":null,"html_url":"https://github.com/zuruoke/Class-Activation-Map","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/zuruoke%2FClass-Activation-Map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuruoke%2FClass-Activation-Map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuruoke%2FClass-Activation-Map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuruoke%2FClass-Activation-Map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuruoke","download_url":"https://codeload.github.com/zuruoke/Class-Activation-Map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239449541,"owners_count":19640532,"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-11-07T06:13:52.187Z","updated_at":"2025-11-05T02:30:35.098Z","avatar_url":"https://github.com/zuruoke.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class-Activation-Map\n\n## MOTIVATION:\nThis technique allows re-using classifiers for getting good localization results even when training without bounding box coordinates data\n\nYou don't need to draw a box, simply train a classifier - you can automatically know where the object is.\n\n![0000001](https://user-images.githubusercontent.com/51057490/82156080-058bdd00-9871-11ea-9ee2-0a07df56c055.JPG)\n\n\n\n*Class activation maps* are a simple technique to get the discriminative image regions used by a CNN to identify a specific class in the image. \nIn other words, a class activation map (CAM) lets us see which regions in the image were relevant to this class  \nThe corresponding weights of the feature vector connected to the logistic regression aids to weight the importance of each object in the image in relation to a classification of a particular image. \n\n*In this kernel*, I used this workflow to get my Class Activation Map:\n\n- *Load a Resnet50* pretrained on [Imagenet](http://www.image-net.org/) but cut it off at the last activation layer, which returns 2048 7x7 feature maps of the query image \n\n- *Use the Resnet50* model to predict the class of the query image\n\n- *With the class of the query image*, take the corresponding weights of the logistic regression, i.e the last dense layer weights\n\n- *Compute the dot product* of the 2048 7x7 feature maps and the logistic regression weights of the query image class, returns 7x7 image\n\n- *Upsample the 7x7 image* to the original size of the image using [scipy](https://www.scipy.org/)\n\n- *Overlay a sort of heatmap* over the query image\n\n- *Plot* both the query image and its overlayed heatmap constituent  \n\n# RESULTS\n\n![0000002](https://user-images.githubusercontent.com/51057490/82155893-e9d40700-986f-11ea-9b8a-b68e96cc566f.JPG)\n![0000004](https://user-images.githubusercontent.com/51057490/82155996-8c8c8580-9870-11ea-98e5-cb019af3ed67.JPG)\n![0000000088](https://user-images.githubusercontent.com/51057490/82156029-c2316e80-9870-11ea-89f6-f88153ac3a12.JPG)\n![0000003](https://user-images.githubusercontent.com/51057490/82156047-e4c38780-9870-11ea-8329-0967f07c88e1.JPG)\n![0000007](https://user-images.githubusercontent.com/51057490/82156068-015fbf80-9871-11ea-94c9-eeb4f6a87150.JPG)\n![0000006](https://user-images.githubusercontent.com/51057490/82156085-091f6400-9871-11ea-9eea-a313a4a78c22.JPG)\n![0000005](https://user-images.githubusercontent.com/51057490/82156093-0d4b8180-9871-11ea-99f4-9aad2f64f8a3.JPG)\n![000000010](https://user-images.githubusercontent.com/51057490/82156095-11779f00-9871-11ea-84f5-c2d86d2a74f7.JPG)\n![0000009](https://user-images.githubusercontent.com/51057490/82156102-189ead00-9871-11ea-90f6-339b25369f36.JPG)\n![0000008](https://user-images.githubusercontent.com/51057490/82156115-28b68c80-9871-11ea-8089-41c26e6f7719.JPG)\n![bicycle](https://user-images.githubusercontent.com/51057490/82156123-30763100-9871-11ea-94d1-d1e72442e896.JPG)\n\nN/B: The area around the main object which the network presumes is relevant for it's prediction is hotter than the rest, hence the name, \"heatmap\"\n\n\n## CONCLUSION:\n- This also shows how deep learning networks already have some kind of a built in attention mechanism.\n\n- This should be useful for debugging the decision process in classification networks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuruoke%2Fclass-activation-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuruoke%2Fclass-activation-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuruoke%2Fclass-activation-map/lists"}