SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.08486 · 2024

Learning Flow Fields in Attention for Controllable Person Image Generation

arXiv · PDF · Open in the Atlas

Code that ran

5 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, 1 violated it and 0 have no contract verdict; 4 failures of our instrument; 1 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/2412.08486.json · badge: /api/ran/2412.08486.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
franciszzj/leffa canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
FunctionStatusWhere it lives
latent_to_image Ran
ran; our contract draft was wrong, not the code
franciszzj/leffa/leffa/pipeline.py
code served (permissive licence) · get_code("bdd78e110a9ba9e2")
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 4, 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
import torch.nn as nn
import numpy as np


torch.manual_seed(0)


class MockVAEConfig:
    def __init__(self):
        self.scaling_factor = 0.18215


class MockVAE(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MockVAEConfig()
    
    def decode(self, latent):
        # latent shape: (batch, channels, height, width)
        # output should have sample attribute with shape (batch, 3, height*8, width*8)
        batch_size = latent.shape[0]
        # Upsample: if latent is (2, 4, 2, 3), output (2, 3, 16, 24)
        output = torch.randn(batch_size, 3, 16, 24)
        
        class DecoderOutput:
            def __init__(self, sample):
                self.sample = sample
        
        return DecoderOutput(output)


# Create a small latent tensor: (batch=2, channels=4, height=2, width=3)
latent = torch.randn(2, 4, 2, 3)

# Create mock VAE
vae = MockVAE()

ARGS = {
    "latent": latent,
    "vae": vae,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 4, 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
numpy_to_pil Ran
ran, violated the contract we drafted
franciszzj/leffa/leffa/pipeline.py
code served (permissive licence) · get_code("de0de27c855054c4")
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 4, 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 numpy as np
from PIL import Image, ImageFilter

# Create a sample numpy array representing a batch of images
# The function expects images in shape (batch, height, width, channels)
# Values should be in range [0, 1] as they get multiplied by 255

# Test case 1: batch of RGB images (2 images, 4x3 pixels, 3 channels)
images_rgb = np.random.rand(2, 4, 3, 3).astype('float32')

ARGS = {
    "images": images_rgb
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 4, 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
pil_to_tensor Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
franciszzj/leffa/leffa/inference.py
code served (permissive licence) · get_code("13618485a328150e")
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 (3, 4, 3) 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
import torch

torch.manual_seed(0)

# Create a small stand-in PIL-like image
# The function expects something that can be converted to numpy array
# with shape (height, width, channels)
# We'll create a numpy array directly since PIL isn't available in this context
# and the function just converts it to numpy anyway
images = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

ARGS = {
    "images": images
}
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 Tensor, ndim 3, dtype family float, shape (3, 4, 3) — shape (3, 4, 3) 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
remove_cross_attention Ran
ran; our contract draft was wrong, not the code
franciszzj/leffa/leffa/model.py
code served (permissive licence) · get_code("ee6c62a5a094de2d")
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 ModuleList. 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 minimal UNet-like mock object that satisfies the function's usage
class MockAttention(nn.Module):
    def __init__(self, hidden_size=64, cross_attention_dim=None):
        super().__init__()
        self.heads = 4
        self.spatial_norm = None
        self.group_norm = None
        self.norm_cross = False
        self.norm_encoder_hidden_states = nn.Identity()
        self.to_q = nn.Linear(hidden_size, hidden_size)
        self.to_k = nn.Linear(cross_attention_dim or hidden_size, hidden_size)
        self.to_v = nn.Linear(cross_attention_dim or hidden_size, hidden_size)
        self.to_out = nn.ModuleList([
            nn.Linear(hidden_size, hidden_size),
            nn.Identity()
        ])
        self.residual_connection = False
        self.rescale_output_factor = 1.0
    
    def prepare_attention_mask(self, attention_mask, sequence_length, batch_size):
        return attention_mask

class MockUNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = type('Config', (), {
            'cross_attention_dim': 768,
            'block_out_channels': [128, 256, 512]
        })()
        
        # Create mock attention layers
        self.attn_procs_dict = {
            'down_blocks.0.attentions.0.attn1.processor': MockAttention(hidden_size=128),
            'down_blocks.0.attentions.0.attn2.processor': MockAttention(hidden_size=128, cross_attention_dim=768),
            'mid_block.attentions.0.attn1.processor': MockAttention(hidden_size=512),
            'mid_block.attentions.0.attn2.processor': MockAttention(hidden_size=512, cross_attention_dim=768),
            'up_blocks.0.attentions.0.attn1.processor': MockAttention(hidden_size=512),
            'up_blocks.0.attentions.0.attn2.processor': MockAttention(hidden_size=512, cross_attention_dim=768),
        }
    
    def attn_processors(self):
        return self.attn_procs_dict
    
    @property
    def attn_processors(self):
        return self.attn_procs_dict
    
    def set_attn_processor(self, procs):
        self.attn_procs_dict = procs

# Create minimal cross attention processor
class CustomSkipAttnProcessor(nn.Module):
    def __init__(self, hidden_size=None, cross_attention_dim=None, **kwargs):
        super().__init__()
    
    def __call__(self, attn, hidden_states, encoder_hidden_states=None, attention_mask=None, temb=None):
        return hidden_states

# Build ARGS
unet = MockUNet()

ARGS = {
    'unet': unet,
    'cross_attn_cls': CustomSkipAttnProcessor,
    'self_attn_cls': None,
    'cross_attn_dim': 768,
}
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 ModuleList — a ModuleList output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ModuleList 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
zero_module Ran
ran; our contract draft was wrong, not the code
franciszzj/leffa/leffa/diffusion_model/unet_gen.py
pointer only (licence: MIT); the stored copy get_code serves, from iguoyanjun/Memorize-When-Needed, is pointer only (licence: NONE) · get_code("d81381b327c76edd")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from iguoyanjun/Memorize-When-Needed, 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.

do_repaint Not yet run
unverified (harvested, no recorded run)
franciszzj/leffa/leffa/pipeline.py
code served (permissive licence) · get_code("cbb87fb554fc2eaf")
How it ran

no invocation recorded.

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, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 1 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
zero_module 40 other papers
30 dated earlier, 2 the same month, 6 later, 2 same year, order not determinable
2305.13077 (2023-05)
ControlVideo: Training-free Controllable Text-to-Video Generation
2305.17098 (2023-05)
ControlVideo: Conditional Control for One-shot Text-driven Video Editing and Beyond
2308.03448 (2023-08)
Make Explicit Calibration Implicit: Calibrate Denoiser Instead of the Noise Model
and 37 more not named here
numpy_to_pil 4 other papers
4 dated earlier
2210.09477 (2022-10)
UniTune: Text-Driven Image Editing by Fine Tuning a Diffusion Model on a Single Image
2307.11410 (2023-07)
Subject-Diffusion:Open Domain Personalized Text-to-Image Generation without Test-time Fine-tuning
2308.12038 (2023-08)
Large Multilingual Models Pivot Zero-Shot Multimodal Learning across Languages
and 1 more not named here
pil_to_tensor 1 other paper
1 dated earlier
2403.05139 (2024-03)
Improving Diffusion Models for Authentic Virtual Try-on in the Wild

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

Controllable person image generation aims to generate a person image conditioned on reference images, allowing precise control over the person's appearance or pose. However, prior methods often distort fine-grained textural details from the reference image, despite achieving high overall image quality. We attribute these distortions to inadequate attention to corresponding regions in the reference image. To address this, we thereby propose learning flow fields in attention (Leffa), which explicitly guides the target query to attend to the correct reference key in the attention layer during training. Specifically, it is realized via a regularization loss on top of the attention map within a diffusion-based baseline. Our extensive experiments show that Leffa achieves state-of-the-art performance in controlling appearance (virtual try-on) and pose (pose transfer), significantly reducing fine-grained detail distortion while maintaining high image quality. Additionally, we show that our loss is model-agnostic and can be used to improve the performance of other diffusion models.

For agents

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

get_harvested_code_for_paper("2412.08486")
get_code_for_paper("2412.08486")
have("2412.08486")

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

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

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

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

Connect an agent — have() is free.