SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.13788 · 2024

AnyPattern: Towards In-context Image Copy Detection

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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; 8 failures of our instrument; 3 no recorded run), measured 2026-11-24; 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.13788.json · badge: /api/ran/2404.13788.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
wangwenhao0716/anypattern canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
WangWenhao0716/AnyPatternStyle canonical (classifier label)
classifier basis: census
1 ran · 1 no recorded run
FunctionStatusWhere it lives
LogSumExp Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/loss/cosfacepairwise.py
code served (permissive licence) · get_code("1b5f7cd991a55738")
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 1, dtype family float, shape (2,) 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)

# Analyze the function:
# - score: tensor with .max(), .unsqueeze(), .expand_as(), indexing with [1], .exp(), .sum(), .log()
# - mask: tensor with same shape as score, used in arithmetic operations
# The function treats score as (batch_size, seq_len) based on max(1) operation

# Create small tensors: batch=2, seq_len=4
batch_size = 2
seq_len = 4

# score tensor: shape (batch_size, seq_len)
score = torch.randn(batch_size, seq_len)

# mask tensor: same shape as score, binary values (0 or 1)
# mask should indicate which positions are valid
mask = torch.ones(batch_size, seq_len)
# Set one position to 0 to test masking
mask[0, 2] = 0

ARGS = {
    "score": score,
    "mask": mask,
}
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 1, dtype family float, shape (2,) — shape (2,) 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
build_metric Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/models_gem_waveblock_balance_cos/metric.py
code served (permissive licence) · get_code("a00d813e0d8c2e34")
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 CircleLoss. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import math

torch.manual_seed(0)

