{"id":19382883,"url":"https://github.com/locuslab/smoothinv","last_synced_at":"2025-10-20T02:06:32.345Z","repository":{"id":96318725,"uuid":"606950196","full_name":"locuslab/smoothinv","owner":"locuslab","description":"Single Image Backdoor Inversion via Robust Smoothed Classifiers","archived":false,"fork":false,"pushed_at":"2023-07-18T12:41:44.000Z","size":12051,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T20:11:24.670Z","etag":null,"topics":[],"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/locuslab.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-02-27T01:48:18.000Z","updated_at":"2024-03-25T00:15:07.000Z","dependencies_parsed_at":"2024-11-10T09:36:51.551Z","dependency_job_id":null,"html_url":"https://github.com/locuslab/smoothinv","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/locuslab%2Fsmoothinv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Fsmoothinv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Fsmoothinv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/locuslab%2Fsmoothinv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/locuslab","download_url":"https://codeload.github.com/locuslab/smoothinv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250509870,"owners_count":21442514,"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-10T09:23:40.544Z","updated_at":"2025-10-20T02:06:32.339Z","avatar_url":"https://github.com/locuslab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SmoothInv\n\nOfficial PyTorch implementation of our CVPR 2023 paper:\n\n\u003e Single Image Backdoor Inversion via Robust Smoothed Classifiers       \n\u003e Mingjie Sun, J. Zico Kolter       \n\u003e Carnegie Mellon University, Bosch Center for AI      \n\nFor more details, please check out our [\u003cins\u003e**paper**\u003c/ins\u003e](https://arxiv.org/abs/2303.00215).\n\n---\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"figures/demo.png\" width=100% height=100% \nclass=\"center\"\u003e\n\u003c/p\u003e\n\nWe propose **SmoothInv**, a backdoor inversion method that reconstruct faithful backdoors from a single test image.\n\n\n## Setup\nCreate an new conda virtual environment\n```\nconda create -n smoothinv python=3.8 -y\nconda activate smoothinv\n```\n\nInstall Pytorch\u003e=1.8.0, torchvision\u003e=0.9.0 following official instructions. For example:\n```\npip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html\n```\n\nClone this repo and install required packages:\n```\ngit clone \npip install scikit-image\n```\n\n### Backdoored Classifiers\nCreate a directory `weights` in the main repo and download backdoored classifiers listed below into this directory.\n| model name | backdoor ASR | download path |\n|:---:|:---:|:---:|\n| Blind-P | 99.29\\% |[model](https://drive.google.com/file/d/1py8WirtbdpzG80IW4wrjrkJSRJLUrljE/view?usp=share_link) |\n| Blind-S | 79.73\\% |[model](https://drive.google.com/file/d/1C96s23k7wWMUiRbavlcgNx-vMbWNV5n-/view?usp=sharing) |\n| Blind-G | 100.00\\% |[model](https://drive.google.com/file/d/1y41CDW3c1H3SJ6tGC3VaiVjgnogykaCx/view?usp=share_link) |\n| TrojAI | 100.00\\% |[model](https://drive.google.com/file/d/1rUujVA96O438cxHnT6qZaYeHeX_kV6hO/view?usp=share_link) |\n| HTBA | 54.00\\%  |[model](https://drive.google.com/file/d/1DF8B4TtdZ219wdtO76KyOVlWtBumROy3/view?usp=share_link) |\n\nAlso to use SmoothInv *w diffusion*, download the ImageNet unconditional diffusion model from [guided-diffusion](https://github.com/openai/guided-diffusion) into the `weights` directory.\n\n## Evaluation\n\nFor visualization, use:\n```\nCUDA_VISIBLE_DEVICES=[GPU IDs] python main_vis.py --sigma [noise level] --backdoor_clf [trojai/htba/blind-p/blind-s/blind-g] --imagenet_dir [path to ImageNet] --eps 10 --no_diffusion\n```\n\nTo evaluate the ASR of reversed backdoors, use:\n```\nCUDA_VISIBLE_DEVICES=[GPU IDs] python main_eval.py --sigma [noise level] --backdoor_clf [trojai/htba/blind-p/blind-s/blind-g] --imagenet_dir [path to ImageNet] --no_diffusion\n```\n\nTurn off `--no_diffusion` if you want to use SmoothInv *w diffusion*.\n\n## Acknowledgement\nThis repository is built using the [smoothadv](https://github.com/Hadisalman/smoothing-adversarial), [blind-backdoors](https://github.com/ebagdasa/backdoors101) library and [diffusion-denoised-smoothing](https://github.com/ethz-privsec/diffusion_denoised_smoothing) repositories.\n\n## License\nThis project is released under the MIT license. Please see the [LICENSE](LICENSE) file for more information.\n\n## Citation\nIf you find this repository helpful, please consider citing:\n```\n@Article{sun2023smoothinv,\n  author  = {Sun, Mingjie and Kolter, Zico},\n  title   = {Single Image Backdoor Inversion via Robust Smoothed Classifiers},\n  journal = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n  year    = {2023},\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocuslab%2Fsmoothinv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocuslab%2Fsmoothinv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocuslab%2Fsmoothinv/lists"}