{"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/improving-sample-quality-of-diffusion-model","title":"Improving Sample Quality of Diffusion Models Using Self-Attention Guidance","arxiv_id":"2210.00939","date":"2022-10-03","proceeding":"ICCV 2023 1","authors":["Susung Hong","Gyuseong Lee","Wooseok Jang","Seungryong Kim"],"abstract":"Denoising diffusion models (DDMs) have attracted attention for their exceptional generation quality and diversity. This success is largely attributed to the use of class- or text-conditional diffusion guidance methods, such as classifier and classifier-free guidance. In this paper, we present a more comprehensive perspective that goes beyond the traditional guidance methods. From this generalized perspective, we introduce novel condition- and training-free strategies to enhance the quality of generated images. As a simple solution, blur guidance improves the suitability of intermediate samples for their fine-scale information and structures, enabling diffusion models to generate higher quality samples with a moderate guidance scale. Improving upon this, Self-Attention Guidance (SAG) uses the intermediate self-attention maps of diffusion models to enhance their stability and efficacy. Specifically, SAG adversarially blurs only the regions that diffusion models attend to at each iteration and guides them accordingly. Our experimental results show that our SAG improves the performance of various diffusion models, including ADM, IDDPM, Stable Diffusion, and DiT. Moreover, combining SAG with conventional guidance methods leads to further improvement.","url_abs":"https://arxiv.org/abs/2210.00939v6","url_pdf":"https://arxiv.org/pdf/2210.00939v6.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":"improving-sample-quality-of-diffusion-model","repo_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"improving-sample-quality-of-diffusion-model","repo_url":"https://github.com/huggingface/diffusers","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"jax","reach":null},{"paper_slug":"improving-sample-quality-of-diffusion-model","repo_url":"https://github.com/ashen-sensored/sd_webui_SAG","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"improving-sample-quality-of-diffusion-model","repo_url":"https://github.com/lllyasviel/fooocus","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"GPL-3.0"}},{"paper_slug":"improving-sample-quality-of-diffusion-model","repo_url":"https://github.com/susunghong/seg-sdxl","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"denoising","task_name":"Denoising"},{"task_slug":"diversity","task_name":"Diversity"},{"task_slug":"image-generation","task_name":"Image Generation"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"sag-1","method_name":"SAG"},{"method_slug":"sag","method_name":"Self-Attention Guidance"}],"datasets_introduced":[],"methods_introduced":[{"slug":"sag-1","name":"SAG","full_name":"Self-Attention Guidance"},{"slug":"sag","name":"Self-Attention Guidance","full_name":"Self-Attention Guidance"}],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2210.00939","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2210.00939"}},"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/huggingface/diffusers","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/susunghong/seg-sdxl","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lllyasviel/fooocus","reach":{"status":"ok","spdx":"GPL-3.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ashen-sensored/sd_webui_SAG","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/KU-CVLAB/Self-Attention-Guidance","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":6,"ran":6,"ran_honours":3,"ran_violates":2,"unverified":5},"by_repo_kind":{"official":{"samples":19,"ran":14,"repositories":1},"listed":{"samples":2,"ran":2,"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":20,"samples":[{"code_sha256_prefix":"8ab9a97df8161f31","entry":"center_crop_arr","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/image_datasets.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/image_datasets.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":2,"contract_check":"MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"8ab9a97df8161f31"}},{"code_sha256_prefix":"cfd76fd0d89574a4","entry":"approx_standard_normal_cdf","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/losses.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/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":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"cfd76fd0d89574a4"}},{"code_sha256_prefix":"e2497fcb1db5da74","entry":"attention_from_qkv","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/unet.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/unet.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"e2497fcb1db5da74"}},{"code_sha256_prefix":"2ab2316ac6fdd869","entry":"betas_for_alpha_bar","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/gaussian_diffusion.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/gaussian_diffusion.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"2ab2316ac6fdd869"}},{"code_sha256_prefix":"35572566acf61c78","entry":"create_named_schedule_sampler","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/resample.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/resample.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":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"35572566acf61c78"}},{"code_sha256_prefix":"424012cb37b31172","entry":"default","repo":"ashen-sensored/sd_webui_SAG","repo_kind":"listed","path":"scripts/SAG.py","file_url":"https://github.com/ashen-sensored/sd_webui_SAG/blob/HEAD/scripts/SAG.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"424012cb37b31172"}},{"code_sha256_prefix":"cd33283d615fb3d7","entry":"discretized_gaussian_log_likelihood","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/losses.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/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":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"cd33283d615fb3d7"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"a086d6286a40b889","entry":"get_named_beta_schedule","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/gaussian_diffusion.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/gaussian_diffusion.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"a086d6286a40b889"}},{"code_sha256_prefix":"e41367ad14ff58fd","entry":"get_param_groups_and_shapes","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/fp16_util.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/fp16_util.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"e41367ad14ff58fd"}},{"code_sha256_prefix":"e20dd5102da3b050","entry":"make_master_params","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/fp16_util.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/fp16_util.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"e20dd5102da3b050"}},{"code_sha256_prefix":"bcd8b4acab199405","entry":"make_output_format","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/logger.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/logger.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"bcd8b4acab199405"}},{"code_sha256_prefix":"cf2798b666b231ca","entry":"normal_kl","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/losses.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/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":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"cf2798b666b231ca"}},{"code_sha256_prefix":"25d9a8be93bc84f5","entry":"save_input_hook","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/unet.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/unet.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"25d9a8be93bc84f5"}},{"code_sha256_prefix":"64fff1e30802b815","entry":"unflatten_master_params","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/fp16_util.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/fp16_util.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"64fff1e30802b815"}},{"code_sha256_prefix":"c6e4e3cadf377bdf","entry":"xattn_forward_log","repo":"ashen-sensored/sd_webui_SAG","repo_kind":"listed","path":"scripts/SAG.py","file_url":"https://github.com/ashen-sensored/sd_webui_SAG/blob/HEAD/scripts/SAG.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c6e4e3cadf377bdf"}},{"code_sha256_prefix":"129b804760b3115f","entry":"zero_module","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/nn.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/nn.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":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"129b804760b3115f"}},{"code_sha256_prefix":"ecd0fc28815b65ae","entry":"avg_pool_nd","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/nn.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/nn.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"ecd0fc28815b65ae"}},{"code_sha256_prefix":"fe4eb545bbb728e0","entry":"conv_nd","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/nn.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/nn.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"fe4eb545bbb728e0"}},{"code_sha256_prefix":"e515a67f7f32e76d","entry":"mpi_weighted_mean","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/logger.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/logger.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"e515a67f7f32e76d"}},{"code_sha256_prefix":"0c6607473a4c4c55","entry":"profile","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/logger.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/logger.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"0c6607473a4c4c55"}},{"code_sha256_prefix":"53d5be4fdbcfac23","entry":"random_crop_arr","repo":"KU-CVLAB/Self-Attention-Guidance","repo_kind":"official","path":"guided_diffusion/image_datasets.py","file_url":"https://github.com/KU-CVLAB/Self-Attention-Guidance/blob/HEAD/guided_diffusion/image_datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":false,"mcp_get_code":{"code_sha256":"53d5be4fdbcfac23"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}