SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.18286 · CVPR · 2025

CO-SPY: Combining Semantic and Pixel Features to Detect Synthetic Images by AI

Vikash Sehwag, Xiangyu Zhang, Siyuan Cheng, Zhenting Wang, Lingjuan Lyu :‹

arXiv · PDF · Open in the Atlas

Code that ran

7 of 13 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 1 has no contract verdict; 5 failures of our instrument; 6 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/2503.18286.json · badge: /api/ran/2503.18286.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
Megum1/Co-Spy community
Papers with Code archive
7 ran · 6 no recorded run
FunctionStatusWhere it lives
Bottleneck Ran
ran on a synthesized input
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("fc446cf956997c40")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, 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 torch
import torch.nn as nn

def conv1x1(in_planes, out_planes, stride=1):
    """1x1 convolution"""
    return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)

def conv3x3(in_planes, out_planes, stride=1):
    """3x3 convolution with padding"""
    return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)

class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, inplanes, planes, stride=1, downsample=None):
        super(Bottleneck, self).__init__()
        self.conv1 = conv1x1(inplanes, planes)
        self.bn1 = nn.BatchNorm2d(planes)
        self.conv2 = conv3x3(planes, planes, stride)
        self.bn2 = nn.BatchNorm2d(planes)
        self.conv3 = conv1x1(planes, planes * self.expansion)
        self.bn3 = nn.BatchNorm2d(planes * self.expansion)
        self.relu = nn.ReLU(inplace=True)
        self.downsample = downsample
        self.stride = stride

    def forward(self, x):
        identity = x
        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)
        out = self.conv2(out)
        out = self.bn2(out)
        out = self.relu(out)
        out = self.conv3(out)
        out = self.bn3(out)
        if self.downsample is not None:
            identity = self.downsample(x)
        out += identity
        out = self.relu(out)
        return out

inplanes = 8
planes = 4
stride = 1

downsample = nn.Sequential(
    conv1x1(inplanes, planes * Bottleneck.expansion, stride),
    nn.BatchNorm2d(planes * Bottleneck.expansion)
)

INIT_ARGS = {
    'inplanes': inplanes,
    'planes': planes,
    'stride': stride,
    'downsample': downsample
}

