SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.17465 · CVPR · 2024

LaRE 2 : Latent Reconstruction Error Based Method for Diffusion-Generated Image Detection

Ke Yan, Junlong Du, Yunpeng Luo

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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; 3 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/2403.17465.json · badge: /api/ran/2403.17465.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
luo3300612/lare canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
FunctionStatusWhere it lives
conv3x3 Ran
ran; our contract draft was wrong, not the code
luo3300612/lare/model_base.py
code served (permissive licence) · get_code("6978f1d410660f53")
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 Conv2d. 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    "in_channels": 3,
    "out_channels": 16,
    "stride": 1,
}
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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
search_best_acc Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
luo3300612/lare/train_classifier_wmap.py
code served (permissive licence) · get_code("054aa6966bc007ec")
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

# Analyze the function:
# - gt_labels: ground truth labels, used with accuracy_score (expects array-like)
# - pred_probs: prediction probabilities, used with .tolist(), np.array(), and indexing
#   The function iterates through sorted values and thresholds against them
#   It needs to be a numpy array or convertible to one

# Create small test data
np.random.seed(0)

# Ground truth labels (binary classification): 0s and 1s
gt_labels = np.array([0, 1, 0, 1, 1, 0])

# Prediction probabilities: float values between 0 and 1
pred_probs = np.array([0.1, 0.8, 0.3, 0.9, 0.7, 0.2])

ARGS = {
    "gt_labels": gt_labels,
    "pred_probs": pred_probs,
}
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
split_list Ran
ran; our contract draft was wrong, not the code
luo3300612/lare/extract_lare.py
code served (permissive licence) · get_code("b75e320bbdef33fa")
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. 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)

# The function split_list takes a list and an integer n
# It splits the list into n sublists by taking every n-th element starting from index i
# So we need:
# - lst: a list of any elements
# - n: an integer greater than 0

lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
n = 3

ARGS = {
    "lst": lst,
    "n": n
}
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 — a list 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
train_one_epoch Ran
ran, honoured the contract we drafted
luo3300612/lare/train_classifier_wmap.py
code served (permissive licence) · get_code("0648e3b3ea1471b7")
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
import torch.nn as nn
from torch.optim import SGD
from unittest.mock import Mock

torch.manual_seed(0)

# Build a minimal model that accepts images and loss_maps
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, images, loss_maps):
        # images shape: (batch, 4)
        # loss_maps: not used in forward, just accepted
        batch_size = images.shape[0]
        return self.linear(images)

# Build a minimal loss meter
class LossMeter:
    def __init__(self):
        self.avg = 0.0
        self.count = 0
        self.sum = 0.0
    
    def reset(self):
        self.avg = 0.0
        self.count = 0
        self.sum = 0.0
    
    def update(self, val, n):
        self.sum += val * n
        self.count += n
        self.avg = self.sum / self.count if self.count > 0 else 0.0

# Build a minimal writer
class MinimalWriter:
    def add_scalar(self, tag, value, step):
        pass

# Build data loader as list of batches
data_loader = [
    (torch.randn(2, 4), torch.randint(0, 2, (2,)), torch.randn(2, 4))
    for _ in range(100)
]

# Build model
model = MinimalModel()

# Build optimizer
optimizer = SGD(model.parameters(), lr=0.01)

# Build args
args = Mock()
args.criterion_ce = nn.CrossEntropyLoss()
args.multiprocessing_distributed = False
args.rank = 0
args.break_onek = False

ARGS = {
    'data_loader': data_loader,
    'model': model,
    'optimizer': optimizer,
    'cur_epoch': 1,
    'loss_meter': LossMeter(),
    'args': args,
    'device': torch.device('cpu'),
    'writer': MinimalWriter(),
    'ngpus_per_node': 1,
}
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
encode_image Not yet run
unverified (harvested, no recorded run)
luo3300612/lare/model.py
code served (permissive licence) · get_code("b59cbe843294ab85")
How it ran

no invocation recorded.

forward Not yet run
unverified (harvested, no recorded run)
luo3300612/lare/model.py
code served (permissive licence) · get_code("0923387a70ab89fc")
How it ran

no invocation recorded.

validation_contrastive Not yet run
unverified (harvested, no recorded run)
luo3300612/lare/train_classifier_wmap.py
code served (permissive licence) · get_code("de38f1d62d33eabc")
How it ran

no invocation recorded.

Also present in other papers' code

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

FunctionAlso present inEarliest-datedOthers named
conv3x3 15 other papers
12 dated earlier, 1 the same month, 2 later
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
1805.04635 (2018-05)
Direction-aware Spatial Context Features for Shadow Detection and Removal
1807.01697 (2018-07)
Benchmarking Neural Network Robustness to Common Corruptions and Surface Variations
and 12 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-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

The evolution of Diffusion Models has dramatically improved image generation quality, making it increasingly difficult to differentiate between real and generated images. This development, while impressive, also raises significant privacy and security concerns. In response to this, we propose a novel Latent REconstruction error guided feature REfinement method (LaRE 2 ) for detecting the diffusiongenerated images. We come up with the Latent Reconstruction Error (LaRE), the first reconstruction-error based feature in the latent space for generated image detection. LaRE surpasses existing methods in terms of feature extraction efficiency while preserving crucial cues required to differentiate between the real and the fake. To exploit LaRE, we propose an Error-Guided feature REfinement module (EGRE), which can refine the image feature guided by LaRE to enhance the discriminativeness of the feature. Our EGRE utilizes an align-then-refine mechanism, which effectively refines the image feature for generated-image detection from both spatial and channel perspectives. Extensive experiments on the large-scale GenImage benchmark demonstrate the superiority of our LaRE 2 , which surpasses the best SoTA method by up to 11.9%/12.1% average ACC/AP across 8 different image generators. LaRE also surpasses existing methods in terms of feature extraction cost, delivering an impressive speed enhancement of 8 times.

For agents

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

get_harvested_code_for_paper("2403.17465")
get_code_for_paper("2403.17465")
have("2403.17465")

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

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

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

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

Connect an agent — have() is free.