SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.12571 · 2021

CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows

arXiv · PDF · Open in the Atlas

Code that ran

11 of 12 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 7 have no contract verdict; 2 failures 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/2107.12571.json · badge: /api/ran/2107.12571.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
gudovskiy/cflow-ad canonical (classifier label)
classifier basis: census
11 ran · 1 no recorded run
FunctionStatusWhere it lives
conv1x1 Ran
ran; our contract draft was wrong, not the code
gudovskiy/cflow-ad/custom_models/resnet.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from medaitech/scrd4ad, is pointer only (licence: NONE) · get_code("2a80220dabcb742a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from medaitech/scrd4ad, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

conv3x3 Ran
ran on a synthesized input
gudovskiy/cflow-ad/custom_models/resnet.py
code served (permissive licence) · get_code("436bb4b1f6464d1b")
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 Conv2d. 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)

PADDING_MODE = 'reflect'

def conv3x3(in_planes: int, out_planes: int, stride: int=1, groups: int=1, dilation: int=1) -> nn.Conv2d:
    """3x3 convolution with padding"""
    return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=dilation, padding_mode=PADDING_MODE, groups=groups, bias=False, dilation=dilation)

ARGS = {
    'in_planes': 3,
    'out_planes': 64,
    'stride': 1,
    'groups': 1,
    'dilation': 1,
}
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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
denormalization Ran
ran on a synthesized input
gudovskiy/cflow-ad/visualize.py
code served (permissive licence) · get_code("d731362a1a10fe78")
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, 5, 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

# Construct arguments for denormalization function
# The function expects:
# - x: a numpy array with shape (height, width, channels) after transpose, 
#      so input should be (channels, height, width)
# - norm_mean: list or array of mean values for each channel
# - norm_std: list or array of std values for each channel

# Create a small normalized image array with shape (3, 4, 5) = (channels, height, width)
# Values normalized to roughly [-1, 1] range (typical for normalized images)
x = np.random.randn(3, 4, 5).astype(np.float32) * 0.5

# Mean values for 3 channels (typical ImageNet-like normalization)
norm_mean = [0.485, 0.456, 0.406]

# Std values for 3 channels (typical ImageNet-like normalization)
norm_std = [0.229, 0.224, 0.225]

