{"id":13574771,"url":"https://github.com/Bai-YT/AdaptiveSmoothing","last_synced_at":"2025-04-04T18:32:04.623Z","repository":{"id":158431517,"uuid":"593423621","full_name":"Bai-YT/AdaptiveSmoothing","owner":"Bai-YT","description":"Implementation of the paper \"Improving the Accuracy-Robustness Trade-off of Classifiers via Adaptive Smoothing\".","archived":false,"fork":false,"pushed_at":"2024-02-06T20:36:56.000Z","size":1677,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-05T10:44:38.528Z","etag":null,"topics":["adversarial-attacks","adversarial-defense","adversarial-machine-learning","adversarial-robustness","robust-machine-learning"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2301.12554","language":"Jupyter Notebook","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/Bai-YT.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-26T00:25:55.000Z","updated_at":"2024-10-20T04:20:20.000Z","dependencies_parsed_at":"2024-11-05T10:57:13.480Z","dependency_job_id":null,"html_url":"https://github.com/Bai-YT/AdaptiveSmoothing","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/Bai-YT%2FAdaptiveSmoothing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bai-YT%2FAdaptiveSmoothing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bai-YT%2FAdaptiveSmoothing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bai-YT%2FAdaptiveSmoothing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bai-YT","download_url":"https://codeload.github.com/Bai-YT/AdaptiveSmoothing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247229642,"owners_count":20905090,"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":["adversarial-attacks","adversarial-defense","adversarial-machine-learning","adversarial-robustness","robust-machine-learning"],"created_at":"2024-08-01T15:00:54.565Z","updated_at":"2025-04-04T18:32:04.114Z","avatar_url":"https://github.com/Bai-YT.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"## Improving the Accuracy-Robustness Trade-off of Classifiers via Adaptive Smoothing\n\nThis repository is the official code base for the paper [Improving the Accuracy-Robustness Trade-off of Classifiers via Adaptive Smoothing](https://arxiv.org/abs/2301.12554).\n\nWe publically share one CIFAR-10 model and two CIFAR-100 models that aim to defend the $\\ell_\\infty$ attack. Each proposed models rely on an accurate base classifier, a robust base classifier, and an optional \"mixing network\". The two proposed models share the same accurate base classifier but use two different robust base models and mixing networks. The results are the following:\n\n| Model             | Clean Accuracy | $\\ell_\\infty$ AutoAttacked Accuracy ($\\epsilon = 8/255$) |\n|-------------------|----------------|----------------------------------------------------------|\n| CIFAR-10          | 95.23 %        | 68.06 %                                                  |\n| CIFAR-100 Model 1 | 85.21 %        | 38.72 %                                                  |\n| CIFAR-100 Model 2 | 80.18 %        | 35.15 %                                                  |\n\nThese results are also verified and listed on [RobustBench](https://robustbench.github.io).\n\n#### Citing our work (BibTeX)\n\n```bibtex\n@article{bai2023improving,\n  title={Improving the Accuracy-Robustness Trade-off of Classifiers via Adaptive Smoothing},\n  author={Bai, Yatong and Anderson, Brendon G and Kim, Aerin and Sojoudi, Somayeh},\n  journal={arXiv preprint arXiv:2301.12554},\n  year={2023}\n}\n```\n\n\n### Running RobustBench to replicate the results\n\nRunning the [RobustBench](https://github.com/RobustBench/robustbench) benchmark should only require `pytorch`, `torchvision`, `numpy`, `click`, and `robustbench` packages.\n\nMake a directory `\u003cYOUR_MODEL_ROOT_DIR\u003e` at a desired path to store the model checkpoints. Then, download the following models:\n- Accurate base classifier: [Big Transfer (BiT)](https://github.com/google-research/big_transfer) ResNet-152 model finetuned on CIFAR-100 -- [download](http://172.233.227.28/base_models/cifar100/cifar100_std_rn152.pt).\n- Robust base classifier 1: WideResNet-70-16 model from [this repo](https://github.com/wzekai99/DM-Improves-AT) -- [download](https://huggingface.co/wzekai99/DM-Improves-AT/resolve/main/checkpoint/cifar100_linf_wrn70-16.pt) and rename as `cifar100_linf_edm_wrn70-16.pt`.\n  - This model was trained on additional images generated by a EDM diffusion model.\n- Robust base classifier 2: WideResNet-70-16 model from [this repo](https://github.com/deepmind/deepmind-research/tree/master/adversarial_robustness) -- [download](https://storage.googleapis.com/dm-adversarial-robustness/cifar100_linf_wrn70-16_with.pt) and rename as `cifar100_linf_trades_wrn70-16.pt`.\n- Mixing network to be coupled with robust base classifier 1 -- [download](https://drive.google.com/uc?export=download\u0026id=15FHXj7lmAgKT4Miu6S1CONufFtAwlWyT).\n- Mixing network to be coupled with robust base classifier 2 -- [download](https://drive.google.com/uc?export=download\u0026id=1_Lh0XLlo3mX0B9o2jGebG8L6h_NpwFea).\n\n\n**Edited on August 3, 2023:**\n\n**We have added a CIFAR-10 model to our results.**\n- The accurate base classifier is a [Big Transfer (BiT)](https://github.com/google-research/big_transfer) ResNet-152 model finetuned on CIFAR-10 -- [download](http://172.233.227.28/base_models/cifar10/cifar10_std_rn152.pt).\n- The robust base classifier is a WideResNet-70-16 model from [this repo](https://github.com/wzekai99/DM-Improves-AT) -- [download](https://huggingface.co/wzekai99/DM-Improves-AT/resolve/main/checkpoint/cifar10_linf_wrn70-16.pt) and rename as `cifar10_linf_edm_wrn70-16.pt`.\n- The corresponding mixing network -- [download](https://drive.google.com/uc?export=download\u0026id=1SE19EHy6WFDqpNs2_exQ9iotV2sF0CZ9).\n\nNow, organize `\u003cYOUR_MODEL_ROOT_DIR\u003e` following the structure below:\n```\n\u003cYOUR_MODEL_ROOT_DIR\u003e\n│\n└───Base\n│   │   cifar100_linf_edm_wrn70-16.pt\n│   │   cifar100_linf_trades_wrn70-16.pt\n|   |   cifar10_linf_edm_wrn70-16.pt\n│   │   cifar100_bit_rn152.tar\n│   │   cifar10_bit_rn152.tar\n│   \n└───CompModel\n    │   cifar100_edm_best.pt\n    │   cifar100_trades_best.pt\n    │   cifar100_edm_best.pt\n```\n\nTo benchmark existing models with RobustBench, run the following:\n```\npython run_robustbench.py --root_dir \u003cYOUR_MODEL_ROOT_DIR\u003e --dataset {cifar10, cifar100} --model_name {edm,trades}\n```\n\nNote that while the base classifiers may require additional (collected or synthesized) training data, the provided mixing networks were only trained on CIFAR training data.\n\n### Training a new model\n\nTo train a new model with the provided code, install the full environment. We require the following packages: `pytorch torchvision tensorboard pytorch_warmup numpy scipy matplotlib jupyter notebook ipykernel ipywidgets tqdm click PyYAML`.\n\nTo train, run the following:\n```\npython run.py --training --config configs/xxx.yaml\n```\n\nTo evaluate, run the following:\n```\npython run.py --eval --config configs/xxx.yaml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBai-YT%2FAdaptiveSmoothing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBai-YT%2FAdaptiveSmoothing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBai-YT%2FAdaptiveSmoothing/lists"}