{"id":13737923,"url":"https://github.com/ExplainableML/ACVC","last_synced_at":"2025-05-08T15:32:02.382Z","repository":{"id":73022391,"uuid":"479327739","full_name":"ExplainableML/ACVC","owner":"ExplainableML","description":"Official PyTorch implementation of CVPRW 2022 paper \"Attention Consistency on Visual Corruptions for Single-Source Domain Generalization\"","archived":false,"fork":false,"pushed_at":"2023-02-22T19:22:46.000Z","size":2345,"stargazers_count":28,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-15T06:32:50.357Z","etag":null,"topics":["computer-vision","cvpr","cvpr2022","cvprw","cvprw2022","data-augmentation","deep-learning","domain-generalization","l3d-ivu","machine-learning","pytorch","single-source-domain-generalization"],"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/ExplainableML.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,"roadmap":null,"authors":null}},"created_at":"2022-04-08T09:29:31.000Z","updated_at":"2024-07-05T09:14:47.000Z","dependencies_parsed_at":"2024-01-07T17:10:57.712Z","dependency_job_id":"9bc68d45-863a-4ad0-bb48-e46c56d100bd","html_url":"https://github.com/ExplainableML/ACVC","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/ExplainableML%2FACVC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExplainableML%2FACVC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExplainableML%2FACVC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExplainableML%2FACVC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExplainableML","download_url":"https://codeload.github.com/ExplainableML/ACVC/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253096245,"owners_count":21853565,"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":["computer-vision","cvpr","cvpr2022","cvprw","cvprw2022","data-augmentation","deep-learning","domain-generalization","l3d-ivu","machine-learning","pytorch","single-source-domain-generalization"],"created_at":"2024-08-03T03:02:05.972Z","updated_at":"2025-05-08T15:32:01.996Z","avatar_url":"https://github.com/ExplainableML.png","language":"Python","readme":"# ACVC\n\u003e [**Attention Consistency on Visual Corruptions for Single-Source Domain Generalization**](https://openaccess.thecvf.com/content/CVPR2022W/L3D-IVU/html/Cugu_Attention_Consistency_on_Visual_Corruptions_for_Single-Source_Domain_Generalization_CVPRW_2022_paper.html)            \n\u003e [Ilke Cugu](https://cuguilke.github.io/), \n\u003e [Massimiliano Mancini](https://www.eml-unitue.de/people/massimiliano-mancini), \n\u003e [Yanbei Chen](https://www.eml-unitue.de/people/yanbei-chen), \n\u003e [Zeynep Akata](https://www.eml-unitue.de/people/zeynep-akata)        \n\u003e *IEEE Computer Vision and Pattern Recognition Workshops (CVPRW), 2022* \n\n\u003cp float=\"center\"\u003e\n  \u003cimg src=\"assets/ACVC_flow.png\" width=\"100%\" /\u003e\n\u003c/p\u003e\n\nThe official PyTorch implementation of the **CVPR 2022, L3D-IVU Workshop** paper titled \"Attention Consistency on Visual Corruptions for Single-Source Domain Generalization\". This repository contains: (1) our single-source domain generalization benchmark that aims at generalizing from natural images to other domains such as paintings, cliparts and skethces, (2) our adaptation/version of well-known advanced data augmentation techniques in the literaure, and (3) our final model ACVC which fuses visual corruptions with an attention consistency loss.\n\n## Dependencies\n```\ntorch~=1.5.1+cu101\nnumpy~=1.19.5\ntorchvision~=0.6.1+cu101\nPillow~=8.3.1\nmatplotlib~=3.1.1\nsklearn~=0.0\nscikit-learn~=0.24.1\nscipy~=1.6.1\nimagecorruptions~=1.1.2\ntqdm~=4.58.0\npycocotools~=2.0.0\n```\n\n- We also include a YAML script `acvc-pytorch.yml` that is prepared for an easy Anaconda environment setup. \n\n- One can also use the `requirements.txt` if one knows one's craft.\n\n## Training\n\nTraining is done via `run.py`. To get the up-to-date list of commands:\n```shell\npython run.py --help\n```\n\nWe include a sample script `run_experiments.sh` for a quick start.\n\n## Analysis\n\nThe benchmark results are prepared by `analysis/GeneralizationExpProcessor.py`, which outputs LaTeX tables of the cumulative results in a .tex file.\n\n- For example:\n```shell\npython GeneralizationExpProcessor.py --path generalization.json --to_dir ./results --image_format pdf\n```\n\n- You can also run distributed experiments, and merge the results later on:\n```shell\npython GeneralizationExpProcessor.py --merge_logs generalization_gpu0.json generalization_gpu1.json\n```\n\n## Case Study: COCO benchmark\n\nCOCO benchmark is especially useful for further studies on ACVC since it includes segmentation masks per image.\n\nHere are the steps to make it work:\n1. For this benchmark you only need 10 classes:\n```\nairplane\nbicycle\nbus\ncar\nhorse\nknife\nmotorcycle\nskateboard\ntrain\ntruck\n```\n\n\n2. Download COCO 2017 [trainset](http://images.cocodataset.org/zips/train2017.zip), [valset](images.cocodataset.org/zips/val2017.zip), and [annotations](http://images.cocodataset.org/annotations/annotations_trainval2017.zip)\n\n\n3. Extract the annotations zip file into a folder named `COCO` inside your choice of `data_dir` (For example: `datasets/COCO`)\n\n\n4. Extract train and val set zip files into a subfolder named `downloads` (For example: `datasets/COCO/downloads`)\n\n\n5. Download [DomainNet (clean version)](https://ai.bu.edu/M3SDA/)\n\n\n6. Create a new `DomainNet` folder next to your `COCO` folder\n\n\n7. Extract each domain's zip file under its respective subfolder (For example: `datasets/DomainNet/clipart`)\n\n\n8. Back to the project, use `--first_run` argument once while running the training script:\n```shell\npython run.py --loss CrossEntropy --epochs 1 --corruption_mode None --data_dir datasets --first_run --train_dataset COCO --test_datasets DomainNet:Real --print_config\n```\n\n\n9. If everything works fine, you will see `train2017` and `val2017` folders under `COCO`\n\n\n10. Both folders must contain 10 subfolders that belong to shared classes between COCO and DomainNet   \n\n\n11. Now, try running ACVC as well:\n```shell\npython run.py --loss CrossEntropy AttentionConsistency --epochs 1 --corruption_mode acvc --data_dir datasets --train_dataset COCO --test_datasets DomainNet:Real --print_config\n```\n\n\n12. All good? Then, you are good to go with the COCO section of `run_experiments.sh` to run multiple experiments\n\n\n13. That's it! \n\n## Citation\n\nIf you use these codes in your research, please cite:\n\n```bibtex\n@InProceedings{Cugu_2022_CVPR,\n    author    = {Cugu, Ilke and Mancini, Massimiliano and Chen, Yanbei and Akata, Zeynep},\n    title     = {Attention Consistency on Visual Corruptions for Single-Source Domain Generalization},\n    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},\n    month     = {June},\n    year      = {2022},\n    pages     = {4165-4174}\n}\n```\n\n## References\n\nWe indicate if a function or script is borrowed externally inside each file.\nSpecifically for visual corruption implementations we benefit from:\n\n- The imagecorruptions library of [Autonomous Driving when Winter is Coming](https://github.com/bethgelab/imagecorruptions).\n\nConsider citing this work as well if you use it in your project.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FExplainableML%2FACVC","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FExplainableML%2FACVC","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FExplainableML%2FACVC/lists"}