SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.14078 · 2024

Stable-Hair: Real-World Hair Transfer via Diffusion Model

arXiv · PDF · Open in the Atlas

Code that ran

6 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 5 failures of our instrument; 6 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2407.14078.json · badge: /api/ran/2407.14078.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Xiaojiu-z/Stable-Hair canonical (classifier label)
classifier basis: census
6 ran · 6 no recorded run
FunctionStatusWhere it lives
compute_noise Ran
ran; our contract draft was wrong, not the code
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
code served (permissive licence) · get_code("149188d4856b3bdc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal scheduler mock that has the required attributes and methods
class MockSchedulerConfig:
    def __init__(self):
        self.num_train_timesteps = 1000
        self.clip_sample = True

class MockScheduler:
    def __init__(self):
        self.config = MockSchedulerConfig()
        self.num_inference_steps = 50
        # Create a small alphas_cumprod tensor with values between 0 and 1
        self.alphas_cumprod = torch.linspace(0.9999, 0.1, 1000)
        self.final_alpha_cumprod = 0.0
    
    def _get_variance(self, timestep, prev_timestep):
        # Return a small positive variance value
        return torch.tensor(0.01)

# Create small tensor arguments
prev_latents = torch.randn(2, 4)
latents = torch.randn(2, 4)
noise_pred = torch.randn(2, 4)

# Create scheduler instance
scheduler = MockScheduler()

# Set timestep to be in valid range (between num_inference_steps and num_train_timesteps)
timestep = 500

# eta parameter for noise computation
eta = 0.0

ARGS = {
    "scheduler": scheduler,
    "prev_latents": prev_latents,
    "latents": latents,
    "timestep": timestep,
    "noise_pred": noise_pred,
    "eta": eta
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
preprocess_mask Ran
ran; our contract draft was wrong, not the code
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_inpaint.py
code served (permissive licence) · get_code("291c31214008a679")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ArrayImpl, ndim 4, dtype family float, shape (1, 1, 96, 96) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from PIL import Image
import jax.numpy as jnp
import numpy as np

# Create a simple PIL Image object with a size that's not a multiple of 32
# so we can test the rounding down logic
img_array = np.random.randint(0, 256, (100, 96, 3), dtype=np.uint8)
mask = Image.fromarray(img_array, mode='RGB')

# The function expects mask.size to return (w, h)
# and mask.resize() to work, and mask.convert('L') to convert to grayscale
# These are all standard PIL Image methods

dtype = jnp.float32

ARGS = {
    "mask": mask,
    "dtype": dtype,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 4, dtype family float, shape (1, 1, 96, 96) — shape (1, 1, 96, 96) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
renew_resnet_paths Ran
ran; our contract draft was wrong, not the code
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
code served (permissive licence) · get_code("dfb052a0af48540f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# Define the function to be tested
def shave_segments(path, n_shave_prefix_segments=1):
    """
    Removes segments. Positive values shave the first segments, negative shave the last segments.
    """
    if n_shave_prefix_segments >= 0:
        return '.'.join(path.split('.')[n_shave_prefix_segments:])
    else:
        return '.'.join(path.split('.')[:n_shave_prefix_segments])

def renew_resnet_paths(old_list, n_shave_prefix_segments=0):
    """
    Updates paths inside resnets to the new naming scheme (local renaming)
    """
    mapping = []
    for old_item in old_list:
        new_item = old_item.replace('in_layers.0', 'norm1')
        new_item = new_item.replace('in_layers.2', 'conv1')
        new_item = new_item.replace('out_layers.0', 'norm2')
        new_item = new_item.replace('out_layers.3', 'conv2')
        new_item = new_item.replace('emb_layers.1', 'time_emb_proj')
        new_item = new_item.replace('skip_connection', 'conv_shortcut')
        new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments)
        mapping.append({'old': old_item, 'new': new_item})
    return mapping

# Construct valid arguments
ARGS = {
    'old_list': [
        'module.in_layers.0.weight',
        'module.in_layers.2.bias',
        'module.out_layers.0.weight',
        'module.out_layers.3.bias',
        'module.emb_layers.1.weight',
        'module.skip_connection.weight',
    ],
    'n_shave_prefix_segments': 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
renew_vae_resnet_paths Ran
ran; our contract draft was wrong, not the code
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from tuananhbui89/Erasing-Adversarial-Preservation, is pointer only (licence: NONE) · get_code("c5ec9c13e456a046")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from tuananhbui89/Erasing-Adversarial-Preservation, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

shave_segments Ran
ran; our contract draft was wrong, not the code
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
code served (permissive licence) · get_code("cea0bc82e0c96896")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyzing the function:
# - path: string parameter that gets split by '.' and rejoined
# - n_shave_prefix_segments: int parameter that controls slicing behavior

ARGS = {
    'path': 'module.layer.weight.data.value',
    'n_shave_prefix_segments': 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unshard Ran
ran, violated the contract we drafted
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yushuiwx/Mixture-of-LoRA-Experts, is pointer only (licence: NONE) · get_code("e75e95456d9039f5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yushuiwx/Mixture-of-LoRA-Experts, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

posterior_sample Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
code served (permissive licence) · get_code("d3de8e0f9e293d59")
How it ran

no invocation recorded.

prepare_mask_and_masked_image Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_inpaint.py
code served (permissive licence) · get_code("d4431fe56ad7f713")
How it ran

no invocation recorded.

preprocess Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
code served (permissive licence) · get_code("107a1125408a883b")
How it ran

no invocation recorded.

preprocess Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_img2img.py
code served (permissive licence) · get_code("186d422b4922bcc8")
How it ran

no invocation recorded.

preprocess Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_onnx_stable_diffusion_img2img.py
code served (permissive licence) · get_code("a4ae6b8026b63031")
How it ran

no invocation recorded.

preprocess_image Not yet run
unverified (harvested, no recorded run)
Xiaojiu-z/Stable-Hair/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_inpaint.py
code served (permissive licence) · get_code("90abefb63ec10393")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 9 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 0 the same month, 4 later) and 3 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
renew_resnet_paths 14 other papers
11 dated earlier, 3 later
2307.04725 (2023-07)
AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning
2310.15169 (2023-10)
FreeNoise: Tuning-Free Longer Video Diffusion via Noise Rescheduling
2311.03054 (2023-11)
AnyText: Multilingual Visual Text Generation And Editing
and 11 more not named here
shave_segments 14 other papers
11 dated earlier, 3 later
2307.04725 (2023-07)
AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning
2310.15169 (2023-10)
FreeNoise: Tuning-Free Longer Video Diffusion via Noise Rescheduling
2311.03054 (2023-11)
AnyText: Multilingual Visual Text Generation And Editing
and 11 more not named here
renew_vae_resnet_paths 11 other papers
10 dated earlier, 1 later
2307.04725 (2023-07)
AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning
2310.15169 (2023-10)
FreeNoise: Tuning-Free Longer Video Diffusion via Noise Rescheduling
2311.16933 (2023-11)
SparseCtrl: Adding Sparse Controls to Text-to-Video Diffusion Models
and 8 more not named here
preprocess 2 other papers
1 dated earlier, 1 later
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model
2502.08590 (2025-02)
Light-A-Video: Training-free Video Relighting via Progressive Light Fusion
unshard 2 other papers
2 dated earlier
2307.13269 (2023-07)
LoraHub: Efficient Cross-Task Generalization via Dynamic LoRA Composition
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model
compute_noise 1 other paper
1 dated earlier
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model
posterior_sample 1 other paper
1 dated earlier
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model
preprocess_image 1 other paper
1 dated earlier
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model
preprocess_mask 1 other paper
1 dated earlier
2403.07764 (2024-03)
Stable-Makeup: When Real-World Makeup Transfer Meets Diffusion Model

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Current hair transfer methods struggle to handle diverse and intricate hairstyles, limiting their applicability in real-world scenarios. In this paper, we propose a novel diffusion-based hair transfer framework, named \textit{Stable-Hair}, which robustly transfers a wide range of real-world hairstyles to user-provided faces for virtual hair try-on. To achieve this goal, our Stable-Hair framework is designed as a two-stage pipeline. In the first stage, we train a Bald Converter alongside stable diffusion to remove hair from the user-provided face images, resulting in bald images. In the second stage, we specifically designed a Hair Extractor and a Latent IdentityNet to transfer the target hairstyle with highly detailed and high-fidelity to the bald image. The Hair Extractor is trained to encode reference images with the desired hairstyles, while the Latent IdentityNet ensures consistency in identity and background. To minimize color deviations between source images and transfer results, we introduce a novel Latent ControlNet architecture, which functions as both the Bald Converter and Latent IdentityNet. After training on our curated triplet dataset, our method accurately transfers highly detailed and high-fidelity hairstyles to the source images. Extensive experiments demonstrate that our approach achieves state-of-the-art performance compared to existing hair transfer methods. Project page: \textcolor{red}{\url{https://xiaojiu-z.github.io/Stable-Hair.github.io/}}

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2407.14078")
get_code_for_paper("2407.14078")
have("2407.14078")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2407.14078.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2407.14078.svg)](https://syntology.ai/paper/2407.14078)

Connect an agent — have() is free.