SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.15677 · 2024

CharacterFactory: Sampling Consistent Characters with GANs for Diffusion Models

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2404.15677.json · badge: /api/ran/2404.15677.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
qinghew/CharacterFactory canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
add_noise_return_paras Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/utils.py
code served (permissive licence) · get_code("93719d1ffaad162b")
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. 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 a mock self object with alphas_cumprod attribute
class MockScheduler:
    def __init__(self):
        # Create a small cumulative product schedule (100 timesteps)
        self.alphas_cumprod = torch.linspace(0.9999, 0.0001, 100)

mock_scheduler = MockScheduler()

# Create small tensors for the function arguments
batch_size = 2
num_channels = 4
height = 3
width = 3

original_samples = torch.randn(batch_size, num_channels, height, width, dtype=torch.float32)
noise = torch.randn(batch_size, num_channels, height, width, dtype=torch.float32)
timesteps = torch.tensor([10, 50], dtype=torch.int64)

ARGS = {
    "self": mock_scheduler,
    "original_samples": original_samples,
    "noise": noise,
    "timesteps": timesteps,
}
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 tuple — a tuple output has no array shape of its own; none is 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
discriminator_r1_loss_accelerator Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/utils.py
code served (permissive licence) · get_code("0738f543a73a1096")
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 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
import torch.nn as nn
from unittest.mock import Mock

torch.manual_seed(0)

# Create a mock accelerator object
# The function calls accelerate.gradient(), so we need to mock that behavior
class MockAccelerator:
    pass

accelerator = MockAccelerator()

# Create a small tensor for real_w that requires grad
# Shape: (2, 4) - batch size 2, feature dimension 4
real_w = torch.randn(2, 4, requires_grad=True)

# Create a small tensor for real_pred
# This will be used in real_pred.sum() and needs to have a gradient flow back through real_w
# We'll make it depend on real_w so gradients can flow
real_pred = (real_w ** 2).sum(dim=1, keepdim=True)

# We need to mock accelerate.gradient since it's not a standard PyTorch function
# It appears to be a custom function from the accelerate library
# We'll patch it to compute gradients manually
def mock_gradient(outputs, inputs, create_graph=True):
    grads = torch.autograd.grad(
        outputs=outputs,
        inputs=inputs,
        create_graph=create_graph,
        retain_graph=True
    )
    return grads

import accelerate
accelerate.gradient = mock_gradient

ARGS = {
    "accelerator": accelerator,
    "real_pred": real_pred,
    "real_w": real_w,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
accelerate, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, 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
embedding_forward Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/models/celeb_embeddings.py
code served (permissive licence) · get_code("30c989755522dca7")
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. 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)

# Build minimal self object with required attributes and methods
class MinimalEmbedding(nn.Module):
    def __init__(self):
        super().__init__()
        self.token_embedding = nn.Embedding(num_embeddings=10, embedding_dim=4)
        self.position_embedding = nn.Embedding(num_embeddings=8, embedding_dim=4)
        self.register_buffer('position_ids', torch.arange(8).unsqueeze(0))
    
    def forward(self, input_ids=None, position_ids=None, name_batch=None, 
                inputs_embeds=None, embedding_manager=None, only_embedding=True, 
                random_embeddings=None, timesteps=None):
        return embedding_forward(self, input_ids, position_ids, name_batch, 
                                inputs_embeds, embedding_manager, only_embedding, 
                                random_embeddings, timesteps)

def embedding_forward(self, input_ids=None, position_ids=None, name_batch=None, inputs_embeds=None, embedding_manager=None, only_embedding=True, random_embeddings=None, timesteps=None) -> torch.Tensor:
    seq_length = input_ids.shape[-1] if input_ids is not None else inputs_embeds.shape[-2]
    if inputs_embeds is None:
        inputs_embeds = self.token_embedding(input_ids)
        if only_embedding:
            return inputs_embeds
    if embedding_manager is not None:
        inputs_embeds, other_return_dict = embedding_manager(input_ids, inputs_embeds, name_batch, random_embeddings, timesteps)
    if position_ids is None:
        position_ids = self.position_ids[:, :seq_length]
    position_embeddings = self.position_embedding(position_ids)
    embeddings = inputs_embeds + position_embeddings
    return (embeddings, other_return_dict)

# Build embedding_manager callable
class EmbeddingManager(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, input_ids, inputs_embeds, name_batch, random_embeddings, timesteps):
        other_return_dict = {"managed": True}
        return inputs_embeds, other_return_dict

# Create instances
self_module = MinimalEmbedding()
embedding_manager = EmbeddingManager()

# Create valid arguments
input_ids = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.long)  # batch_size=2, seq_len=3
position_ids = None
name_batch = "test_batch"
inputs_embeds = None
random_embeddings = torch.randn(2, 3, 4)
timesteps = torch.tensor([0, 1])

