{"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/resad-a-simple-framework-for-class","title":"ResAD: A Simple Framework for Class Generalizable Anomaly Detection","arxiv_id":"2410.20047","date":"2024-10-26","proceeding":null,"authors":["Xincheng Yao","Zixin Chen","Chao GAO","Guangtao Zhai","Chongyang Zhang"],"abstract":"This paper explores the problem of class-generalizable anomaly detection, where the objective is to train one unified AD model that can generalize to detect anomalies in diverse classes from different domains without any retraining or fine-tuning on the target data. Because normal feature representations vary significantly across classes, this will cause the widely studied one-for-one AD models to be poorly classgeneralizable (i.e., performance drops dramatically when used for new classes). In this work, we propose a simple but effective framework (called ResAD) that can be directly applied to detect anomalies in new classes. Our main insight is to learn the residual feature distribution rather than the initial feature distribution. In this way, we can significantly reduce feature variations. Even in new classes, the distribution of normal residual features would not remarkably shift from the learned distribution. Therefore, the learned model can be directly adapted to new classes. ResAD consists of three components: (1) a Feature Converter that converts initial features into residual features; (2) a simple and shallow Feature Constraintor that constrains normal residual features into a spatial hypersphere for further reducing feature variations and maintaining consistency in feature scales among different classes; (3) a Feature Distribution Estimator that estimates the normal residual feature distribution, anomalies can be recognized as out-of-distribution. Despite the simplicity, ResAD can achieve remarkable anomaly detection results when directly used in new classes. The code is available at https://github.com/xcyao00/ResAD.","url_abs":"https://arxiv.org/abs/2410.20047v1","url_pdf":"https://arxiv.org/pdf/2410.20047v1.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":"resad-a-simple-framework-for-class","repo_url":"https://github.com/xcyao00/resad","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.20047","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.20047"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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":"deterministic:regex_extraction","url":"https://github.com/xcyao00/ResAD","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/xcyao00/resad","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":11},"by_repo_kind":{"official":{"samples":11,"ran":0,"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":"09544c0c0a013039","entry":"calculate_log_barrier_occ_loss","repo":"xcyao00/resad","repo_kind":"official","path":"losses/loss.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/losses/loss.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"09544c0c0a013039"}},{"code_sha256_prefix":"5ac595999ee650c5","entry":"calculate_occ_loss","repo":"xcyao00/resad","repo_kind":"official","path":"losses/loss.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/losses/loss.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5ac595999ee650c5"}},{"code_sha256_prefix":"4864e6c6c42523f8","entry":"get_logp_a","repo":"xcyao00/resad","repo_kind":"official","path":"losses/utils.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/losses/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4864e6c6c42523f8"}},{"code_sha256_prefix":"6871690b7d7c52ca","entry":"get_logp_boundary","repo":"xcyao00/resad","repo_kind":"official","path":"losses/loss.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/losses/loss.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6871690b7d7c52ca"}},{"code_sha256_prefix":"97bb30729343aee3","entry":"get_normal_boundary","repo":"xcyao00/resad","repo_kind":"official","path":"losses/utils.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/losses/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"97bb30729343aee3"}},{"code_sha256_prefix":"5461edac0e02cae6","entry":"get_position_encoding","repo":"xcyao00/resad","repo_kind":"official","path":"models/modules.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/models/modules.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5461edac0e02cae6"}},{"code_sha256_prefix":"5697b41685ddd400","entry":"load_and_transform_vision_data","repo":"xcyao00/resad","repo_kind":"official","path":"main_ib.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/main_ib.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5697b41685ddd400"}},{"code_sha256_prefix":"8724d875b88a147c","entry":"load_mc_reference_features","repo":"xcyao00/resad","repo_kind":"official","path":"main_all.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/main_all.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8724d875b88a147c"}},{"code_sha256_prefix":"38f73e38d215dec7","entry":"load_mc_reference_features","repo":"xcyao00/resad","repo_kind":"official","path":"main_ib.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/main_ib.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"38f73e38d215dec7"}},{"code_sha256_prefix":"247b256eed3c80d3","entry":"load_reference_features","repo":"xcyao00/resad","repo_kind":"official","path":"cpr.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/cpr.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"247b256eed3c80d3"}},{"code_sha256_prefix":"3f068df64f534372","entry":"subnet_fc","repo":"xcyao00/resad","repo_kind":"official","path":"models/fc_flow.py","file_url":"https://github.com/xcyao00/resad/blob/HEAD/models/fc_flow.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3f068df64f534372"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}