SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.10091 · ICCV · 2025

G 2 SF: Geometry-Guided Score Fusion for Multimodal Industrial Anomaly Detection

Chengyu Tao, Xuanming Cao, Juan Du

arXiv · PDF · Open in the Atlas

Code that ran

5 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; 2 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 6 no recorded run), measured 2026-11-22; 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.10091.json · badge: /api/ran/2503.10091.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
ctaoaa/G2SF community
Papers with Code archive
5 ran · 6 no recorded run
FunctionStatusWhere it lives
WDSADMarginLoss Ran
ran on a synthesized input
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("b292ef3ea5250431")
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 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 torch
import torch.nn.functional as F

class WDSADMarginLoss(torch.nn.Module):

    def __init__(self, c, margin, percentile=0.995, alpha=None, eta=1.0, eps=1e-05, reduction='mean'):
        super(WDSADMarginLoss, self).__init__()
        self.reduction = reduction
        self.c = c
        self.eta = eta
        self.eps = eps
        self.margin = margin
        if alpha is not None:
            self.is_weighted = True
            self.alpha = alpha
        else:
            self.is_weighted = False
        self.percentile = percentile

    def calculate_margin(self, dist, targets):
        bs = dist.shape[0]
        normal_dist = dist[targets == 1]
        scale = torch.quantile(normal_dist, self.percentile)
        normal_dist = normal_dist / scale
        anomaly_dist = dist[targets == -1] / scale
        a_bound = torch.min(anomaly_dist)
        n_bound = torch.quantile(normal_dist, self.percentile)
        margin_score0 = torch.sum(F.relu(normal_dist - a_bound))
        margin_score1 = torch.sum(F.relu(n_bound - anomaly_dist))
        return ((margin_score0 + margin_score1) / bs, n_bound, a_bound)

    def anomaly_score(self, rep):
        dist = torch.sum((rep - self.c) ** 2, dim=1)
        score = torch.sqrt(dist + 1e-08)
        return score

    def forward(self, rep, targets=None, is_weighted=True):
        dist = torch.sum((rep - self.c) ** 2, dim=1)
        na_margin, n_bound, a_bound = self.calculate_margin(dist, targets)
        if targets is not None:
            loss_normal = dist[targets == 1]
            loss_anomaly = F.relu(1 / (dist[targets == -1] + self.eps) - 1 / self.margin)
            if is_weighted:
                weight = dist ** self.alpha
                torch.clamp_(weight, max=3.0, min=0.33)
                weight_a = (1 / (dist + self.eps)) ** self.alpha
                torch.clamp_(weight_a, max=3.0, min=0.33)
                loss_normal = dist[targets == 1] * weight[targets == 1]
                loss_anomaly = F.relu(1 / (dist[targets == -1] + self.eps) - 1 / self.margin) * weight_a[targets == -1]
            loss = torch.cat([loss_normal, loss_anomaly], dim=0)
        else:
            loss = dist
        return (torch.mean(loss), na_margin)

    def forward_negative(self, rep):
        dist = torch.sum((rep - self.c) ** 2, dim=1)
        loss = F.relu(1 / (dist + self.eps) - 1 / self.margin)
        return torch.mean(loss)


INIT_ARGS = {
    'c': torch.randn(4),
    'margin': 0.5,
    'percentile': 0.995,
    'alpha': 0.5,
    'eta': 1.0,
    'eps': 1e-05,
    'reduction': 'mean'
}

ARGS = {
    'rep': torch.randn(6, 4),
    'targets': torch.tensor([1, 1, 1, -1, -1, -1]),
    'is_weighted': True
}

if __name__ == '__main__':
    loss_fn = WDSADMarginLoss(**INIT_ARGS)
    output = loss_fn(**ARGS)
    print("Output:", output)
    print("Loss value:", output[0])
    print("Margin score:", output[1])
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
get_dataloader Ran
ran; our contract draft was wrong, not the code
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("7c4de0bc86a2ecd7")
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 torch
import numpy as np
import tempfile
import os

torch.manual_seed(0)
np.random.seed(0)

# Create a temporary directory for the data files
temp_dir = tempfile.mkdtemp()

# Create synthetic data files
num_samples = 40
feature_dim = 4
idx2coreset_dim = 3

# Generate features
features = np.random.randn(num_samples, feature_dim).astype(np.float32)

# Generate masks (0 for normal, 1 for anomaly)
masks = np.random.randint(0, 2, size=num_samples).astype(np.int64)

# Generate scores
scores = np.random.rand(num_samples).astype(np.float32)

# Generate idx2coreset
idx2coreset = np.random.randint(0, idx2coreset_dim, size=num_samples).astype(np.int64)

# Save the data files
np.savez(os.path.join(temp_dir, 'patch_lib.npz'), feature=features)
np.save(os.path.join(temp_dir, 'per_label.npy'), masks)
np.save(os.path.join(temp_dir, 'score.npy'), scores)
np.save(os.path.join(temp_dir, 'idx2coreset.npy'), idx2coreset)

ARGS = {
    'path': temp_dir,
    'batch_size': 8,
    'test_batch_size': 8,
}
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 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
get_scale Ran
ran; our contract draft was wrong, not the code
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("dab20c12aac5426b")
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 (1, 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

torch.manual_seed(0)

# The function takes a single parameter 'scale' which should be a tensor
# It applies tanh, adds 1, multiplies by 0.5, reshapes to (1, 2), and normalizes
# So 'scale' should be a tensor that can be reshaped to (1, 2) after the operations

# Create a small tensor that will work with the function
scale_tensor = torch.randn(2)

ARGS = {
    "scale": scale_tensor
}
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 (1, 2) — shape (1, 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
l1_regularization Ran
ran, honoured the contract we drafted
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("16199d8c3e9c8b3a")
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 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

torch.manual_seed(0)

# Build a simple model with Linear layers
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 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
l2_regularization Ran
ran, honoured the contract we drafted
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("3857baec9affd767")
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 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

torch.manual_seed(0)

# Build a small model with Linear layers
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 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
FusionModelV2 Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("120da69785b147cc")
How it ran

no invocation recorded.

LinearBlock Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("49e18d07c7924b81")
How it ran

no invocation recorded.

MLPnet Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("cf61e747b2182da7")
How it ran

no invocation recorded.

MMScoringTrainer Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("44b75c572fb89506")
How it ran

no invocation recorded.

MultiModalGateNet Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("e89daa54904fb1fb")
How it ran

no invocation recorded.

get_sampler Not yet run
unverified (harvested, no recorded run)
ctaoaa/G2SF/G2SF_GITHUB/Fusion/fusion_engine_v2.py
code served (permissive licence) · get_code("163820e4f0bc74bd")
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 11 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 10 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
LinearBlock
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2305.16114 (2023-05)
Fascinating Supervisory Signals and Where to Find Them: Deep Anomaly Detection with Scale Learning

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

and anomalous patterns. Additionally, we develop specialized loss functions and score aggregation strategy from geometric priors to ensure both metric generalization and efficacy. Comprehensive evaluations on the MVTec-3D AD and Eyecandies datasets demonstrate the state-of-the-art detection performance of our method, and detailed ablation analysis validates each component's contribution. Our code is available at https://github.com/ctaoaa/G2SF.

For agents

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

get_harvested_code_for_paper("2503.10091")
get_code_for_paper("2503.10091")
have("2503.10091")

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

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

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

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

Connect an agent — have() is free.