SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.16771 · 2024

ConsistentID: Portrait Generation with Multimodal Fine-Grained Identity Preserving

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 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, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 0 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.16771.json · badge: /api/ran/2404.16771.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
JackAILab/ConsistentID canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
collate_fn Ran
ran; our contract draft was wrong, not the code
JackAILab/ConsistentID/utils.py
code served (permissive licence) · get_code("7700d9baf7cadb6a")
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 dict. 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)

# Create a single example dictionary matching the expected structure
def create_example():
    return {
        'image': torch.randn(3, 32, 32),  # 3-channel image
        'multi_image': torch.randn(3, 32, 32),  # multi-resolution image
        'facial_clip_image': torch.randn(3, 32, 32),  # facial CLIP image
        'facial_mask': torch.randn(1, 32, 32),  # facial mask
        'clean_input_id': torch.tensor([[101, 2054, 2003, 102]]),  # 1D batch with token IDs
        'text_input_id_all': torch.tensor([[101, 2054, 2003, 102]]),  # 1D batch with token IDs
        'facial_token_mask': torch.tensor([[1, 1, 1, 0]]),  # token mask
        'facial_token_idx': torch.tensor([[0, 1, 2]]),  # token indices
        'facial_token_idx_mask': torch.tensor([[1, 1, 1]]),  # token index mask
        'text_prompt': "a person with facial features",  # text prompt
        'clip_image': torch.randn(1, 512),  # CLIP image embedding
        'multi_clip_image': torch.randn(1, 512),  # multi CLIP image embedding
        'face_id_embed': torch.randn(512),  # face ID embedding
        'drop_image_embed': torch.randn(512),  # drop image embedding
        'parsing_mask_list': [torch.randn(32, 32), torch.randn(32, 32)],  # list of parsing masks
        'key_parsing_mask_list': [torch.randn(32, 32)],  # list of key parsing masks
    }

# Create batch of examples
data = [create_example() for _ in range(2)]

ARGS = {
    'data': data
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
collate_fn Ran
ran; our contract draft was wrong, not the code
JackAILab/ConsistentID/utils_SDXL.py
code served (permissive licence) · get_code("74fd28b38b46a716")
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 dict. 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)

# Create a single example dict matching the structure expected by collate_fn
def create_example():
    return {
        'image': torch.randn(3, 4, 4),
        'multi_image': torch.randn(3, 4, 4),
        'facial_clip_image': torch.randn(3, 4, 4),
        'facial_mask': torch.randn(1, 4, 4),
        'clean_input_id': torch.randint(0, 1000, (5,)),
        'text_input_id_all': torch.randint(0, 1000, (6,)),
        'text_input_id_all2': torch.randint(0, 1000, (7,)),
        'image_token_idx': torch.randint(0, 100, (4,)),
        'image_token_idx_mask': torch.randint(0, 2, (4,)),
        'image_token_mask': torch.randint(0, 2, (8,)),
        'facial_token_mask': torch.randint(0, 2, (3,)),
        'facial_token_idx': torch.randint(0, 100, (3,)),
        'facial_token_idx_mask': torch.randint(0, 2, (3,)),
        'original_size': torch.tensor([256, 256]),
        'crop_coords_top_left': torch.tensor([0, 0]),
        'target_size': torch.tensor([512, 512]),
        'text_prompt': "a beautiful portrait",
        'text_origin': "user_input",
        'clip_image': torch.randn(1, 3, 224, 224),
        'multi_clip_image': torch.randn(1, 3, 224, 224),
        'face_id_embed': torch.randn(512),
        'drop_image_embed': False,
        'parsing_mask_list': [torch.randn(1, 64, 64), torch.randn(1, 64, 64)],
        'key_parsing_mask_list': [torch.randn(1, 32, 32)],
    }

# Create a batch of 2 examples
data = [create_example(), create_example()]

