{"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/inpainting-transformer-for-anomaly-detection","title":"Inpainting Transformer for Anomaly Detection","arxiv_id":"2104.13897","date":"2021-04-28","proceeding":null,"authors":["Jonathan Pirnay","Keng Chai"],"abstract":"Anomaly detection in computer vision is the task of identifying images which deviate from a set of normal images. A common approach is to train deep convolutional autoencoders to inpaint covered parts of an image and compare the output with the original image. By training on anomaly-free samples only, the model is assumed to not being able to reconstruct anomalous regions properly. For anomaly detection by inpainting we suggest it to be beneficial to incorporate information from potentially distant regions. In particular we pose anomaly detection as a patch-inpainting problem and propose to solve it with a purely self-attention based approach discarding convolutions. The proposed Inpainting Transformer (InTra) is trained to inpaint covered patches in a large sequence of image patches, thereby integrating information across large regions of the input image. When training from scratch, in comparison to other methods not using extra training data, InTra achieves results on par with the current state-of-the-art on the MVTec AD dataset for detection and surpassing them on segmentation.","url_abs":"https://arxiv.org/abs/2104.13897v3","url_pdf":"https://arxiv.org/pdf/2104.13897v3.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":"inpainting-transformer-for-anomaly-detection","repo_url":"https://github.com/uzl/inpainting-transformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"inpainting-transformer-for-anomaly-detection","repo_url":"https://github.com/jhy12/inpainting-transformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"anomaly-detection","task_name":"Anomaly Detection"}],"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":"pixel-prediction","method_name":"Inpainting"},{"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":[{"leaderboard":"/sota/anomaly-detection-on-aebad-s","task":"Anomaly Detection","dataset":"AeBAD-S","model":"InTra","rank_in_archive_order":7,"of":8,"metrics":{"Detection AUROC":"44.2","Segmentation AUPRO":"74.7"},"uses_additional_data":false},{"leaderboard":"/sota/anomaly-detection-on-aebad-v","task":"Anomaly Detection","dataset":"AeBAD-V","model":"InTra","rank_in_archive_order":7,"of":7,"metrics":{"Detection AUROC":"54.1"},"uses_additional_data":false},{"leaderboard":"/sota/anomaly-detection-on-mvtec-ad","task":"Anomaly Detection","dataset":"MVTec AD","model":"InTra","rank_in_archive_order":94,"of":148,"metrics":{"Detection AUROC":"95.0","Segmentation AUROC":"96.6"},"uses_additional_data":true}],"syntology":{"syntology_url":"https://syntology.ai/paper/2104.13897","atlas_url":"https://app.syntology.ai/?focus=2104.13897","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2104.13897"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/uzl/inpainting-transformer","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jhy12/inpainting-transformer","reach":null}],"summary":{"ran_draft_wrong":2,"ran_honours":1,"ran_fixture":1},"by_repo_kind":{"listed":{"samples":4,"ran":4,"repositories":2}},"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":4,"samples":[{"code_sha256_prefix":"bcec61b27800543d","entry":"attention","repo":"jhy12/inpainting-transformer","repo_kind":"listed","path":"model.py","file_url":"https://github.com/jhy12/inpainting-transformer/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bcec61b27800543d"}},{"code_sha256_prefix":"6893af95b673482b","entry":"clones","repo":"jhy12/inpainting-transformer","repo_kind":"listed","path":"model.py","file_url":"https://github.com/jhy12/inpainting-transformer/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6893af95b673482b"}},{"code_sha256_prefix":"fd379ae04177d538","entry":"g","repo":"jhy12/inpainting-transformer","repo_kind":"listed","path":"model.py","file_url":"https://github.com/jhy12/inpainting-transformer/blob/HEAD/model.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fd379ae04177d538"}},{"code_sha256_prefix":"fde200589548d0c3","entry":"img_to_window_patches","repo":"uzl/inpainting-transformer","repo_kind":"listed","path":"inpainting_transformer_base.py","file_url":"https://github.com/uzl/inpainting-transformer/blob/HEAD/inpainting_transformer_base.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fde200589548d0c3"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}