SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.00908 · 2022

MemSeg: A semi-supervised method for image surface defect detection using differences and commonalities

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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 4 have no contract verdict; 1 failure of our instrument; 1 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/2205.00908.json · badge: /api/ran/2205.00908.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
TooTouch/MemSeg community (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
ntkhoa95/MemSeg-Defect-Detection community (classifier label)
classifier basis not recorded on the link
2 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_pro Ran
ran on a synthesized input
TooTouch/MemSeg/metrics/pro_curve_util.py
code served (permissive licence) · get_code("65ccd9c3a0376427")
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 2, 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

# Create small anomaly maps (2D numpy arrays with real-valued anomaly scores)
# Using distinct sizes: 4x3 for height x width
anomaly_map_1 = np.random.rand(4, 3).astype(np.float32)
anomaly_map_2 = np.random.rand(4, 3).astype(np.float32)
anomaly_maps = [anomaly_map_1, anomaly_map_2]

# Create corresponding ground truth maps (binary: 0 or 1)
ground_truth_map_1 = np.array([
    [0, 1, 0],
    [1, 1, 0],
    [0, 0, 1],
    [0, 1, 1]
], dtype=np.uint8)

ground_truth_map_2 = np.array([
    [1, 0, 1],
    [0, 0, 0],
    [1, 1, 0],
    [0, 0, 1]
], dtype=np.uint8)

ground_truth_maps = [ground_truth_map_1, ground_truth_map_2]

ARGS = {
    "anomaly_maps": anomaly_maps,
    "ground_truth_maps": ground_truth_maps,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, 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
generate_toy_dataset Ran
ran on a synthesized input
TooTouch/MemSeg/metrics/generic_util.py
code served (permissive licence) · get_code("92626665be140960")
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 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 numpy as np

ARGS = {
    "num_images": 3,
    "image_width": 64,
    "image_height": 48,
    "gt_size": 16,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 4, 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
minmax_scaling Ran
ran on a synthesized input
ntkhoa95/MemSeg-Defect-Detection/inference_cpu.py
code served (permissive licence) · get_code("1d82542315664ba0")
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 4, dtype family int, shape (2, 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 torch
import numpy as np

torch.manual_seed(0)

# The function minmax_scaling takes an image tensor and applies min-max normalization
# It expects:
# - img: a tensor with .min(), .max(), and .to() methods
# The function computes (img - img.min()) / (img.max() - img.min()) * 255
# and converts to uint8

# Create a small test image tensor with some variation in values
img = torch.rand(2, 4, 3, 3) * 100  # Random values between 0-100, shape: (2, 4, 3, 3)

ARGS = {
    "img": img
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy, 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 int, shape (2, 4, 3, 3) — shape (2, 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
parse_cfg Ran
ran on a synthesized input
ntkhoa95/MemSeg-Defect-Detection/conversion.py
code served (permissive licence) · get_code("7e4d7de3fdbdb1bc")
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 dict. 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 json
import tempfile
import os

# Create a temporary config file
temp_dir = tempfile.mkdtemp()
config_path = os.path.join(temp_dir, "test_config.json")

# Create a valid JSON config file
config_data = {
    "model": "test_model",
    "batch_size": 32,
    "learning_rate": 0.001,
    "epochs": 10,
    "layers": [64, 128, 256]
}

with open(config_path, 'w') as f:
    json.dump(config_data, f)

ARGS = {
    "path": config_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
trapezoid Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
TooTouch/MemSeg/metrics/generic_util.py
code served (permissive licence) · get_code("92db361050fcd08d")
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 float64, ndim 0, 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

# Create simple test data for trapezoid integration
x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
y = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])

ARGS = {
    'x': x,
    'y': y,
    'x_max': 3.5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
heatmap_on_image Not yet run
unverified (harvested, no recorded run)
ntkhoa95/MemSeg-Defect-Detection/inference_cpu.py
code served (permissive licence) · get_code("9321cc2548fee949")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 4 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 2 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
trapezoid 2 other papers
2 later
2303.14535 (2023-03)
EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies
2405.14529 (2024-05)
AnomalyDINO: Boosting Patch-based Few-shot Anomaly Detection with DINOv2
compute_pro 1 other paper
1 later
2303.14535 (2023-03)
EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies
generate_toy_dataset 1 other paper
1 later
2303.14535 (2023-03)
EfficientAD: Accurate Visual Anomaly Detection at Millisecond-Level Latencies
heatmap_on_image 1 other paper
1 dated earlier
2106.08265 (2021-06)
Towards Total Recall in Industrial Anomaly Detection

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

Under the semi-supervised framework, we propose an end-to-end memory-based segmentation network (MemSeg) to detect surface defects on industrial products. Considering the small intra-class variance of products in the same production line, from the perspective of differences and commonalities, MemSeg introduces artificially simulated abnormal samples and memory samples to assist the learning of the network. In the training phase, MemSeg explicitly learns the potential differences between normal and simulated abnormal images to obtain a robust classification hyperplane. At the same time, inspired by the mechanism of human memory, MemSeg uses a memory pool to store the general patterns of normal samples. By comparing the similarities and differences between input samples and memory samples in the memory pool to give effective guesses about abnormal regions; In the inference phase, MemSeg directly determines the abnormal regions of the input image in an end-to-end manner. Through experimental validation, MemSeg achieves the state-of-the-art (SOTA) performance on MVTec AD datasets with AUC scores of 99.56% and 98.84% at the image-level and pixel-level, respectively. In addition, MemSeg also has a significant advantage in inference speed benefiting from the end-to-end and straightforward network structure, which better meets the real-time requirement in industrial scenarios.

For agents

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

get_harvested_code_for_paper("2205.00908")
get_code_for_paper("2205.00908")
have("2205.00908")

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

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

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

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

Connect an agent — have() is free.