{"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/efficient-image-to-image-diffusion-classifier","title":"Efficient Image-to-Image Diffusion Classifier for Adversarial Robustness","arxiv_id":"2408.08502","date":"2024-08-16","proceeding":null,"authors":["Hefei Mei","Minjing Dong","Chang Xu"],"abstract":"Diffusion models (DMs) have demonstrated great potential in the field of adversarial robustness, where DM-based defense methods can achieve superior defense capability without adversarial training. However, they all require huge computational costs due to the usage of large-scale pre-trained DMs, making it difficult to conduct full evaluation under strong attacks and compare with traditional CNN-based methods. Simply reducing the network size and timesteps in DMs could significantly harm the image generation quality, which invalidates previous frameworks. To alleviate this issue, we redesign the diffusion framework from generating high-quality images to predicting distinguishable image labels. Specifically, we employ an image translation framework to learn many-to-one mapping from input samples to designed orthogonal image labels. Based on this framework, we introduce an efficient Image-to-Image diffusion classifier with a pruned U-Net structure and reduced diffusion timesteps. Besides the framework, we redesign the optimization objective of DMs to fit the target of image classification, where a new classification loss is incorporated in the DM-based image translation framework to distinguish the generated label from those of other classes. We conduct sufficient evaluations of the proposed classifier under various attacks on popular benchmarks. Extensive experiments show that our method achieves better adversarial robustness with fewer computational costs than DM-based and CNN-based methods. The code is available at https://github.com/hfmei/IDC.","url_abs":"https://arxiv.org/abs/2408.08502v1","url_pdf":"https://arxiv.org/pdf/2408.08502v1.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":"efficient-image-to-image-diffusion-classifier","repo_url":"https://github.com/hfmei/idc","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"adversarial-robustness","task_name":"Adversarial Robustness"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"translation","task_name":"Translation"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"concatenated-skip-connection","method_name":"Concatenated Skip Connection"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"max-pooling","method_name":"Max Pooling"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"u-net","method_name":"U-Net"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2408.08502","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.08502"}},"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/hfmei/idc","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":8,"ran":5,"ran_fixture":1,"ran_honours":1,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":18,"ran":16,"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":18,"samples":[{"code_sha256_prefix":"c3a6b977022957cb","entry":"Normalize","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/ddpm/unet_ddpm.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/ddpm/unet_ddpm.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c3a6b977022957cb"}},{"code_sha256_prefix":"cfd76fd0d89574a4","entry":"approx_standard_normal_cdf","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/guided_diffusion/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/guided_diffusion/losses.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cfd76fd0d89574a4"}},{"code_sha256_prefix":"ad12a494674d23fb","entry":"compute_n_params","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/utils.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ad12a494674d23fb"}},{"code_sha256_prefix":"bd1f17e427bf51a5","entry":"dict2namespace","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/utils.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bd1f17e427bf51a5"}},{"code_sha256_prefix":"cd33283d615fb3d7","entry":"discretized_gaussian_log_likelihood","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/guided_diffusion/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/guided_diffusion/losses.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cd33283d615fb3d7"}},{"code_sha256_prefix":"8ff7c24dade9904c","entry":"get_optimizer","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8ff7c24dade9904c"}},{"code_sha256_prefix":"fac494cec4301110","entry":"get_sde_loss_fn","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fac494cec4301110"}},{"code_sha256_prefix":"cb49209c125de1b4","entry":"get_timestep_embedding","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/ddpm/unet_ddpm.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/ddpm/unet_ddpm.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cb49209c125de1b4"}},{"code_sha256_prefix":"195d635db8eb778b","entry":"lerp_clip","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/classifiers/attribute_net.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/classifiers/attribute_net.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"195d635db8eb778b"}},{"code_sha256_prefix":"d5eb57879ef1704e","entry":"max_res_from_state_dict","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/classifiers/attribute_net.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/classifiers/attribute_net.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d5eb57879ef1704e"}},{"code_sha256_prefix":"3137073275f8c21a","entry":"nonlinearity","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/ddpm/unet_ddpm.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/ddpm/unet_ddpm.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3137073275f8c21a"}},{"code_sha256_prefix":"cf2798b666b231ca","entry":"normal_kl","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/guided_diffusion/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/guided_diffusion/losses.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cf2798b666b231ca"}},{"code_sha256_prefix":"366bb8c7035a2fc8","entry":"optimization_manager","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/losses.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"366bb8c7035a2fc8"}},{"code_sha256_prefix":"a05b1d0cf3f508b4","entry":"register_corrector","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/sampling.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/sampling.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a05b1d0cf3f508b4"}},{"code_sha256_prefix":"473066ddf62a075a","entry":"register_predictor","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/sampling.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/sampling.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"473066ddf62a075a"}},{"code_sha256_prefix":"7c508037b40522af","entry":"str2bool","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/utils.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/utils.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7c508037b40522af"}},{"code_sha256_prefix":"0dd156dfa78cac88","entry":"from_state_dict","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/classifiers/attribute_net.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/classifiers/attribute_net.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0dd156dfa78cac88"}},{"code_sha256_prefix":"a58facb8fe71823a","entry":"get_predictor","repo":"hfmei/idc","repo_kind":"official","path":"IDC-BPDA/score_sde/sampling.py","file_url":"https://github.com/hfmei/idc/blob/HEAD/IDC-BPDA/score_sde/sampling.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a58facb8fe71823a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}