{"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/bayesian-prompt-flow-learning-for-zero-shot","title":"Bayesian Prompt Flow Learning for Zero-Shot Anomaly Detection","arxiv_id":"2503.10080","date":"2025-03-13","proceeding":"CVPR 2025 1","authors":["Zhen Qu","Xian Tao","Xinyi Gong","Shichen Qu","Qiyu Chen","Zhengtao Zhang","Xingang Wang","Guiguang Ding"],"abstract":"Recently, vision-language models (e.g. CLIP) have demonstrated remarkable performance in zero-shot anomaly detection (ZSAD). By leveraging auxiliary data during training, these models can directly perform cross-category anomaly detection on target datasets, such as detecting defects on industrial product surfaces or identifying tumors in organ tissues. Existing approaches typically construct text prompts through either manual design or the optimization of learnable prompt vectors. However, these methods face several challenges: 1) handcrafted prompts require extensive expert knowledge and trial-and-error; 2) single-form learnable prompts struggle to capture complex anomaly semantics; and 3) an unconstrained prompt space limit generalization to unseen categories. To address these issues, we propose Bayesian Prompt Flow Learning (Bayes-PFL), which models the prompt space as a learnable probability distribution from a Bayesian perspective. Specifically, a prompt flow module is designed to learn both image-specific and image-agnostic distributions, which are jointly utilized to regularize the text prompt space and enhance the model's generalization on unseen categories. These learned distributions are then sampled to generate diverse text prompts, effectively covering the prompt space. Additionally, a residual cross-attention (RCA) module is introduced to better align dynamic text embeddings with fine-grained image features. Extensive experiments on 15 industrial and medical datasets demonstrate our method's superior performance.","url_abs":"https://arxiv.org/abs/2503.10080v1","url_pdf":"https://arxiv.org/pdf/2503.10080v1.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":"bayesian-prompt-flow-learning-for-zero-shot","repo_url":"https://github.com/xiaozhen228/Bayes-PFL","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"},{"task_slug":"zero-shot-anomaly-detection","task_name":"zero-shot anomaly detection"}],"methods":[{"method_slug":"align","method_name":"ALIGN"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2503.10080","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2503.10080"}},"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/xiaozhen228/Bayes-PFL","reach":null}],"summary":{"ran":7,"ran_draft_wrong":1,"unverified":4},"by_repo_kind":{"official":{"samples":12,"ran":8,"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":12,"samples":[{"code_sha256_prefix":"c07c0cecf493a1dd","entry":"Decoder","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c07c0cecf493a1dd"}},{"code_sha256_prefix":"1cd5917f59cfed09","entry":"Encoder","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1cd5917f59cfed09"}},{"code_sha256_prefix":"7492d2701b36df98","entry":"Global_Feature","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7492d2701b36df98"}},{"code_sha256_prefix":"3b23b0d856fbe61f","entry":"InferenceBlock","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3b23b0d856fbe61f"}},{"code_sha256_prefix":"40744df2580572ab","entry":"PFL","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"40744df2580572ab"}},{"code_sha256_prefix":"5ca5a6e68c3b6c2e","entry":"Planar","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5ca5a6e68c3b6c2e"}},{"code_sha256_prefix":"875b72dfcf9c804f","entry":"binary_loss_function","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"875b72dfcf9c804f"}},{"code_sha256_prefix":"7dadf0e81a27a70a","entry":"log_normal_dist","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7dadf0e81a27a70a"}},{"code_sha256_prefix":"6464dd5e0e28bb63","entry":"Context_Prompting","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6464dd5e0e28bb63"}},{"code_sha256_prefix":"45e172ba85da53bc","entry":"PlanarPFL","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"45e172ba85da53bc"}},{"code_sha256_prefix":"834b89db3bf92f14","entry":"PlanarPFL_state","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"834b89db3bf92f14"}},{"code_sha256_prefix":"45e674352dcd6885","entry":"Zero_Parameter","repo":"xiaozhen228/Bayes-PFL","repo_kind":"official","path":"models/VPB.py","file_url":"https://github.com/xiaozhen228/Bayes-PFL/blob/HEAD/models/VPB.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"45e674352dcd6885"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}