SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.17229 · CVPR · 2024

Preserving Fairness Generalization in Deepfake Detection

Shu Hu, Xin Wang, Li Lin, Xinan He, Yan Ju, Feng Ding

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 6 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/2402.17229.json · badge: /api/ran/2402.17229.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
purdue-m2/fairness-generalization canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
Purdue-M2/Fairness-Generalization community
Papers with Code archive
7 ran · 3 no recorded run
FunctionStatusWhere it lives
AdaIN Ran
ran on a synthesized input · constructed an object; no result was computed
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("7f3ff664d9863e70")
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, eps=1e-05):
        super().__init__()
        self.eps = eps

    def c_norm(self, x, bs, ch, eps=1e-07):
        x_var = x.var(dim=-1) + eps
        x_std = x_var.sqrt().view(bs, ch, 1, 1)
        x_mean = x.mean(dim=-1).view(bs, ch, 1, 1)
        return (x_std, x_mean)

    def forward(self, x, y):
        assert x.size(0) == y.size(0)
        size = x.size()
        bs, ch = size[:2]
        x_ = x.view(bs, ch, -1)
        y_ = y.reshape(bs, ch, -1)
        x_std, x_mean = self.c_norm(x_, bs, ch, eps=self.eps)
        y_std, y_mean = self.c_norm(y_, bs, ch, eps=self.eps)
        out = (x - x_mean.expand(size)) / x_std.expand(size) * y_std.expand(size) + y_mean.expand(size)
        return out


# Create small tensors for testing
# Batch size: 2, Channels: 4, Height: 3, Width: 3
x = torch.randn(2, 4, 3, 3)
y = torch.randn(2, 4, 3, 3)

ARGS = {
    'eps': 1e-05,
}
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
Conv2d1x1 Ran
ran on a synthesized input · constructed an object; no result was computed
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("72523daadda7aa6a")
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, Conv2d1x1: 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_f': 3,
    'hidden_dim': 8,
    'out_f': 16
}
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 Conv2d1x1 — 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 Conv2d1x1 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
Head Ran
ran on a synthesized input · constructed an object; no result was computed
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("a961635e87f5c559")
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, Head: 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)

# Head.__init__ parameters: in_f, hidden_dim, out_f
# Head.forward expects x to be a 4D tensor (batch, channels, height, width)
# because it uses AdaptiveAvgPool2d which expects 4D input

in_f = 16  # number of input channels
hidden_dim = 8  # hidden dimension for MLP
out_f = 4  # output features

# Create a sample input tensor for testing
# Shape: (batch_size, channels, height, width)
# batch_size=2, channels=16 (matches in_f), height=3, width=3
sample_input = torch.randn(2, in_f, 3, 3)

ARGS = {
    "in_f": in_f,
    "hidden_dim": hidden_dim,
    "out_f": out_f
}
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 Head — 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 Head 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
Registry Ran
ran on a synthesized input · constructed an object; no result was computed
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("f88683254210f95c")
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, Registry: 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 Registry(object):

    def __init__(self):
        self.data = {}

    def register_module(self, module_name=None):

        def _register(cls):
            name = module_name
            if module_name is None:
                name = cls.__name__
            self.data[name] = cls
            return cls
        return _register

    def __getitem__(self, key):
        return self.data[key]


# Setup code to construct valid arguments
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 Registry — 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 Registry 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
calculate_metrics_for_train Ran
ran; our contract draft was wrong, not the code
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("46cb3a5813949dd0")
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 tuple, 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
import numpy as np

torch.manual_seed(0)

# Create small tensors for testing
# label: shape (batch_size,) with binary class labels
label = torch.tensor([0, 1], dtype=torch.long)

# output: shape (batch_size, num_classes) with logits
# Using 2 classes for binary classification
output = torch.randn(2, 2, dtype=torch.float32)

