{"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/optimizing-patchcore-for-few-many-shot","title":"Optimizing PatchCore for Few/many-shot Anomaly Detection","arxiv_id":"2307.10792","date":"2023-07-20","proceeding":null,"authors":["João Santos","Triet Tran","Oliver Rippel"],"abstract":"Few-shot anomaly detection (AD) is an emerging sub-field of general AD, and tries to distinguish between normal and anomalous data using only few selected samples. While newly proposed few-shot AD methods do compare against pre-existing algorithms developed for the full-shot domain as baselines, they do not dedicatedly optimize them for the few-shot setting. It thus remains unclear if the performance of such pre-existing algorithms can be further improved. We address said question in this work. Specifically, we present a study on the AD/anomaly segmentation (AS) performance of PatchCore, the current state-of-the-art full-shot AD/AS algorithm, in both the few-shot and the many-shot settings. We hypothesize that further performance improvements can be realized by (I) optimizing its various hyperparameters, and by (II) transferring techniques known to improve few-shot supervised learning to the AD domain. Exhaustive experiments on the public VisA and MVTec AD datasets reveal that (I) significant performance improvements can be realized by optimizing hyperparameters such as the underlying feature extractor, and that (II) image-level augmentations can, but are not guaranteed, to improve performance. Based on these findings, we achieve a new state of the art in few-shot AD on VisA, further demonstrating the merit of adapting pre-existing AD/AS methods to the few-shot setting. Last, we identify the investigation of feature extractors with a strong inductive bias as a potential future research direction for (few-shot) AD/AS.","url_abs":"https://arxiv.org/abs/2307.10792v1","url_pdf":"https://arxiv.org/pdf/2307.10792v1.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":"optimizing-patchcore-for-few-many-shot","repo_url":"https://github.com/scortexio/patchcore-few-shot","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"optimizing-patchcore-for-few-many-shot","repo_url":"https://github.com/MindSpore-paper-code-2/code2/tree/main/PatchCore","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"optimizing-patchcore-for-few-many-shot","repo_url":"https://github.com/code-implementation1/Code6/tree/main/PatchCore","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"},{"task_slug":"anomaly-segmentation","task_name":"Anomaly Segmentation"},{"task_slug":"inductive-bias","task_name":"Inductive Bias"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2307.10792","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2307.10792"}},"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/MindSpore-paper-code-2/code2/tree/main/PatchCore","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/code-implementation1/Code6/tree/main/PatchCore","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/scortexio/patchcore-few-shot","reach":{"status":"ok"}}],"summary":{"ran":4,"unverified":10},"by_repo_kind":{"official":{"samples":14,"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":14,"samples":[{"code_sha256_prefix":"0df9110a3e902c84","entry":"downscale_image","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/pre_processing/tiler.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/pre_processing/tiler.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":"0df9110a3e902c84"}},{"code_sha256_prefix":"09ec852941ee7b97","entry":"filter_dataframe_experiment","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/utils/general.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/utils/general.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":"09ec852941ee7b97"}},{"code_sha256_prefix":"55219966131ba694","entry":"get_indexes_from_filenames","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/utils/general.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/utils/general.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":"55219966131ba694"}},{"code_sha256_prefix":"104da3e4b26f2c3a","entry":"upscale_image","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/pre_processing/tiler.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/pre_processing/tiler.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":"104da3e4b26f2c3a"}},{"code_sha256_prefix":"943f15268bdd462e","entry":"add_anomalous_label","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/post_processing/post_process.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/post_processing/post_process.py","link_basis":"harvester_set","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":"943f15268bdd462e"}},{"code_sha256_prefix":"4447ac929ca7ab0c","entry":"add_label","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/post_processing/post_process.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/post_processing/post_process.py","link_basis":"harvester_set","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":"4447ac929ca7ab0c"}},{"code_sha256_prefix":"fe1771d45fa5b75a","entry":"add_normal_label","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/post_processing/post_process.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/post_processing/post_process.py","link_basis":"harvester_set","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":"fe1771d45fa5b75a"}},{"code_sha256_prefix":"a2dff7977c4b3db4","entry":"compute_new_image_size","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/pre_processing/tiler.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/pre_processing/tiler.py","link_basis":"harvester_set","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":"a2dff7977c4b3db4"}},{"code_sha256_prefix":"ec1d2a4493b60e50","entry":"create_dataframe_from_seeds_file","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/utils/general.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/utils/general.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":"ec1d2a4493b60e50"}},{"code_sha256_prefix":"7703e3fe0138f8d3","entry":"get_image_height_and_width","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/pre_processing/pre_process.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/pre_processing/pre_process.py","link_basis":"harvester_set","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":"7703e3fe0138f8d3"}},{"code_sha256_prefix":"36ed981842aa4e86","entry":"get_transforms","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/pre_processing/pre_process.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/pre_processing/pre_process.py","link_basis":"harvester_set","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":"36ed981842aa4e86"}},{"code_sha256_prefix":"458acbf30c9b5a58","entry":"update_input_size_config","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/config/config.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/config/config.py","link_basis":"harvester_set","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":"458acbf30c9b5a58"}},{"code_sha256_prefix":"6d3c92b52fa4d6da","entry":"update_multi_gpu_training_config","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/config/config.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/config/config.py","link_basis":"harvester_set","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":"6d3c92b52fa4d6da"}},{"code_sha256_prefix":"5179dd442c5dbf8b","entry":"update_nncf_config","repo":"scortexio/patchcore-few-shot","repo_kind":"official","path":"src/anomalib/config/config.py","file_url":"https://github.com/scortexio/patchcore-few-shot/blob/HEAD/src/anomalib/config/config.py","link_basis":"harvester_set","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":"5179dd442c5dbf8b"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}