{"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/arxiv-2609-12454","title":"Bridging Vision Foundation Model Priors with CLIP for Spatial-aware Few-shot Anomaly Detection in Medical Images","arxiv_id":"2609.12454","date":"2026-09-11","proceeding":null,"authors":["Juzheng Miao","Yuchen Yuan","Cheng Chen","Pheng-Ann Heng"],"abstract":"Vision-Language Models such as CLIP enable effective few-shot medical anomaly detection (AD) via strong image-text semantic alignment. However, their globally contrastive pretraining lacks explicit spatial supervision, limiting precise lesion localization. In contrast, Vision Foundation Models (VFMs) such as DINO learn spatially coherent patch representations via self-distillation and local-to-global consistency, better capturing fine-grained anatomical structures. Leveraging this complementarity, we propose Spatial-FAD, a spatial-aware few-shot medical AD framework that improves lesion localization by combining VFM spatial priors with CLIP semantics. Specifically, we introduce a VFM-enhanced adapter that injects a structural affinity prior derived from DINO into CLIP features. This structure-guided refinement encourages visual embeddings to better adhere to lesion boundaries while maintaining semantic alignment. To address the loss of spatial detail from patchification and the limited input resolution of CLIP, we adopt a sliding-window aggregation strategy. This generates high-resolution, spatially dense embeddings to further enhance localization granularity. Moreover, we introduce a prototype-enhanced support memory scheme to efficiently exploit the few-shot support set. This module stores compact prototypes for normal and abnormal patterns, reducing memory costs while boosting performance by fusing patch-to-prototype and image-text similarities. Extensive experiments on three benchmark datasets, including Liver CT, Retinal OCT, and Brain MRI, demonstrate that Spatial-FAD significantly outperforms state-of-the-art methods, especially in lesion segmentation. Notably, in the 4-shot scenario, our method achieves an average improvement of over 11.4% in Dice score and 1.8% in AUC. Code is available at: https://github.com/JuzhengMiao/Spatial-FAD.","url_abs":"https://arxiv.org/abs/2609.12454","url_pdf":"https://arxiv.org/pdf/2609.12454","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2609.12454","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2609.12454"}},"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":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/JuzhengMiao/Spatial-FAD","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_violates":1,"ran_draft_wrong":2,"ran_honours":1,"unverified":8},"by_repo_kind":{"found_in_text":{"samples":12,"ran":4,"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":"f19962ebb134b3d7","entry":"convert_to_custom_text_state_dict","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"CLIP/model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/CLIP/model.py","link_basis":"plan_row","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f19962ebb134b3d7"}},{"code_sha256_prefix":"dcd422d66b0581d8","entry":"get_cast_dtype","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"CLIP/model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/CLIP/model.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dcd422d66b0581d8"}},{"code_sha256_prefix":"b476c8cfbf0f1f47","entry":"get_input_dtype","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/model.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b476c8cfbf0f1f47"}},{"code_sha256_prefix":"f0bead498d7b3068","entry":"get_rot_mat","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"custom_utils.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/custom_utils.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f0bead498d7b3068"}},{"code_sha256_prefix":"09c0abc70500a134","entry":"build_model_from_openai_state_dict","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"CLIP/model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/CLIP/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":"09c0abc70500a134"}},{"code_sha256_prefix":"80d50221b83e3ef4","entry":"cos_sim","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"custom_utils.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/custom_utils.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":"80d50221b83e3ef4"}},{"code_sha256_prefix":"00c4c440750b8eec","entry":"freeze_batch_norm_2d","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"CLIP/modified_resnet.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/CLIP/modified_resnet.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":"00c4c440750b8eec"}},{"code_sha256_prefix":"ddcbd45e940484ee","entry":"gather_features","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/loss.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/loss.py","link_basis":"plan_row","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":"ddcbd45e940484ee"}},{"code_sha256_prefix":"e332856e3c2fc814","entry":"neighbour_exchange","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/loss.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/loss.py","link_basis":"plan_row","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":"e332856e3c2fc814"}},{"code_sha256_prefix":"5b1fd364afcf3c05","entry":"neighbour_exchange_bidir","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/loss.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/loss.py","link_basis":"plan_row","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":"5b1fd364afcf3c05"}},{"code_sha256_prefix":"fb651d0a97fd4d3f","entry":"prepare_inputs_for_generation","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/coca_model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/coca_model.py","link_basis":"plan_row","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":"fb651d0a97fd4d3f"}},{"code_sha256_prefix":"2a377da4a76a2d44","entry":"register_pooler","repo":"JuzhengMiao/Spatial-FAD","repo_kind":"found_in_text","path":"open_clip_SpatialFAD/hf_model.py","file_url":"https://github.com/JuzhengMiao/Spatial-FAD/blob/HEAD/open_clip_SpatialFAD/hf_model.py","link_basis":"plan_row","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":"2a377da4a76a2d44"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CV","source":"arxiv_backlog_21d_20260915.json"},"syntology_extracted_results":null}