ARGS = {
    'data': data
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
extract_first_sentence Ran
ran; our contract draft was wrong, not the code
JackAILab/ConsistentID/functions.py
code served (permissive licence) · get_code("739002c9e7fea607")
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
import numpy as np

ARGS = {
    "text": "Hello world. This is a test. Another sentence here."
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
make_canny_condition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
JackAILab/ConsistentID/demo/controlnet_demo.py
code served (permissive licence) · get_code("aeaf1f5591e4a120")
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 Image. 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 numpy as np
import cv2
from PIL import Image

# Create a small test image as a numpy array
# Using a simple gradient pattern with shape (4, 3, 3) for height x width x channels
test_image = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# Convert to PIL Image
pil_image = Image.fromarray(test_image)

ARGS = {
    "image": pil_image
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, cv2, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
process_text_with_markers Ran
ran; our contract draft was wrong, not the code
JackAILab/ConsistentID/functions.py
code served (permissive licence) · get_code("2275194cbe185ddd")
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 re

def remove_duplicate_keywords(text, keywords):
    keyword_counts = {}
    words = re.findall('\\b\\w+\\b|[.,;!?]', text)
    for keyword in keywords:
        keyword_counts[keyword] = 0
        for i, word in enumerate(words):
            if word.lower() == keyword.lower():
                keyword_counts[keyword] += 1
                if keyword_counts[keyword] > 1:
                    words[i] = ''
    processed_text = ' '.join(words)
    return processed_text

def process_text_with_markers(text, parsing_mask_list):
    keywords = ['face', 'ears', 'eyes', 'nose', 'mouth']
    text = remove_duplicate_keywords(text, keywords)
    key_parsing_mask_markers = ['Face', 'Left_Ear', 'Right_Ear', 'Left_Eye', 'Right_Eye', 'Nose', 'Upper_Lip', 'Lower_Lip']
    mapping = {'Face': 'face', 'Left_Ear': 'ears', 'Right_Ear': 'ears', 'Left_Eye': 'eyes', 'Right_Eye': 'eyes', 'Nose': 'nose', 'Upper_Lip': 'mouth', 'Lower_Lip': 'mouth'}
    facial_features_align = []
    markers_align = []
    for key in key_parsing_mask_markers:
        if key in parsing_mask_list:
            mapped_key = mapping.get(key, key.lower())
            if mapped_key not in facial_features_align:
                facial_features_align.append(mapped_key)
                markers_align.append('<|' + mapped_key + '|>')
    text_marked = text
    align_parsing_mask_list = parsing_mask_list
    for feature, marker in zip(facial_features_align[::-1], markers_align[::-1]):
        pattern = f'\\b{feature}\\b'
        text_marked_new = re.sub(pattern, f'{feature} {marker}', text_marked, count=1)
        if text_marked == text_marked_new:
            for key, value in mapping.items():
                if value == feature:
                    if key in align_parsing_mask_list:
                        del align_parsing_mask_list[key]
        text_marked = text_marked_new
    text_marked = text_marked.replace('\n', '')
    ordered_text = []
    text_none_makers = []
    facial_marked_count = 0
    skip_count = 0
    for marker in markers_align:
        start_idx = text_marked.find(marker)
        end_idx = start_idx + len(marker)
        while start_idx > 0 and text_marked[start_idx - 1] not in [',', '.', ';']:
            start_idx -= 1
        while end_idx < len(text_marked) and text_marked[end_idx] not in [',', '.', ';']:
            end_idx += 1
        context = text_marked[start_idx:end_idx].strip()
        if context == '':
            text_none_makers.append(text_marked[:end_idx])
        elif skip_count != 0:
            skip_count -= 1
            continue
        else:
            ordered_text.append(context + ',')
            text_delete_makers = text_marked[:start_idx] + text_marked[end_idx:]
            text_marked = text_delete_makers
            facial_marked_count += 1
    align_marked_text = ' '.join(ordered_text)
    replace_list = ['<|face|>', '<|ears|>', '<|nose|>', '<|eyes|>', '<|mouth|>']
    for item in replace_list:
        align_marked_text = align_marked_text.replace(item, '<|facial|>')
    return (align_marked_text, align_parsing_mask_list)

ARGS = {
    "text": "The face has two eyes and a nose. The mouth is below the nose. The ears are on the sides.",
    "parsing_mask_list": ['Face', 'Left_Eye', 'Right_Eye', 'Nose']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
remove_duplicate_keywords Ran
ran; our contract draft was wrong, not the code
JackAILab/ConsistentID/functions.py
code served (permissive licence) · get_code("7221bdf0b3c21924")
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 re

def remove_duplicate_keywords(text, keywords):
    keyword_counts = {}
    words = re.findall('\\b\\w+\\b|[.,;!?]', text)
    for keyword in keywords:
        keyword_counts[keyword] = 0
        for i, word in enumerate(words):
            if word.lower() == keyword.lower():
                keyword_counts[keyword] += 1
                if keyword_counts[keyword] > 1:
                    words[i] = ''
    processed_text = ' '.join(words)
    return processed_text


ARGS = {
    "text": "The quick brown fox jumps over the lazy dog. The quick brown fox runs fast.",
    "keywords": ["the", "quick", "fox"]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 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 6 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-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

Diffusion-based technologies have made significant strides, particularly in personalized and customized facialgeneration. However, existing methods face challenges in achieving high-fidelity and detailed identity (ID)consistency, primarily due to insufficient fine-grained control over facial areas and the lack of a comprehensive strategy for ID preservation by fully considering intricate facial details and the overall face. To address these limitations, we introduce ConsistentID, an innovative method crafted for diverseidentity-preserving portrait generation under fine-grained multimodal facial prompts, utilizing only a single reference image. ConsistentID comprises two key components: a multimodal facial prompt generator that combines facial features, corresponding facial descriptions and the overall facial context to enhance precision in facial details, and an ID-preservation network optimized through the facial attention localization strategy, aimed at preserving ID consistency in facial regions. Together, these components significantly enhance the accuracy of ID preservation by introducing fine-grained multimodal ID information from facial regions. To facilitate training of ConsistentID, we present a fine-grained portrait dataset, FGID, with over 500,000 facial images, offering greater diversity and comprehensiveness than existing public facial datasets. % such as LAION-Face, CelebA, FFHQ, and SFHQ. Experimental results substantiate that our ConsistentID achieves exceptional precision and diversity in personalized facial generation, surpassing existing methods in the MyStyle dataset. Furthermore, while ConsistentID introduces more multimodal ID information, it maintains a fast inference speed during generation.

For agents

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

get_harvested_code_for_paper("2404.16771")
get_code_for_paper("2404.16771")
have("2404.16771")

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

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

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

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

Connect an agent — have() is free.