{"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/focus-the-discrepancy-intra-and-inter","title":"Focus the Discrepancy: Intra- and Inter-Correlation Learning for Image Anomaly Detection","arxiv_id":"2308.02983","date":"2023-08-06","proceeding":"ICCV 2023 1","authors":["Xincheng Yao","Ruoqi Li","Zefeng Qian","Yan Luo","Chongyang Zhang"],"abstract":"Humans recognize anomalies through two aspects: larger patch-wise representation discrepancies and weaker patch-to-normal-patch correlations. However, the previous AD methods didn't sufficiently combine the two complementary aspects to design AD models. To this end, we find that Transformer can ideally satisfy the two aspects as its great power in the unified modeling of patch-wise representations and patch-to-patch correlations. In this paper, we propose a novel AD framework: FOcus-the-Discrepancy (FOD), which can simultaneously spot the patch-wise, intra- and inter-discrepancies of anomalies. The major characteristic of our method is that we renovate the self-attention maps in transformers to Intra-Inter-Correlation (I2Correlation). The I2Correlation contains a two-branch structure to first explicitly establish intra- and inter-image correlations, and then fuses the features of two-branch to spotlight the abnormal patterns. To learn the intra- and inter-correlations adaptively, we propose the RBF-kernel-based target-correlations as learning targets for self-supervised learning. Besides, we introduce an entropy constraint strategy to solve the mode collapse issue in optimization and further amplify the normal-abnormal distinguishability. Extensive experiments on three unsupervised real-world AD benchmarks show the superior performance of our approach. Code will be available at https://github.com/xcyao00/FOD.","url_abs":"https://arxiv.org/abs/2308.02983v1","url_pdf":"https://arxiv.org/pdf/2308.02983v1.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":"focus-the-discrepancy-intra-and-inter","repo_url":"https://github.com/xcyao00/fod","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"},{"task_slug":"self-supervised-learning","task_name":"Self-Supervised Learning"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2308.02983","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2308.02983"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/xcyao00/fod","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/xcyao00/FOD","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":9,"ran_draft_wrong":1,"unverified":3},"by_repo_kind":{"official":{"samples":13,"ran":10,"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":"5ed0a100400b50f9","entry":"Embedding2D","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5ed0a100400b50f9"}},{"code_sha256_prefix":"5ef174bf4fbeea2f","entry":"Encoder","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5ef174bf4fbeea2f"}},{"code_sha256_prefix":"69586fc628c7ebb6","entry":"EncoderLayer","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69586fc628c7ebb6"}},{"code_sha256_prefix":"9aadfb2a17c8c080","entry":"PositionalEmbedding","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9aadfb2a17c8c080"}},{"code_sha256_prefix":"b45f413cb8bb72e2","entry":"compute_pro_retrieval_metrics","repo":"xcyao00/fod","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/utils/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b45f413cb8bb72e2"}},{"code_sha256_prefix":"3dcadf77eb559329","entry":"denormalization","repo":"xcyao00/fod","repo_kind":"official","path":"utils/visualizer.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/utils/visualizer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3dcadf77eb559329"}},{"code_sha256_prefix":"ef0e6b962918f4b4","entry":"embedding_concat","repo":"xcyao00/fod","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/utils/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ef0e6b962918f4b4"}},{"code_sha256_prefix":"d6ada2dc4e5d3719","entry":"entropy_loss","repo":"xcyao00/fod","repo_kind":"official","path":"losses.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d6ada2dc4e5d3719"}},{"code_sha256_prefix":"11596f92ff71fb9a","entry":"idx_1d_to_pos_2d","repo":"xcyao00/fod","repo_kind":"official","path":"create_distance_maps.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/create_distance_maps.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"11596f92ff71fb9a"}},{"code_sha256_prefix":"502c50812b7f31ab","entry":"to_var","repo":"xcyao00/fod","repo_kind":"official","path":"utils/utils.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/utils/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"502c50812b7f31ab"}},{"code_sha256_prefix":"36da03ed71d4d479","entry":"Attention2D","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","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":"36da03ed71d4d479"}},{"code_sha256_prefix":"de8248efbce530f7","entry":"FOD","repo":"xcyao00/FOD","repo_kind":"official","path":"models/model.py","file_url":"https://github.com/xcyao00/FOD/blob/HEAD/models/model.py","link_basis":"first_harvest_node","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":"de8248efbce530f7"}},{"code_sha256_prefix":"a2f6a358aed78f39","entry":"kl_loss","repo":"xcyao00/fod","repo_kind":"official","path":"losses.py","file_url":"https://github.com/xcyao00/fod/blob/HEAD/losses.py","link_basis":"first_harvest_node","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":"a2f6a358aed78f39"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}