{"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/exact-diffusion-inversion-via-bi-directional","title":"Exact Diffusion Inversion via Bi-directional Integration Approximation","arxiv_id":"2307.10829","date":"2023-07-10","proceeding":null,"authors":["Guoqiang Zhang","J. P. Lewis","W. Bastiaan Kleijn"],"abstract":"Recently, various methods have been proposed to address the inconsistency issue of DDIM inversion to enable image editing, such as EDICT [36] and Null-text inversion [22]. However, the above methods introduce considerable computational overhead. In this paper, we propose a new technique, named \\emph{bi-directional integration approximation} (BDIA), to perform exact diffusion inversion with neglible computational overhead. Suppose we would like to estimate the next diffusion state $\\boldsymbol{z}_{i-1}$ at timestep $t_i$ with the historical information $(i,\\boldsymbol{z}_i)$ and $(i+1,\\boldsymbol{z}_{i+1})$. We first obtain the estimated Gaussian noise $\\hat{\\boldsymbol{\\epsilon}}(\\boldsymbol{z}_i,i)$, and then apply the DDIM update procedure twice for approximating the ODE integration over the next time-slot $[t_i, t_{i-1}]$ in the forward manner and the previous time-slot $[t_i, t_{t+1}]$ in the backward manner. The DDIM step for the previous time-slot is used to refine the integration approximation made earlier when computing $\\boldsymbol{z}_i$. A nice property of BDIA-DDIM is that the update expression for $\\boldsymbol{z}_{i-1}$ is a linear combination of $(\\boldsymbol{z}_{i+1}, \\boldsymbol{z}_i, \\hat{\\boldsymbol{\\epsilon}}(\\boldsymbol{z}_i,i))$. This allows for exact backward computation of $\\boldsymbol{z}_{i+1}$ given $(\\boldsymbol{z}_i, \\boldsymbol{z}_{i-1})$, thus leading to exact diffusion inversion. It is demonstrated with experiments that (round-trip) BDIA-DDIM is particularly effective for image editing. Our experiments further show that BDIA-DDIM produces markedly better image sampling qualities than DDIM for text-to-image generation. BDIA can also be applied to improve the performance of other ODE solvers in addition to DDIM. In our work, it is found that applying BDIA to the EDM sampling procedure produces consistently better performance over four pre-trained models.","url_abs":"https://arxiv.org/abs/2307.10829v6","url_pdf":"https://arxiv.org/pdf/2307.10829v6.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":"exact-diffusion-inversion-via-bi-directional","repo_url":"https://github.com/guoqiang-zhang-x/BDIA","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"image-reconstruction","task_name":"Image Reconstruction"},{"task_slug":"text-to-image-generation-1","task_name":"Text to Image Generation"},{"task_slug":"text-to-image-generation","task_name":"Text-to-Image Generation"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2307.10829","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.10829"}},"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/guoqiang-zhang-x/BDIA","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran_draft_wrong":1,"ran":4,"ran_honours":1,"unverified":9},"by_repo_kind":{"official":{"samples":15,"ran":6,"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":16,"samples":[{"code_sha256_prefix":"4cee7c1861294d59","entry":"calculate_frechet_distance","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"text-to-image/stablediffusionV2/fid_score.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/text-to-image/stablediffusionV2/fid_score.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4cee7c1861294d59"}},{"code_sha256_prefix":"8241c0562bc710fd","entry":"chunk","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"8241c0562bc710fd"}},{"code_sha256_prefix":"eafa252fd6f86857","entry":"get_parameter_device","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/modeling_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/modeling_utils.py","link_basis":"harvester_set","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":"eafa252fd6f86857"}},{"code_sha256_prefix":"dc2045840ce679cb","entry":"get_parameter_dtype","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/modeling_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/modeling_utils.py","link_basis":"harvester_set","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":"dc2045840ce679cb"}},{"code_sha256_prefix":"25d9cd38598c4751","entry":"get_timestep_embedding","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/models/embeddings.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/models/embeddings.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":"25d9cd38598c4751"}},{"code_sha256_prefix":"aa4cae054b657ba2","entry":"imread","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"text-to-image/stablediffusionV2/fid_score.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/text-to-image/stablediffusionV2/fid_score.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aa4cae054b657ba2"}},{"code_sha256_prefix":"498ae1b2f8e470f7","entry":"upfirdn2d_native","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/models/resnet.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/models/resnet.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":"498ae1b2f8e470f7"}},{"code_sha256_prefix":"301682fc3342590a","entry":"check_imports","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/dynamic_modules_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/dynamic_modules_utils.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":"301682fc3342590a"}},{"code_sha256_prefix":"a0900d0499301ed4","entry":"downsample_2d","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/models/resnet.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/models/resnet.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":"a0900d0499301ed4"}},{"code_sha256_prefix":"52f0b0681052dbb6","entry":"get_activations","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"text-to-image/stablediffusionV2/fid_score.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/text-to-image/stablediffusionV2/fid_score.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":"52f0b0681052dbb6"}},{"code_sha256_prefix":"d7a3942d0d5c6041","entry":"get_full_repo_name","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/hub_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/hub_utils.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":"d7a3942d0d5c6041"}},{"code_sha256_prefix":"00cc853a73f3aeb6","entry":"get_relative_import_files","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/dynamic_modules_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/dynamic_modules_utils.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":"00cc853a73f3aeb6"}},{"code_sha256_prefix":"450aeffe7f80f917","entry":"get_relative_imports","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/dynamic_modules_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/dynamic_modules_utils.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":"450aeffe7f80f917"}},{"code_sha256_prefix":"4c264554ae99a2ef","entry":"init_git_repo","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/hub_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/hub_utils.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":"4c264554ae99a2ef"}},{"code_sha256_prefix":"77bd5e6e8ca8c91d","entry":"load_state_dict","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/modeling_utils.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/modeling_utils.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":"77bd5e6e8ca8c91d"}},{"code_sha256_prefix":"9a0acd22f4c9b83f","entry":"upsample_2d","repo":"guoqiang-zhang-x/BDIA","repo_kind":"official","path":"image-editing/my_diffusers/models/resnet.py","file_url":"https://github.com/guoqiang-zhang-x/BDIA/blob/HEAD/image-editing/my_diffusers/models/resnet.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":"9a0acd22f4c9b83f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}