SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.14061 · ICCV · 2023

Hierarchical Contrastive Learning for Pattern-Generalizable Image Corruption Detection

Wenjie Pei, Yifeng Xu, Guangming Lu, Xin Feng

arXiv · PDF · Open in the Atlas

Code that ran

5 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; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 4 failures of our instrument; 2 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/2308.14061.json · badge: /api/ran/2308.14061.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
xyfJASON/HCL community
Papers with Code archive
5 ran · 2 no recorded run
FunctionStatusWhere it lives
SimplifiedCircleLoss Ran
ran on a synthesized input
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("dcd8e72c547e1b3c")
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 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 import Tensor

class SimplifiedCircleLoss(nn.Module):

    def __init__(self, reduction: str='mean'):
        super().__init__()
        assert reduction in ['mean', 'sum', 'none']
        self.reduction = reduction

    def forward(self, pred: Tensor, target: Tensor):
        """
        Args:
            pred (Tensor): [..., C]
            target (Tensor): [..., C], 1 pos, -1 neg, 0 not care
        """
        assert ((target == 0) | (target == 1) | (target == -1)).all()
        assert pred.shape == target.shape
        logits = -target * pred
        BigNegNum = torch.tensor(-1000000000000.0, device=pred.device)
        logits_neg = torch.where(target != -1, BigNegNum, logits)
        logits_pos = torch.where(target != 1, BigNegNum, logits)
        lse_neg = torch.logsumexp(logits_neg, dim=-1, keepdim=True)
        lse_pos = torch.logsumexp(logits_pos, dim=-1, keepdim=True)
        lse = lse_neg + lse_pos
        loss = torch.logsumexp(torch.cat([lse, torch.zeros_like(lse)], dim=-1), dim=-1)
        if self.reduction == 'mean':
            return torch.mean(loss)
        elif self.reduction == 'sum':
            return torch.sum(loss)
        elif self.reduction == 'none':
            return loss
        else:
            raise ValueError


INIT_ARGS = {
    'reduction': 'mean'
}

ARGS = {
    'pred': torch.randn(2, 4),
    'target': torch.tensor([[1.0, -1.0, 0.0, 1.0],
                            [-1.0, 1.0, 1.0, 0.0]])
}

if __name__ == '__main__':
    loss_fn = SimplifiedCircleLoss(**INIT_ARGS)
    output = loss_fn(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output value: {output}")
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
extract_edge Ran
ran; our contract draft was wrong, not the code
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("82879ddae683806c")
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 Tensor, ndim 4, dtype family float, shape (2, 1, 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 torch
from torch import Tensor

torch.manual_seed(0)

# Create a small binary image tensor
# The function accepts either [bs, 1, H, W] or [1, H, W]
# Let's create a [bs, 1, H, W] format with batch size 2, height 4, width 3
X = torch.randint(0, 2, (2, 1, 4, 3)).float()

ARGS = {
    "X": X
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, shape (2, 1, 4, 3) — shape (2, 1, 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
mask_indexing Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("89ac064542ac97c6")
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 Tensor, ndim 2, dtype family float, shape (15, 4) 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.functional as F

torch.manual_seed(0)

# Create test tensors
# X: [C, H, W] - feature tensor with C channels, H height, W width
C, H, W = 4, 5, 6
X = torch.randn(C, H, W)

# mask: [1, H, W], dtype=bool - boolean mask
mask = torch.randint(0, 2, (1, H, W)).bool()

# conf: [1, H, W] - confidence scores for hard mining
conf = torch.rand(1, H, W)

# Test case 1: hard_mining=False (basic case)
ARGS = {
    "X": X,
    "mask": mask,
    "hard_mining": False,
    "conf": None
}

# Verify the function can be called
# result = mask_indexing(**ARGS)
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 (15, 4) — shape (15, 4) 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
mask_prop Ran
ran; our contract draft was wrong, not the code
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("107b48411f4eb749")
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 Tensor, ndim 4, dtype family float, shape (2, 4, 4, 4) 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 a valid mask tensor
# Shape: (B, C, H, W) where H and W are divisible by patch_size
# mask values must be 0 or 1
B, C, H, W = 2, 4, 8, 8
mask = torch.randint(0, 2, (B, C, H, W), dtype=torch.float32)

# patch_size must divide H and W evenly
patch_size = 2

ARGS = {
    "mask": mask,
    "patch_size": patch_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, shape (2, 4, 4, 4) — shape (2, 4, 4, 4) 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
upsample2x Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("8daa018a7aa5dc7c")
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 Tensor, ndim 4, dtype family float, shape (2, 4, 6, 10) 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 a small tensor with shape (B, C, H, W)
# B=2 (batch), C=4 (channels), H=3 (height), W=5 (width)
X = torch.randn(2, 4, 3, 5)

ARGS = {
    "X": X
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, shape (2, 4, 6, 10) — shape (2, 4, 6, 10) 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
ContrastLoss Not yet run
unverified (harvested, no recorded run)
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("65e00f77bc64095e")
How it ran

no invocation recorded.

HierarchicalContrastiveLoss Not yet run
unverified (harvested, no recorded run)
xyfJASON/HCL/losses/contrast_loss.py
code served (permissive licence) · get_code("1ddd55ad4fbf37d1")
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, 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 7 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

by learning the contrastive distinctions rather than the semantic patterns of corruptions, our model has well generalization ability across different corruption patterns. Extensive experiments demonstrate following merits of our model: 1) the superior performance over other methods on both corruption detection and various image restoration tasks including blind inpainting and watermark removal, and 2) strong generalization across different corruption patterns such as graffiti, random noise or other image content. Codes and trained weights are available at https://github.com/xyfJASON/HCL.

For agents

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

get_harvested_code_for_paper("2308.14061")
get_code_for_paper("2308.14061")
have("2308.14061")

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

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

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

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

Connect an agent — have() is free.