{"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/segment-any-anomaly-without-training-via","title":"Segment Any Anomaly without Training via Hybrid Prompt Regularization","arxiv_id":"2305.10724","date":"2023-05-18","proceeding":null,"authors":["Yunkang Cao","Xiaohao Xu","Chen Sun","Yuqi Cheng","Zongwei Du","Liang Gao","Weiming Shen"],"abstract":"We present a novel framework, i.e., Segment Any Anomaly + (SAA+), for zero-shot anomaly segmentation with hybrid prompt regularization to improve the adaptability of modern foundation models. Existing anomaly segmentation models typically rely on domain-specific fine-tuning, limiting their generalization across countless anomaly patterns. In this work, inspired by the great zero-shot generalization ability of foundation models like Segment Anything, we first explore their assembly to leverage diverse multi-modal prior knowledge for anomaly localization. For non-parameter foundation model adaptation to anomaly segmentation, we further introduce hybrid prompts derived from domain expert knowledge and target image context as regularization. Our proposed SAA+ model achieves state-of-the-art performance on several anomaly segmentation benchmarks, including VisA, MVTec-AD, MTD, and KSDD2, in the zero-shot setting. We will release the code at \\href{https://github.com/caoyunkang/Segment-Any-Anomaly}{https://github.com/caoyunkang/Segment-Any-Anomaly}.","url_abs":"https://arxiv.org/abs/2305.10724v1","url_pdf":"https://arxiv.org/pdf/2305.10724v1.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":"segment-any-anomaly-without-training-via","repo_url":"https://github.com/caoyunkang/segment-any-anomaly","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"segment-any-anomaly-without-training-via","repo_url":"https://github.com/caoyunkang/groundedsam-zero-shot-anomaly-detection","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"},{"task_slug":"anomaly-localization","task_name":"Anomaly Localization"},{"task_slug":"anomaly-segmentation","task_name":"Anomaly Segmentation"},{"task_slug":"segmentation","task_name":"Segmentation"},{"task_slug":"zero-shot-generalization","task_name":"Zero-shot Generalization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/anomaly-detection-on-ksdd2","task":"Anomaly Detection","dataset":"KSDD2","model":"SAA+","rank_in_archive_order":1,"of":1,"metrics":{"F1-Score":"59.19"},"uses_additional_data":false},{"leaderboard":"/sota/anomaly-detection-on-visa","task":"Anomaly Detection","dataset":"VisA","model":"SAA+","rank_in_archive_order":49,"of":50,"metrics":{"F1-Score":"27.07"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2305.10724","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2305.10724"}},"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/caoyunkang/groundedsam-zero-shot-anomaly-detection","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/caoyunkang/segment-any-anomaly","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":3,"unverified":6},"by_repo_kind":{"official":{"samples":9,"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":"733d7f0bedcb74c2","entry":"get_rel_pos","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/modeling/image_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"733d7f0bedcb74c2"}},{"code_sha256_prefix":"105fa08885dc36cc","entry":"window_partition","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/modeling/image_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"105fa08885dc36cc"}},{"code_sha256_prefix":"50f37d517e2be27f","entry":"window_unpartition","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/modeling/image_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"50f37d517e2be27f"}},{"code_sha256_prefix":"7069d6e0ba7c409e","entry":"box_xyxy_to_xywh","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/utils/amg.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/utils/amg.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":"7069d6e0ba7c409e"}},{"code_sha256_prefix":"d30fb98bb5527e4c","entry":"build_sam_vit_b","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/build_sam.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/build_sam.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":"d30fb98bb5527e4c"}},{"code_sha256_prefix":"651b14799932c69f","entry":"build_sam_vit_h","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/build_sam.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/build_sam.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":"651b14799932c69f"}},{"code_sha256_prefix":"a57702b6feec4b40","entry":"build_sam_vit_l","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/build_sam.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/build_sam.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":"a57702b6feec4b40"}},{"code_sha256_prefix":"114a3e68a54ab16c","entry":"is_box_near_crop_edge","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/utils/amg.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/utils/amg.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":"114a3e68a54ab16c"}},{"code_sha256_prefix":"d59832deec0972a0","entry":"mask_to_rle_pytorch","repo":"caoyunkang/segment-any-anomaly","repo_kind":"official","path":"SAM/segment_anything/utils/amg.py","file_url":"https://github.com/caoyunkang/segment-any-anomaly/blob/HEAD/SAM/segment_anything/utils/amg.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":"d59832deec0972a0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}