ARGS = {
    'x': torch.randn(2, 8, 7, 7)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
cv2_jpg Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("86961d87fd5fab69")
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 ndarray, ndim 3, dtype family int, shape (4, 3, 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 cv2
import numpy as np

# Create a valid image array in BGR format (as expected by cv2)
# Image shape: (height, width, channels) with values in uint8 range [0, 255]
img = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# Compression quality value (JPEG quality, typically 0-100)
compress_val = 80

ARGS = {
    'img': img,
    'compress_val': compress_val
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (4, 3, 3) — shape (4, 3, 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
data_augment Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("229442b36ab50a29")
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 random

# Set seed for reproducibility
random.seed(0)
np.random.seed(0)

# Create a small RGB image (height=32, width=24, channels=3)
# Using uint8 dtype as expected by cv2 and PIL
img = np.random.randint(0, 256, size=(32, 24, 3), dtype=np.uint8)

# Create augmentation config dict with all required keys
aug_config = {
    'blur_prob': 0.5,           # Probability of applying blur
    'blur_sig': [0.5, 2.0],     # Range for gaussian blur sigma
    'jpg_prob': 0.5,            # Probability of applying jpeg compression
    'jpg_method': ['cv2'],      # Method to use for jpeg compression
    'jpg_qual': [75],           # JPEG quality level
}

ARGS = {
    'img': img,
    'aug_config': aug_config,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, cv2, numpy, scipy — 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
jpeg_from_key Ran
ran; our contract draft was wrong, not the code
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("6754fc7cf147b2c3")
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) and returned ndarray, ndim 3, dtype family int, shape (4, 3, 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 cv2
import numpy as np
from io import BytesIO
from PIL import Image

# Create a small RGB image (height=4, width=3, channels=3)
# Using uint8 values in range [0, 255]
img = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# Compression quality value (1-100 for JPEG)
compress_val = 85

# Key to select the method ('cv2' or 'pil')
key = 'cv2'

ARGS = {
    'img': img,
    'compress_val': compress_val,
    'key': key
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 ndarray, ndim 3, dtype family int, shape (4, 3, 3) — shape (4, 3, 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
pil_jpg Ran
ran; our contract draft was wrong, not the code
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("a3254e6aff2ba505")
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) and returned ndarray, ndim 3, dtype family int, shape (4, 3, 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
from io import BytesIO
from PIL import Image

# Create a small test image as a numpy array
# The function expects a numpy array that can be converted to PIL Image
# Image dimensions: 4 height x 3 width x 3 channels (RGB)
test_img = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

ARGS = {
    'img': test_img,
    'compress_val': 85
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (4, 3, 3) — shape (4, 3, 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
sample_continuous Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("2d279d661251af46")
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) 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 random

def sample_continuous(s):
    if len(s) == 1:
        return s[0]
    if len(s) == 2:
        rg = s[1] - s[0]
        return random.random() * rg + s[0]
    raise ValueError('Length of iterable s should be 1 or 2.')

# Test case 1: single element
ARGS = {
    's': [5.0]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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
sample_discrete Ran
ran, violated the contract we drafted
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("d9f67916280ae1e3")
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) and returned int, ndim 0, dtype family int, 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 random

def sample_discrete(s):
    if len(s) == 1:
        return s[0]
    return random.choice(s)

# Test with a list of discrete values
ARGS = {
    "s": [1, 2, 3, 4, 5]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 int, ndim 0, dtype family int, 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
ArtifactDetector Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("03dc388e6cfd8b10")
How it ran

no invocation recorded.

BaseDetector Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("ea6444b2029dc4b3")
How it ran

no invocation recorded.

CoSpyFusionDetector Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("90c883f0b81276fe")
How it ran

no invocation recorded.

ResNet Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("4e663e8cbd8b097b")
How it ran

no invocation recorded.

SemanticDetector Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("604cf2ee5e85a6d0")
How it ran

no invocation recorded.

gaussian_blur Not yet run
unverified (harvested, no recorded run)
Megum1/Co-Spy/detectors/progan/fusion.py
code served (permissive licence) · get_code("e51a12966ba2acaa")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 2 the same month, 0 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
cv2_jpg
brick of this paper's assembly: helper
3 other papers
3 dated earlier
2008.04115 (2020-08)
T-GD: Transferable GAN-generated Images Detection Framework
2402.12927 (2024-02)
CLIPping the Deception: Adapting Vision-Language Models for Universal Deepfake Detection
2407.20337 (2024-07)
Contrasting Deepfakes Diffusion via Contrastive Learning and Global-Local Similarities
sample_continuous
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 the same month
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
2503.20188 (2025-03)
Rethinking Vision-Language Model in Face Forensics: Multi-Modal Interpretable Forged Face Detector
sample_discrete
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 the same month
2410.23623 (2024-10)
On Learning Multi-Modal Forgery Representation for Diffusion Generated Video Detection
2503.20188 (2025-03)
Rethinking Vision-Language Model in Face Forensics: Multi-Modal Interpretable Forged Face Detector
Bottleneck
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2106.05920 (2021-06)
Implicit Feature Alignment: Learn to Convert Text Recognizer to Text Spotter
pil_jpg
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2407.20337 (2024-07)
Contrasting Deepfakes Diffusion via Contrastive Learning and Global-Local Similarities

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

With the rapid advancement of generative AI, it is now possible to synthesize high-quality images in a few seconds. Despite the power of these technologies, they raise significant concerns regarding misuse. Current efforts to distinguish between real and AI-generated images may lack generalization, being effective for only certain types of generative models and susceptible to post-processing techniques like JPEG compression. To overcome these limitations, we propose a novel framework, CO-SPY, that first enhances existing semantic features (e.g., the number of fingers in a hand) and artifact features (e.g., pixel value differences), and then adaptively integrates them to achieve more general and robust synthetic image detection. Additionally, we create CO-SPYBENCH, a comprehensive dataset comprising 5 real image datasets and 22 state-of-the-art generative models, including the latest models like FLUX. We also collect 50k synthetic images in the wild from the Internet to enable evaluation in a more practical setting. Our extensive evaluations demonstrate that our detector outperforms existing methods under identical training conditions, achieving an average accuracy improvement of approximately 11% to 34%. The code is available at https://github.com/Megum1/Co-Spy.

For agents

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

get_harvested_code_for_paper("2503.18286")
get_code_for_paper("2503.18286")
have("2503.18286")

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

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

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

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

Connect an agent — have() is free.