ARGS = {
    "label": label,
    "output": output,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple 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
classification_metrics Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
purdue-m2/fairness-generalization/training/fairness_metrics.py
code served (permissive licence) · get_code("c987e7409c07b8d5")
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 tuple, 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 numpy as np

np.random.seed(0)

# Generate simple binary classification data
# label: binary labels (0 or 1)
# prediction: prediction scores between 0 and 1

label = np.array([0, 0, 1, 1, 0, 1, 1, 0])
prediction = np.array([0.1, 0.3, 0.8, 0.9, 0.2, 0.7, 0.85, 0.15])

ARGS = {
    "label": label,
    "prediction": prediction,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple 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
get_accracy Ran
ran; our contract draft was wrong, not the code
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("5eb46a5ee6daa359")
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 float, ndim 0, dtype family float, shape () 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

torch.manual_seed(0)

# Create a batch of 2 samples with 4 output classes
output = torch.randn(2, 4)

# Create corresponding labels (class indices 0-3)
label = torch.tensor([1, 3])

ARGS = {
    "output": output,
    "label": label
}
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 float, ndim 0, dtype family float, shape () — shape () 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
r_double_conv Ran
ran; our contract draft was wrong, not the code
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("9d6ab83ebd588047")
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 Sequential. 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_channels": 3,
    "out_channels": 16,
}
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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 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
sigmoid Ran
ran, honoured the contract we drafted
purdue-m2/fairness-generalization/training/fairness_metrics.py
code served (permissive licence) · get_code("396256bd807f90dc")
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 ndarray, 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 numpy as np

# The sigmoid function takes a single parameter: inputarray
# It applies the sigmoid operation: 1 / (1 + exp(-inputarray))
# The input should be a numpy array or array-like object

# Create a small numpy array for testing
inputarray = np.array([[-2.0, -1.0, 0.0, 1.0],
                       [2.0, 3.0, -0.5, 0.5]])

ARGS = {
    "inputarray": inputarray
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
softmax Ran
ran; our contract draft was wrong, not the code
purdue-m2/fairness-generalization/training/fairness_metrics.py
code served (permissive licence) · get_code("7937fb59ef6dda7d")
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 ndarray, 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 numpy as np

# Create a small input array for testing
# Using shape (2, 4) to keep it tiny but have distinct dimensions
input_array = np.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=np.float32)

# Set dim to 1 (softmax along the feature dimension)
dim = 1

ARGS = {
    "input_array": input_array,
    "dim": dim
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
swap_spe_features Ran
ran; our contract draft was wrong, not the code
purdue-m2/fairness-generalization/training/loss/contrastive_regularization.py
code served (permissive licence) · get_code("04fdd18bc3255f94")
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 (6, 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 random
from collections import defaultdict

torch.manual_seed(0)

# Create type_list as a torch tensor containing type indices
# The function calls .cpu().numpy().tolist() on it, so it must be a tensor
type_list = torch.tensor([0, 1, 0, 1, 2, 1], dtype=torch.long)

# Create value_list as a tensor that will be indexed and reordered
# Shape: (6, 4) - 6 values, each with 4 features
value_list = torch.randn(6, 4)

ARGS = {
    "type_list": type_list,
    "value_list": value_list,
}
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 (6, 4) — shape (6, 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
AbstractDetector Not yet run
unverified (harvested, no recorded run)
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("907c22bdf2a2c147")
How it ran

no invocation recorded.

Conditional_UNet Not yet run
unverified (harvested, no recorded run)
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("7f58b64ed9b32184")
How it ran

no invocation recorded.

FairDetector Not yet run
unverified (harvested, no recorded run)
Purdue-M2/Fairness-Generalization/training/detectors/fair_df_detector.py
code served (permissive licence) · get_code("16b3c26d9346c7bc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 13 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
sigmoid 1 other paper
1 dated earlier
2208.10451 (2022-08)
Minimax AUC Fairness: Efficient Algorithm with Provable Convergence

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

Although effective deepfake detection models have been developed in recent years, recent studies have revealed that these models can result in unfair performance disparities among demographic groups, such as race and gender. This can lead to particular groups facing unfair targeting or exclusion from detection, potentially allowing misclassified deepfakes to manipulate public opinion and undermine trust in the model. The existing method for addressing this problem is providing a fair loss function. It shows good fairness performance for intra-domain evaluation but does not maintain fairness for cross-domain testing. This highlights the significance of fairness generalization in the fight against deepfakes. In this work, we propose the first method to address the fairness generalization problem in deepfake detection by simultaneously considering features, loss, and optimization aspects. Our method employs disentanglement learning to extract demographic and domain-agnostic forgery features, fusing them to encourage fair learning across a flattened loss landscape. Extensive experiments on prominent deepfake datasets demonstrate our method's effectiveness, surpassing state-of-the-art approaches in preserving fairness during cross-domain deepfake detection. The code is available at https://github.com/Purdue-M2/Fairness-Generalization.

For agents

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

get_harvested_code_for_paper("2402.17229")
get_code_for_paper("2402.17229")
have("2402.17229")

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

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

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

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

Connect an agent — have() is free.