ARGS = {
    "x": x,
    "norm_mean": norm_mean,
    "norm_std": norm_std
}
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 ndarray, ndim 3, dtype family int, shape (4, 5, 3) — shape (4, 5, 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
get_logp Ran
ran on a synthesized input
gudovskiy/cflow-ad/utils.py
code served (permissive licence) · get_code("2ab96791722158f7")
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

torch.manual_seed(0)

# C: scalar multiplier for _GCONST_
C = 1.0

# z: tensor of shape (batch_size, dim) - the function computes z**2 and sums along dim 1
z = torch.randn(2, 4)

# logdet_J: tensor or scalar - log determinant of Jacobian, added to logp
logdet_J = torch.randn(2)

ARGS = {
    "C": C,
    "z": z,
    "logdet_J": logdet_J,
}
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
load_weights2 Ran
ran on a synthesized input
gudovskiy/cflow-ad/cflow-to-onnx.py
code served (permissive licence) · get_code("5ed0a07d8083a744")
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 MainModel. 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 os
import tempfile
import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal encoder module
class MinimalEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create a minimal decoder module
class MinimalDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(3, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create the main model with encoder and decoders
class MainModel(nn.Module):
    def __init__(self, num_decoders=2):
        super().__init__()
        self.encoder = MinimalEncoder()
        self.decoders = nn.ModuleList([MinimalDecoder() for _ in range(num_decoders)])
    
    def forward(self, x):
        encoded = self.encoder(x)
        outputs = [decoder(encoded) for decoder in self.decoders]
        return outputs

# Create model and save weights to a temporary file
model = MainModel(num_decoders=2)

# Create state dict with encoder and decoder states
encoder_state = model.encoder.state_dict()
decoder_states = [decoder.state_dict() for decoder in model.decoders]

state_dict = {
    'encoder_state_dict': encoder_state,
    'decoder_state_dict': decoder_states
}

# Save to temporary file
with tempfile.NamedTemporaryFile(mode='w', suffix='.pt', delete=False) as f:
    temp_filename = f.name

torch.save(state_dict, temp_filename)

# Create fresh model to load weights into
model_to_load = MainModel(num_decoders=2)

ARGS = {
    'model': model_to_load,
    'filename': temp_filename
}
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 MainModel — a MainModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MainModel 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
load_weights2 Ran
ran on a synthesized input
gudovskiy/cflow-ad/cflow-to-onnx2.py
code served (permissive licence) · get_code("0b96b4820206a0ff")
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 FullModel. 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
import tempfile
import os

torch.manual_seed(0)

# Create a minimal encoder module
class MinimalEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create a minimal decoder module
class MinimalDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(3, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create encoder module container
class EncoderModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = MinimalEncoder()

# Create decoder module container with multiple decoders
class DecoderModule(nn.Module):
    def __init__(self, num_decoders=2):
        super().__init__()
        self.decoders = nn.ModuleList([MinimalDecoder() for _ in range(num_decoders)])

# Create the full model
class FullModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.Encoder_module = EncoderModule()
        self.Decoder_module = DecoderModule(num_decoders=2)

# Build model
model = FullModel()

# Create temporary file with valid state dict
temp_dir = tempfile.gettempdir()
temp_filename = os.path.join(temp_dir, "test_weights.pt")

# Create a valid state dict matching the expected structure
state_dict = {
    'encoder_state_dict': model.Encoder_module.encoder.state_dict(),
    'decoder_state_dict': [
        model.Decoder_module.decoders[0].state_dict(),
        model.Decoder_module.decoders[1].state_dict()
    ]
}

torch.save(state_dict, temp_filename)

ARGS = {
    'model': model,
    'filename': temp_filename
}
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 FullModel — a FullModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a FullModel 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
positionalencoding2d Ran
ran on a synthesized input
gudovskiy/cflow-ad/model.py
code served (permissive licence) · get_code("fd31dcc4742a6774")
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 (8, 3, 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 math

torch.manual_seed(0)

# The function positionalencoding2d takes three parameters:
# D: dimension of the model (must be divisible by 4)
# H: height of the positions
# W: width of the positions
# It returns a DxHxW tensor

ARGS = {
    'D': 8,   # dimension, divisible by 4
    'H': 3,   # height
    'W': 4,   # width
}
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 3, dtype family float, shape (8, 3, 4) — shape (8, 3, 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
rescale Ran
ran, honoured the contract we drafted
gudovskiy/cflow-ad/utils.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from JuanFMontesinos/Acappella-YNet, is pointer only (licence: NONE) · get_code("f51e6ad9c7104a5a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from JuanFMontesinos/Acappella-YNet, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

subnet_fc Ran
ran; our contract draft was wrong, not the code
gudovskiy/cflow-ad/model.py
code served (permissive licence) · get_code("3f068df64f534372")
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 Sequential. 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)

ARGS = {
    "dims_in": 4,
    "dims_out": 3,
}
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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 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
t2np Ran
ran on a synthesized input
gudovskiy/cflow-ad/utils.py
code served (permissive licence) · get_code("993e5b3dd131459c")
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 2, dtype family float, shape (2, 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 small tensor to pass to t2np
tensor_arg = torch.randn(2, 4)

# Map all parameters to values
ARGS = {
    "tensor": tensor_arg
}
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 ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 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
warmup_learning_rate Ran
ran, honoured the contract we drafted
gudovskiy/cflow-ad/custom_models/utils.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from xcyao00/HGAD, is pointer only (licence: NONE) · get_code("a7e2b063f1913a27")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from xcyao00/HGAD, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

resnet18 Not yet run
unverified (harvested, no recorded run)
gudovskiy/cflow-ad/custom_models/resnet.py
code served (permissive licence) · get_code("fdc6bc5bd1f2e3c8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 6 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 5 later) and 6 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
conv1x1 112 other papers
11 dated earlier, 1 the same month, 100 later · 6 only as an assembly brick
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
1806.01531 (2018-06)
Deep Mixture of Experts via Shallow Embedding
1905.12794 (2019-05)
Fashion IQ: A New Dataset Towards Retrieving Images by Natural Language Feedback
and 109 more not named here
resnet18 36 other papers
5 dated earlier, 31 later
1905.12794 (2019-05)
Fashion IQ: A New Dataset Towards Retrieving Images by Natural Language Feedback
2002.09564 (2020-02)
Towards Robust and Reproducible Active Learning Using Neural Networks
2003.04297 (2020-03)
Improved Baselines with Momentum Contrastive Learning
and 33 more not named here
subnet_fc 4 other papers
4 later
aaai_25604 (2023 (year only))
One-for-All: Proposal Masked Cross-Class Anomaly Detection
2403.13349 (2024-03)
Hierarchical Gaussian Mixture Normalizing Flow Modeling for Unified Anomaly Detection
2410.20047 (2024-10)
ResAD: A Simple Framework for Class Generalizable Anomaly Detection
and 1 more not named here
rescale 3 other papers
3 dated earlier
2008.05369 (2020-08)
Anomaly localization by modeling perceptual features
2104.09946 (2021-04)
A cappella: Audio-visual Singing Voice Separation
2106.08265 (2021-06)
Towards Total Recall in Industrial Anomaly Detection
t2np 1 other paper
1 later
2504.03306 (2025-04)
Multi-Flow: Multi-View-Enriched Normalizing Flows for Industrial Anomaly Detection
warmup_learning_rate 1 other paper
1 later
2403.13349 (2024-03)
Hierarchical Gaussian Mixture Normalizing Flow Modeling for Unified 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

Unsupervised anomaly detection with localization has many practical applications when labeling is infeasible and, moreover, when anomaly examples are completely missing in the train data. While recently proposed models for such data setup achieve high accuracy metrics, their complexity is a limiting factor for real-time processing. In this paper, we propose a real-time model and analytically derive its relationship to prior methods. Our CFLOW-AD model is based on a conditional normalizing flow framework adopted for anomaly detection with localization. In particular, CFLOW-AD consists of a discriminatively pretrained encoder followed by a multi-scale generative decoders where the latter explicitly estimate likelihood of the encoded features. Our approach results in a computationally and memory-efficient model: CFLOW-AD is faster and smaller by a factor of 10x than prior state-of-the-art with the same input setting. Our experiments on the MVTec dataset show that CFLOW-AD outperforms previous methods by 0.36% AUROC in detection task, by 1.12% AUROC and 2.5% AUPRO in localization task, respectively. We open-source our code with fully reproducible experiments.

For agents

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

get_harvested_code_for_paper("2107.12571")
get_code_for_paper("2107.12571")
have("2107.12571")

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

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

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

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

Connect an agent — have() is free.