SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.09965 · IJCAI · 2021

HifiFace: 3D Shape and Semantic Prior Guided High Fidelity Face Swapping

Rongrong Ji, Ying Tai, Xu Chen, Yongjian Wu, Yuhan Wang, Chengjie Wang, Jilin Li, Feiyue Huang, Wenqing Chu, Junwei Zhu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 3 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/2106.09965.json · badge: /api/ran/2106.09965.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
mindslab-ai/hififace community
Papers with Code archive
6 ran · 3 no recorded run
FunctionStatusWhere it lives
AdaIn Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("1bd881bcb0d57b8b")
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 an instance of its own class, AdaIn: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

class AdaIn(nn.Module):

    def __init__(self, in_channel, vector_size):
        super(AdaIn, self).__init__()
        self.eps = 1e-05
        self.std_style_fc = nn.Linear(vector_size, in_channel)
        self.mean_style_fc = nn.Linear(vector_size, in_channel)

    def forward(self, x, style_vector):
        import torch.nn.functional as F
        std_style = self.std_style_fc(style_vector)
        mean_style = self.mean_style_fc(style_vector)
        std_style = std_style.unsqueeze(-1).unsqueeze(-1)
        mean_style = mean_style.unsqueeze(-1).unsqueeze(-1)
        x = F.instance_norm(x)
        x = std_style * x + mean_style
        return x

in_channel = 4
vector_size = 3

adain_module = AdaIn(in_channel, vector_size)

# Create small tensors for forward pass
# x should be (batch, channels, height, width)
x = torch.randn(2, 4, 5, 5)

# style_vector should be (batch, vector_size)
style_vector = torch.randn(2, 3)

ARGS = {
    'in_channel': in_channel,
    'vector_size': vector_size
}
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 AdaIn — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AdaIn 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
AdaInResBlock Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("c4fc51a9b20f2ffb")
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 an instance of its own class, AdaInResBlock: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

# Create the AdaInResBlock module
ARGS = {
    'in_channel': 16,
    'out_channel': 32,
    'up_sample': False
}
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 AdaInResBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AdaInResBlock 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
Decoder Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("783124ffe8118da5")
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 an instance of its own class, Decoder: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

ARGS = {}
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 Decoder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Decoder 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
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("52cef0e5b0e022d8")
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 an instance of its own class, Encoder: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

class Encoder(nn.Module):

    def __init__(self):
        super(Encoder, self).__init__()
        self.conv_first = nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=1)
        self.channel_list = [64, 128, 256, 512, 512, 512, 512, 512]
        self.down_sample = [True, True, True, True, True, False, False]
        self.block_list = nn.ModuleList()
        for i in range(7):
            from __main__ import ResBlock
            self.block_list.append(ResBlock(self.channel_list[i], self.channel_list[i + 1], down_sample=self.down_sample[i]))

    def forward(self, x):
        x = self.conv_first(x)
        z_enc = None
        for i in range(7):
            x = self.block_list[i](x)
            if i == 1:
                z_enc = x
        return (z_enc, x)


class ResBlock(nn.Module):

    def __init__(self, in_channel, out_channel, down_sample=False, up_sample=False):
        super(ResBlock, self).__init__()
        main_module_list = []
        main_module_list += [nn.InstanceNorm2d(in_channel), nn.LeakyReLU(0.2), nn.Conv2d(in_channel, out_channel, kernel_size=3, stride=1, padding=1)]
        if down_sample:
            main_module_list.append(nn.AvgPool2d(kernel_size=2))
        elif up_sample:
            main_module_list.append(nn.Upsample(scale_factor=2, mode='bilinear'))
        main_module_list += [nn.InstanceNorm2d(out_channel), nn.LeakyReLU(0.2), nn.Conv2d(out_channel, out_channel, kernel_size=3, stride=1, padding=1)]
        self.main_path = nn.Sequential(*main_module_list)
        side_module_list = [nn.Conv2d(in_channel, out_channel, kernel_size=1, stride=1, padding=0)]
        if down_sample:
            side_module_list.append(nn.AvgPool2d(kernel_size=2))
        elif up_sample:
            side_module_list.append(nn.Upsample(scale_factor=2, mode='bilinear'))
        self.side_path = nn.Sequential(*side_module_list)

    def forward(self, x):
        x1 = self.main_path(x)
        x2 = self.side_path(x)
        return x1 + x2


ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
__main__, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Encoder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Encoder 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
ResBlock Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("b376afa18006bcd0")
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 an instance of its own class, ResBlock: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "in_channel": 3,
    "out_channel": 16,
    "down_sample": False,
    "up_sample": False,
}
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 ResBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ResBlock 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
UpSamplingBlock Ran
ran on a synthesized input · constructed an object; no result was computed
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("d03d80feddf16f36")
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 an instance of its own class, UpSamplingBlock: the run constructed the object and did not call it, so no result was computed. 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
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