# Define ARGS dict for build_metric function
ARGS = {
    'loss_type': 'circle',
    'in_dim': 4,
    'out_dim': 3,
    's': 64,
    'm': 0.35
}
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 CircleLoss — a CircleLoss output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a CircleLoss 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
cosine_dist Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/loss/triplet.py
code served (permissive licence) · get_code("97bcc985e3ddff46")
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 (2, 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 torch

torch.manual_seed(0)

# The function expects two tensors x and y
# It performs cosine distance computation
# x and y should be 2D tensors (batch_size, feature_dim)
# The function uses:
# - x.size(0), y.size(0) to get batch sizes
# - x.transpose(0, 1) to transpose y
# - torch.matmul for matrix multiplication
# - torch.sum, torch.pow, torch.sqrt for norm computation
# - view and repeat for reshaping and broadcasting

x = torch.randn(2, 4)  # batch_size=2, feature_dim=4
y = torch.randn(3, 4)  # batch_size=3, feature_dim=4

ARGS = {
    'x': x,
    'y': y,
}
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 (2, 3) — shape (2, 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
cosine_sim Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/layer.py
code served (permissive licence) · get_code("55b7eacdfa96a1c5")
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 (2, 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 torch

torch.manual_seed(0)

# Create two small tensors for cosine similarity computation
# x1: shape (2, 4) - 2 samples, 4 dimensions
# x2: shape (3, 4) - 3 samples, 4 dimensions
x1 = torch.randn(2, 4)
x2 = torch.randn(3, 4)

ARGS = {
    "x1": x1,
    "x2": x2,
    "dim": 1,
    "eps": 1e-08
}
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 (2, 3) — shape (2, 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
cosine_sim Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/models_gem_waveblock_balance_cos/metric.py
code served (permissive licence) · get_code("475146601a2a3bf5")
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 (2, 2) 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)

# Create small 2D tensors for cosine similarity computation
# x1: batch_size=2, embedding_dim=4
# x2: batch_size=2, embedding_dim=4
x1 = torch.randn(2, 4)
x2 = torch.randn(2, 4)

ARGS = {
    'x1': x1,
    'x2': x2,
    'dim': 1,
    'eps': 1e-08
}
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 (2, 2) — shape (2, 2) 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
euclidean_dist Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/loss/triplet.py
code served (permissive licence) · get_code("e54804982d1e6d22")
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 (2, 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 torch

torch.manual_seed(0)

# Create two small tensors with distinct shapes
# x: shape (2, 4) - 2 samples, 4 dimensions
# y: shape (3, 4) - 3 samples, 4 dimensions
x = torch.randn(2, 4)
y = torch.randn(3, 4)

ARGS = {
    'x': x,
    'y': y,
}
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 (2, 3) — shape (2, 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
pairwise_distance Ran
ran; our contract draft was wrong, not the code
wangwenhao0716/anypattern/Train/dg/evaluators.py
code served (permissive licence) · get_code("818a78a0677bf92a")
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 simple metric class that has a transform method
class SimpleMetric:
    def transform(self, x):
        # Simple transformation: just return the input
        return x

# Create feature dictionaries
features_dict = {
    'feat_0': torch.randn(4),
    'feat_1': torch.randn(4),
}

# Create query and gallery tuples (feature_id, label, camera_id)
query = [
    ('feat_0', 0, 0),
    ('feat_1', 1, 1),
]

gallery = [
    ('feat_0', 0, 0),
    ('feat_1', 1, 1),
]

# Create metric instance
metric = SimpleMetric()

# Test case 1: with query and gallery
ARGS = {
    'features': features_dict,
    'query': query,
    'gallery': gallery,
    'metric': metric
}
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
preprocessor Ran
ran; our contract draft was wrong, not the code
WangWenhao0716/AnyPatternStyle/anypattern_style_extractor.py
code served (permissive licence) · get_code("d2d8982282279307")
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, 224, 224) 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 torchvision
from PIL import Image
import numpy as np

torch.manual_seed(0)

# Create a small PIL Image object
# The preprocessor expects a PIL Image with a convert method and resize method
image_array = np.random.randint(0, 256, (224, 224, 3), dtype=np.uint8)
pil_image = Image.fromarray(image_array, mode='RGB')

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, numpy, torch, torchvision — 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, 224, 224) — shape (3, 224, 224) 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
create_model Not yet run
unverified (harvested, no recorded run)
WangWenhao0716/AnyPatternStyle/anypattern_style_extractor.py
code served (permissive licence) · get_code("59ed6bbf050d257e")
How it ran

no invocation recorded.

evaluate_all Not yet run
unverified (harvested, no recorded run)
wangwenhao0716/anypattern/Train/dg/evaluators.py
code served (permissive licence) · get_code("16698586b4001b08")
How it ran

no invocation recorded.

extract_features Not yet run
unverified (harvested, no recorded run)
wangwenhao0716/anypattern/Train/dg/evaluators.py
code served (permissive licence) · get_code("66e24510952a66e6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 1 the same month, 2 later) and 4 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
euclidean_dist 20 other papers
17 dated earlier, 2 the same month, 1 later · 4 only as an assembly brick
1902.09212 (2019-02)
Deep High-Resolution Representation Learning for Human Pose Estimation
1903.07071 (2019-03)
Bag of Tricks and A Strong Baseline for Deep Person Re-identification
1904.02998 (2019-04)
Relation-Aware Global Attention for Person Re-identification
and 17 more not named here
cosine_dist 4 other papers
3 dated earlier, 1 later
2001.01526 (2020-01)
Mutual Mean-Teaching: Pseudo Label Refinery for Unsupervised Domain Adaptation on Person Re-identification
2006.06525 (2020-06)
Attentive WaveBlock: Complementarity-enhanced Mutual Networks for Unsupervised Domain Adaptation in Person Re-identification and Beyond
aaai_19970 (2022 (year only))
SECRET: Self-Consistent Pseudo Label Refinement for Unsupervised Domain Adaptive Person Re-identification
and 1 more not named here
cosine_sim 2 other papers
2 dated earlier
1904.02882 (2019-04)
LibriTTS: A Corpus Derived from LibriSpeech for Text-to-Speech
aaai_26699 (2023 (year only))
MixFairFace: Towards Ultimate Fairness via MixFair Adapter in Face Recognition
evaluate_all 1 other paper
1 dated earlier
2006.06525 (2020-06)
Attentive WaveBlock: Complementarity-enhanced Mutual Networks for Unsupervised Domain Adaptation in Person Re-identification and Beyond
extract_features 1 other paper
1 dated earlier
2006.06525 (2020-06)
Attentive WaveBlock: Complementarity-enhanced Mutual Networks for Unsupervised Domain Adaptation in Person Re-identification and Beyond
pairwise_distance 1 other paper
1 dated earlier
2006.06525 (2020-06)
Attentive WaveBlock: Complementarity-enhanced Mutual Networks for Unsupervised Domain Adaptation in Person Re-identification and Beyond

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

Repositories linked to this paper

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

Abstract

This paper explores in-context learning for image copy detection (ICD), i.e., prompting an ICD model to identify replicated images with new tampering patterns without the need for additional training. The prompts (or the contexts) are from a small set of image-replica pairs that reflect the new patterns and are used at inference time. Such in-context ICD has good realistic value, because it requires no fine-tuning and thus facilitates fast reaction against the emergence of unseen patterns. To accommodate the "seen $\rightarrow$ unseen" generalization scenario, we construct the first large-scale pattern dataset named AnyPattern, which has the largest number of tamper patterns ($90$ for training and $10$ for testing) among all the existing ones. We benchmark AnyPattern with popular ICD methods and reveal that existing methods barely generalize to novel patterns. We further propose a simple in-context ICD method named ImageStacker. ImageStacker learns to select the most representative image-replica pairs and employs them as the pattern prompts in a stacking manner (rather than the popular concatenation manner). Experimental results show (1) training with our large-scale dataset substantially benefits pattern generalization ($+26.66 \%$ $μAP$), (2) the proposed ImageStacker facilitates effective in-context ICD (another round of $+16.75 \%$ $μAP$), and (3) AnyPattern enables in-context ICD, i.e., without such a large-scale dataset, in-context learning does not emerge even with our ImageStacker. Beyond the ICD task, we also demonstrate how AnyPattern can benefit artists, i.e., the pattern retrieval method trained on AnyPattern can be generalized to identify style mimicry by text-to-image models. The project is publicly available at https://anypattern.github.io.

For agents

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

get_harvested_code_for_paper("2404.13788")
get_code_for_paper("2404.13788")
have("2404.13788")

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

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

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

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

Connect an agent — have() is free.