{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/patchcleanser-certifiably-robust-defense","title":"PatchCleanser: Certifiably Robust Defense against Adversarial Patches for Any Image Classifier","arxiv_id":"2108.09135","date":"2021-08-20","proceeding":null,"authors":["Chong Xiang","Saeed Mahloujifar","Prateek Mittal"],"abstract":"The adversarial patch attack against image classification models aims to inject adversarially crafted pixels within a restricted image region (i.e., a patch) for inducing model misclassification. This attack can be realized in the physical world by printing and attaching the patch to the victim object; thus, it imposes a real-world threat to computer vision systems. To counter this threat, we design PatchCleanser as a certifiably robust defense against adversarial patches. In PatchCleanser, we perform two rounds of pixel masking on the input image to neutralize the effect of the adversarial patch. This image-space operation makes PatchCleanser compatible with any state-of-the-art image classifier for achieving high accuracy. Furthermore, we can prove that PatchCleanser will always predict the correct class labels on certain images against any adaptive white-box attacker within our threat model, achieving certified robustness. We extensively evaluate PatchCleanser on the ImageNet, ImageNette, CIFAR-10, CIFAR-100, SVHN, and Flowers-102 datasets and demonstrate that our defense achieves similar clean accuracy as state-of-the-art classification models and also significantly improves certified robustness from prior works. Remarkably, PatchCleanser achieves 83.9% top-1 clean accuracy and 62.1% top-1 certified robust accuracy against a 2%-pixel square patch anywhere on the image for the 1000-class ImageNet dataset.","url_abs":"https://arxiv.org/abs/2108.09135v2","url_pdf":"https://arxiv.org/pdf/2108.09135v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"patchcleanser-certifiably-robust-defense","repo_url":"https://github.com/inspire-group/PatchCleanser","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2108.09135","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2108.09135"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/inspire-group/PatchCleanser","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":6},"by_repo_kind":{"official":{"samples":6,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"eec1dffb030e6ea0","entry":"double_masking","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"utils/defense.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/utils/defense.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"eec1dffb030e6ea0"}},{"code_sha256_prefix":"06cd86197cddda59","entry":"double_masking_precomputed","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"utils/defense.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/utils/defense.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"06cd86197cddda59"}},{"code_sha256_prefix":"03785e97d143efc7","entry":"gen_mask_set","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"utils/defense.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/utils/defense.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"03785e97d143efc7"}},{"code_sha256_prefix":"512589c1670e79f2","entry":"gen_mask_set_mr","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"misc/pc_mr_experimental.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/misc/pc_mr_experimental.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"512589c1670e79f2"}},{"code_sha256_prefix":"e08babe721b045e2","entry":"process_minority_report","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"misc/pc_mr_experimental.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/misc/pc_mr_experimental.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e08babe721b045e2"}},{"code_sha256_prefix":"9dd0b4ae4528945e","entry":"provable_detection","repo":"inspire-group/PatchCleanser","repo_kind":"official","path":"misc/pc_mr.py","file_url":"https://github.com/inspire-group/PatchCleanser/blob/HEAD/misc/pc_mr.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9dd0b4ae4528945e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}