{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/cflow-ad-real-time-unsupervised-anomaly","title":"CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows","arxiv_id":"2107.12571","date":"2021-07-27","proceeding":null,"authors":["Denis Gudovskiy","Shun Ishizaka","Kazuki Kozuka"],"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.","url_abs":"https://arxiv.org/abs/2107.12571v1","url_pdf":"https://arxiv.org/pdf/2107.12571v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"cflow-ad-real-time-unsupervised-anomaly","repo_url":"https://github.com/gudovskiy/cflow-ad","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"paper_slug":"cflow-ad-real-time-unsupervised-anomaly","repo_url":"https://github.com/caoyunkang/IKD","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"cflow-ad-real-time-unsupervised-anomaly","repo_url":"https://github.com/openvinotoolkit/anomalib/tree/development/anomalib/models/cflow","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"anomaly-classification","task_name":"Anomaly Classification"},{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"},{"task_slug":"anomaly-segmentation","task_name":"Anomaly Segmentation"},{"task_slug":"unsupervised-anomaly-detection","task_name":"Unsupervised Anomaly Detection"}],"methods":[{"method_slug":"normalizing-flows","method_name":"Normalizing Flows"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/anomaly-classification-on-goodsad","task":"Anomaly Classification","dataset":"GoodsAD","model":"CFLOW-AD","rank_in_archive_order":4,"of":11,"metrics":{"AUPR":"75.3","AUROC":"71.2"},"uses_additional_data":false},{"leaderboard":"/sota/anomaly-detection-on-mvtec-ad","task":"Anomaly Detection","dataset":"MVTec AD","model":"CFLOW-AD","rank_in_archive_order":63,"of":148,"metrics":{"Detection AUROC":"98.26","FPS":"27","Segmentation AUPRO":"94.6","Segmentation AUROC":"98.62"},"uses_additional_data":false},{"leaderboard":"/sota/anomaly-detection-on-visa","task":"Anomaly Detection","dataset":"VisA","model":"CFLOW","rank_in_archive_order":28,"of":50,"metrics":{"Detection AUROC":"91.5"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2107.12571","atlas_url":"https://app.syntology.ai/?focus=2107.12571","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2107.12571"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/caoyunkang/IKD","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/gudovskiy/cflow-ad","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/openvinotoolkit/anomalib/tree/development/anomalib/models/cflow","reach":null}],"summary":{"ran_draft_wrong":1,"ran_honours":1,"ran":1,"unverified":9},"by_repo_kind":{"official":{"samples":12,"ran":3,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"2a80220dabcb742a","entry":"conv1x1","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"custom_models/resnet.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/custom_models/resnet.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2a80220dabcb742a"}},{"code_sha256_prefix":"f51e6ad9c7104a5a","entry":"rescale","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"utils.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/utils.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"f51e6ad9c7104a5a"}},{"code_sha256_prefix":"a7e2b063f1913a27","entry":"warmup_learning_rate","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"custom_models/utils.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/custom_models/utils.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a7e2b063f1913a27"}},{"code_sha256_prefix":"436bb4b1f6464d1b","entry":"conv3x3","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"custom_models/resnet.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/custom_models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"436bb4b1f6464d1b"}},{"code_sha256_prefix":"d731362a1a10fe78","entry":"denormalization","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"visualize.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/visualize.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"d731362a1a10fe78"}},{"code_sha256_prefix":"2ab96791722158f7","entry":"get_logp","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"utils.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"2ab96791722158f7"}},{"code_sha256_prefix":"5ed0a07d8083a744","entry":"load_weights2","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"cflow-to-onnx.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/cflow-to-onnx.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"5ed0a07d8083a744"}},{"code_sha256_prefix":"0b96b4820206a0ff","entry":"load_weights2","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"cflow-to-onnx2.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/cflow-to-onnx2.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"0b96b4820206a0ff"}},{"code_sha256_prefix":"fd31dcc4742a6774","entry":"positionalencoding2d","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"model.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"fd31dcc4742a6774"}},{"code_sha256_prefix":"fdc6bc5bd1f2e3c8","entry":"resnet18","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"custom_models/resnet.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/custom_models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"fdc6bc5bd1f2e3c8"}},{"code_sha256_prefix":"3f068df64f534372","entry":"subnet_fc","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"model.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/model.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"3f068df64f534372"}},{"code_sha256_prefix":"993e5b3dd131459c","entry":"t2np","repo":"gudovskiy/cflow-ad","repo_kind":"official","path":"utils.py","file_url":"https://github.com/gudovskiy/cflow-ad/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"993e5b3dd131459c"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}