{"id":13721015,"url":"https://github.com/Jongchan/attention-module","last_synced_at":"2025-05-07T13:31:27.003Z","repository":{"id":41344849,"uuid":"151912385","full_name":"Jongchan/attention-module","owner":"Jongchan","description":"Official PyTorch code for \"BAM: Bottleneck Attention Module (BMVC2018)\" and \"CBAM: Convolutional Block Attention Module (ECCV2018)\"","archived":false,"fork":false,"pushed_at":"2023-03-09T03:46:12.000Z","size":21,"stargazers_count":2025,"open_issues_count":42,"forks_count":400,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-08-04T01:14:23.525Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jongchan.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":"2018-10-07T06:25:26.000Z","updated_at":"2024-08-01T18:06:35.000Z","dependencies_parsed_at":"2022-07-15T15:30:38.233Z","dependency_job_id":null,"html_url":"https://github.com/Jongchan/attention-module","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/Jongchan%2Fattention-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jongchan%2Fattention-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jongchan%2Fattention-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jongchan%2Fattention-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jongchan","download_url":"https://codeload.github.com/Jongchan/attention-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224604703,"owners_count":17339187,"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-03T01:01:11.316Z","updated_at":"2024-11-14T10:30:55.221Z","avatar_url":"https://github.com/Jongchan.png","language":"Python","funding_links":[],"categories":["DLA"],"sub_categories":["BAM"],"readme":"# BAM and CBAM\nOfficial PyTorch code for \"[BAM: Bottleneck Attention Module (BMVC2018)](http://bmvc2018.org/contents/papers/0092.pdf)\" and \"[CBAM: Convolutional Block Attention Module (ECCV2018)](http://openaccess.thecvf.com/content_ECCV_2018/html/Sanghyun_Woo_Convolutional_Block_Attention_ECCV_2018_paper.html)\"\n\n### Updates \u0026 Notices\n- 2018-10-08: ~~Currently, only CBAM test code is validated. **There may be minor errors in the training code**. Will be fixed in a few days.~~\n- 2018-10-11: Training code validated. RESNET50+BAM pretrained weight added.\n\n### Requirement\n\nThe code is validated under below environment:\n- Ubuntu 16.04, 4*GTX 1080 Ti, Docker (PyTorch 0.4.1, CUDA 9.0 + CuDNN 7.0, Python 3.6)\n\n### How to use\n\nResNet50 based examples are included. Example scripts are included under ```./scripts/``` directory.\nImageNet data should be included under ```./data/ImageNet/``` with foler named ```train``` and ```val```.\n\n```\n# To train with BAM (ResNet50 backbone)\npython train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type BAM --prefix RESNET50_IMAGENET_BAM ./data/ImageNet\n# To train with CBAM (ResNet50 backbone)\npython train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --epochs 100 --batch-size 256 --lr 0.1 --att-type CBAM --prefix RESNET50_IMAGENET_CBAM ./data/ImageNet\n```\n\n### Resume with checkpoints\n\n- ResNet50+CBAM (trained for 100 epochs) checkpoint is provided in this [link](https://drive.google.com/file/d/1mvAVvhLR_2XY_bPYxh-SEz4vDmGzSArO/view?usp=sharing). ACC@1=77.622 ACC@5=93.948\n- ResNet50+BAM (trained for 90 epochs) checkpoint is provided in this [link](https://drive.google.com/file/d/1auVf70gfL0ol40bvaX5rlbpn9cKIxhAL/view?usp=sharing). ACC@1=76.860 ACC@5=93.416\n\nFor validation, please use the script as follows\n```\npython train_imagenet.py --ngpu 4 --workers 20 --arch resnet --depth 50 --att-type CBAM --prefix EVAL --resume $CHECKPOINT_PATH$ --evaluate ./data/ImageNet\n```\n\n### Other implementations\n\n- [MXNet implementation of CBAM with several modifications](https://github.com/bruinxiong/Modified-CBAMnet.mxnet) by [bruinxiong](https://github.com/bruinxiong)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJongchan%2Fattention-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJongchan%2Fattention-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJongchan%2Fattention-module/lists"}