{"id":26235960,"url":"https://github.com/clement-w/activation-maps-visualiser-pt","last_synced_at":"2026-04-28T17:04:16.264Z","repository":{"id":54325350,"uuid":"340973170","full_name":"Clement-W/Activation-Maps-Visualiser-PT","owner":"Clement-W","description":"Activation maps visualizer for PyTorch","archived":false,"fork":false,"pushed_at":"2021-11-21T21:32:41.000Z","size":46749,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T03:19:16.581Z","etag":null,"topics":["activation-maps","cnn","python3","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Clement-W.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}},"created_at":"2021-02-21T18:27:26.000Z","updated_at":"2022-04-03T03:14:22.000Z","dependencies_parsed_at":"2022-08-13T12:01:10.345Z","dependency_job_id":null,"html_url":"https://github.com/Clement-W/Activation-Maps-Visualiser-PT","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/Clement-W%2FActivation-Maps-Visualiser-PT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FActivation-Maps-Visualiser-PT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FActivation-Maps-Visualiser-PT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FActivation-Maps-Visualiser-PT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Clement-W","download_url":"https://codeload.github.com/Clement-W/Activation-Maps-Visualiser-PT/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Clement-W%2FActivation-Maps-Visualiser-PT/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259270847,"owners_count":22832085,"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":["activation-maps","cnn","python3","pytorch"],"created_at":"2025-03-13T03:18:55.822Z","updated_at":"2026-04-28T17:04:11.241Z","avatar_url":"https://github.com/Clement-W.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\n\u003ch1 align=\"left\"\u003eActivation maps visualizer for PyTorch\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"example.png\" alt=\"example\" \u003e\n\u003c/p\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nI've created a little PyTorch script to display the activation maps of a specific, or all the CNN's layers. \nSince I'm learning PyTorch, I thought it would be interesting to do this little project to get used to handling torch objects and tensors.\n\n### Built With\n\n* [Python 3.8](https://www.python.org/)\n* [PyTorch](https://pytorch.org/)\n* [Matplotlib](https://matplotlib.org)\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nTo get a local copy up and running, follow these simple example steps.\n\n### Prerequisites\n\n* Python  ⩾ 3.8\n  ```sh\n  sudo apt install python3 python3-pip\n  ```\n\n### Installation\n\n\n1. Clone the repo\n   ```sh\n   git clone https://github.com/Clement-W/Activation-Maps-Visualiser-PT.git\n   cd Activation-Maps-Visualiser-PT/\n   ```\n3. Create and activate a virtual environment\n   ```sh\n   pip3 install virtualenv --upgrade\n   virtualenv venv\n   source venv/bin/activate\n   ```\n4. Install the requirements\n   ```sh\n   pip3 install -r requirements.txt\n   ```\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\n\n### Use ActivationMapExtractor.py\n\nThere is two main ways to use this python script :\n\n* Call the function **show_activation_maps(model, layer_name, image)**. This function shows the activation maps for a specific layer in the model. \n* Call the function **save_all_activation_maps(model, image,path_to_directory)**. This function saves the activation maps of every layers of the model in the specified directory. \n\nCheck the next section to see an example.\n\n\n\n\n### Demo with RestNet-18\n\nImport modules :\n```py\nfrom torchvision import models, transforms, datasets\nimport torch\nfrom PIL import Image\nfrom ActivationMapsExtractor import save_all_activation_maps, show_activation_maps\n```\nSet torch device :\n```py\ndevice = torch.device(\"cuda:0\"  if torch.cuda.is_available() else  \"cpu\")\n```\nLoad pretrained RestNet-18 model from PyTorch :\n```py\nmodel = models.resnet18(pretrained=True)\n```\nLoad an image to feed the ResNet-18 model :\n```py\nimage = Image.open(\"imageNet/sample.JPEG\")\ntransform = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor()])\nimage = transform(image).to(device)\n```\n\nIf you want to see the activation maps of a specific layer by it's name for that input image :\n```py\nshow_activation_maps(model,\"conv1\",image)\n```\n\nIf you want to save the activation maps of every layers for that input image :\n```py\nsave_all_activation_maps(model, image,\"./ResNet-activation-maps\")\n```\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nI'm still learning PyTorch, so feel free to use Issues or PR to report errors and/or propose additions or corrections to my code. Any contributions you make are **greatly appreciated**.\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n\n\u003c!-- TODO LIST --\u003e\n## Todo list\n\n- [ ] Add a Jupyter notebook demo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclement-w%2Factivation-maps-visualiser-pt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclement-w%2Factivation-maps-visualiser-pt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclement-w%2Factivation-maps-visualiser-pt/lists"}