ARGS = {
    'self': self_module,
    'input_ids': input_ids,
    'position_ids': position_ids,
    'name_batch': name_batch,
    'inputs_embeds': inputs_embeds,
    'embedding_manager': embedding_manager,
    'only_embedding': False,
    'random_embeddings': random_embeddings,
    'timesteps': timesteps
}
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 tuple — a tuple output has no array shape of its own; none is 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
get_clip_token_for_string Ran
ran, honoured the contract we drafted
qinghew/CharacterFactory/models/embedding_manager.py
code served (permissive licence) · get_code("2340eb21cf6c4ce5")
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 int, shape (1, 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
from transformers import CLIPTokenizer

torch.manual_seed(0)

# Create a minimal tokenizer stand-in that mimics CLIPTokenizer behavior
class MockCLIPTokenizer:
    def __call__(self, string, return_length=False, padding=False, truncation=False, 
                 return_overflowing_tokens=False, return_tensors=None):
        # Simple mock: create token ids based on string length
        # Return a dict with 'input_ids' key containing a tensor
        tokens = torch.tensor([[101, 2054, 2003, 102]], dtype=torch.long)  # batch_size=1, seq_len=4
        
        result = {'input_ids': tokens}
        if return_length:
            result['length'] = torch.tensor([4])
        
        return result

# Create instances for the function arguments
tokenizer = MockCLIPTokenizer()
string = "a photo of a dog"

ARGS = {
    'tokenizer': tokenizer,
    'string': string
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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 int, shape (1, 4) — shape (1, 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
get_embedding_for_clip_token Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/models/embedding_manager.py
code served (permissive licence) · get_code("185e8742c689f316")
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 3, dtype family float, shape (1, 1, 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)

class MockEmbedder(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(num_embeddings=10, embedding_dim=4)
    
    def forward(self, token_ids):
        return self.embedding(token_ids)

embedder = MockEmbedder()
token = torch.tensor([5], dtype=torch.long)

ARGS = {
    "embedder": embedder,
    "token": token
}
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 3, dtype family float, shape (1, 1, 4) — shape (1, 1, 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
get_rep_pos Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/models/id_embedding/helpers.py
code served (permissive licence) · get_code("fd9206b7174f95ba")
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 2, dtype family int; 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

torch.manual_seed(0)

# Create a small tokenized tensor
# Shape: (2, 4) - batch size 2, sequence length 4
tokenized = torch.tensor([
    [1, 2, 3, 4],
    [2, 3, 1, 5]
], dtype=torch.long)

# Create a list of tokens to find positions for
rep_tokens = [1, 2, 3]

ARGS = {
    "tokenized": tokenized,
    "rep_tokens": rep_tokens
}
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 2, dtype family int — 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
leaky_relu Ran
ran; our contract draft was wrong, not the code
qinghew/CharacterFactory/models/id_embedding/meta_net.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from lxa9867/imagefolder, is pointer only (licence: NOASSERTION) · get_code("c8ec5333f4bcb71f")
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 lxa9867/imagefolder, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

discriminator_r1_loss Not yet run
unverified (harvested, no recorded run)
qinghew/CharacterFactory/utils.py
code served (permissive licence) · get_code("c451f8fed3a37a6f")
How it ran

no invocation recorded.

shift_tensor_dim0 Not yet run
unverified (harvested, no recorded run)
qinghew/CharacterFactory/models/id_embedding/helpers.py
code served (permissive licence) · get_code("109f33b49ebd4274")
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, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 8 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
leaky_relu 4 other papers
2 dated earlier, 2 later
2011.10039 (2020-11)
Creative Sketch Generation
2401.09386 (2024-01)
Tri 2 -plane: Thinking Head Avatar via Feature Pyramid
2410.01756 (2024-10)
ImageFolder: Autoregressive Image Generation with Folded Tokens
and 1 more not named here

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-23.

Repositories linked to this paper

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

Abstract

Recent advances in text-to-image models have opened new frontiers in human-centric generation. However, these models cannot be directly employed to generate images with consistent newly coined identities. In this work, we propose CharacterFactory, a framework that allows sampling new characters with consistent identities in the latent space of GANs for diffusion models. More specifically, we consider the word embeddings of celeb names as ground truths for the identity-consistent generation task and train a GAN model to learn the mapping from a latent space to the celeb embedding space. In addition, we design a context-consistent loss to ensure that the generated identity embeddings can produce identity-consistent images in various contexts. Remarkably, the whole model only takes 10 minutes for training, and can sample infinite characters end-to-end during inference. Extensive experiments demonstrate excellent performance of the proposed CharacterFactory on character creation in terms of identity consistency and editability. Furthermore, the generated characters can be seamlessly combined with the off-the-shelf image/video/3D diffusion models. We believe that the proposed CharacterFactory is an important step for identity-consistent character generation. Project page is available at: https://qinghew.github.io/CharacterFactory/.

For agents

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

get_harvested_code_for_paper("2404.15677")
get_code_for_paper("2404.15677")
have("2404.15677")

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

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

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

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

Connect an agent — have() is free.