class ResBlock(nn.Module):

    def __init__(self, in_channel, out_channel, down_sample=False, up_sample=False):
        super(ResBlock, self).__init__()
        main_module_list = []
        main_module_list += [nn.InstanceNorm2d(in_channel), nn.LeakyReLU(0.2), nn.Conv2d(in_channel, out_channel, kernel_size=3, stride=1, padding=1)]
        if down_sample:
            main_module_list.append(nn.AvgPool2d(kernel_size=2))
        elif up_sample:
            main_module_list.append(nn.Upsample(scale_factor=2, mode='bilinear'))
        main_module_list += [nn.InstanceNorm2d(out_channel), nn.LeakyReLU(0.2), nn.Conv2d(out_channel, out_channel, kernel_size=3, stride=1, padding=1)]
        self.main_path = nn.Sequential(*main_module_list)
        side_module_list = [nn.Conv2d(in_channel, out_channel, kernel_size=1, stride=1, padding=0)]
        if down_sample:
            side_module_list.append(nn.AvgPool2d(kernel_size=2))
        elif up_sample:
            side_module_list.append(nn.Upsample(scale_factor=2, mode='bilinear'))
        self.side_path = nn.Sequential(*side_module_list)

    def forward(self, x):
        x1 = self.main_path(x)
        x2 = self.side_path(x)
        return x1 + x2

class UpSamplingBlock(nn.Module):

    def __init__(self):
        super(UpSamplingBlock, self).__init__()
        self.net = nn.Sequential(ResBlock(256, 64, up_sample=True), ResBlock(64, 16, up_sample=True), ResBlock(16, 8), ResBlock(8, 4))

    def forward(self, x):
        x = self.net(x)
        m_r, i_r = (x[:, 0, ...].unsqueeze(1), x[:, 1:, ...])
        m_r = F.tanh(m_r)
        return (i_r, m_r)

# Create input tensor: batch_size=2, channels=256, height=4, width=3
input_tensor = torch.randn(2, 256, 4, 3)

# UpSamplingBlock takes no __init__ parameters
ARGS = {
}
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 UpSamplingBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a UpSamplingBlock 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
Generator Not yet run
unverified (harvested, no recorded run)
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("5b15de1bba9dd473")
How it ran

no invocation recorded.

SemanticFacialFusionModule Not yet run
unverified (harvested, no recorded run)
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("458264cd50748669")
How it ran

no invocation recorded.

ShapeAwareIdentityExtractor Not yet run
unverified (harvested, no recorded run)
mindslab-ai/hififace/model/hififace.py
code served (permissive licence) · get_code("4eda167c0bcfcbc5")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 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.

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

In this work, we propose a high fidelity face swapping method, called HifiFace, which can well preserve the face shape of the source face and generate photo-realistic results. Unlike other existing face swapping works that only use face recognition model to keep the identity similarity, we propose 3D shape-aware identity to control the face shape with the geometric supervision from 3DMM and 3D face reconstruction method. Meanwhile, we introduce the Semantic Facial Fusion module to optimize the combination of encoder and decoder features and make adaptive blending, which makes the results more photo-realistic. Extensive experiments on faces in the wild demonstrate that our method can preserve better identity, especially on the face shape, and can generate more photo-realistic results than previous state-of-the-art methods. Code is available at: https://johann.wang/HifiFace.

For agents

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

get_harvested_code_for_paper("2106.09965")
get_code_for_paper("2106.09965")
have("2106.09965")

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

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

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

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

Connect an agent — have() is free.