{"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/what-to-preserve-and-what-to-transfer","title":"What to Preserve and What to Transfer: Faithful, Identity-Preserving Diffusion-based Hairstyle Transfer","arxiv_id":"2408.16450","date":"2024-08-29","proceeding":null,"authors":["Chaeyeon Chung","Sunghyun Park","Jeongho Kim","Jaegul Choo"],"abstract":"Hairstyle transfer is a challenging task in the image editing field that modifies the hairstyle of a given face image while preserving its other appearance and background features. The existing hairstyle transfer approaches heavily rely on StyleGAN, which is pre-trained on cropped and aligned face images. Hence, they struggle to generalize under challenging conditions such as extreme variations of head poses or focal lengths. To address this issue, we propose a one-stage hairstyle transfer diffusion model, HairFusion, that applies to real-world scenarios. Specifically, we carefully design a hair-agnostic representation as the input of the model, where the original hair information is thoroughly eliminated. Next, we introduce a hair align cross-attention (Align-CA) to accurately align the reference hairstyle with the face image while considering the difference in their head poses. To enhance the preservation of the face image's original features, we leverage adaptive hair blending during the inference, where the output's hair regions are estimated by the cross-attention map in Align-CA and blended with non-hair areas of the face image. Our experimental results show that our method achieves state-of-the-art performance compared to the existing methods in preserving the integrity of both the transferred hairstyle and the surrounding features. The codes are available at https://github.com/cychungg/HairFusion","url_abs":"https://arxiv.org/abs/2408.16450v2","url_pdf":"https://arxiv.org/pdf/2408.16450v2.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":"what-to-preserve-and-what-to-transfer","repo_url":"https://github.com/cychungg/hairfusion","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"align","method_name":"ALIGN"},{"method_slug":"adaptive-instance-normalization","method_name":"Adaptive Instance Normalization"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"feedforward-network","method_name":"Feedforward Network"},{"method_slug":"r1-regularization","method_name":"R1 Regularization"},{"method_slug":"stylegan","method_name":"StyleGAN"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2408.16450","atlas_url":"https://app.syntology.ai/?focus=2408.16450","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.16450"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/cychungg/hairfusion","reach":{"status":"ok"}}],"summary":{"ran":5,"ran_draft_wrong":1,"unverified":3},"by_repo_kind":{"official":{"samples":9,"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":9,"samples":[{"code_sha256_prefix":"cb0c1205020f5f67","entry":"build_config","repo":"cychungg/hairfusion","repo_kind":"official","path":"inference.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/inference.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":"cb0c1205020f5f67"}},{"code_sha256_prefix":"a92e42c28a066d4e","entry":"get_fn","repo":"cychungg/hairfusion","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/dataset.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a92e42c28a066d4e"}},{"code_sha256_prefix":"f4d6a41b4e50d0cb","entry":"imread","repo":"cychungg/hairfusion","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/dataset.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":"f4d6a41b4e50d0cb"}},{"code_sha256_prefix":"f6ab4b62b58c4b25","entry":"imread_for_albu","repo":"cychungg/hairfusion","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/dataset.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":"f6ab4b62b58c4b25"}},{"code_sha256_prefix":"29e5e72bcd006dcd","entry":"spatial_average","repo":"cychungg/hairfusion","repo_kind":"official","path":"eval_models/networks_basic.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/eval_models/networks_basic.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":"29e5e72bcd006dcd"}},{"code_sha256_prefix":"351677a36e1961df","entry":"upsample","repo":"cychungg/hairfusion","repo_kind":"official","path":"eval_models/networks_basic.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/eval_models/networks_basic.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"351677a36e1961df"}},{"code_sha256_prefix":"cfc17707f35e7ec4","entry":"get_state_dict","repo":"cychungg/hairfusion","repo_kind":"official","path":"cldm/model.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/cldm/model.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":"cfc17707f35e7ec4"}},{"code_sha256_prefix":"35ad646f5b9e8cbf","entry":"load_state_dict","repo":"cychungg/hairfusion","repo_kind":"official","path":"cldm/model.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/cldm/model.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":"35ad646f5b9e8cbf"}},{"code_sha256_prefix":"dfd2379e29a03aef","entry":"score_2afc_dataset","repo":"cychungg/hairfusion","repo_kind":"official","path":"eval_models/dist_model.py","file_url":"https://github.com/cychungg/hairfusion/blob/HEAD/eval_models/dist_model.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":"dfd2379e29a03aef"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}