{"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/lf-vit-reducing-spatial-redundancy-in-vision","title":"LF-ViT: Reducing Spatial Redundancy in Vision Transformer for Efficient Image Recognition","arxiv_id":"2402.00033","date":"2024-01-08","proceeding":null,"authors":["Youbing Hu","Yun Cheng","Anqi Lu","Zhiqiang Cao","Dawei Wei","Jie Liu","Zhijun Li"],"abstract":"The Vision Transformer (ViT) excels in accuracy when handling high-resolution images, yet it confronts the challenge of significant spatial redundancy, leading to increased computational and memory requirements. To address this, we present the Localization and Focus Vision Transformer (LF-ViT). This model operates by strategically curtailing computational demands without impinging on performance. In the Localization phase, a reduced-resolution image is processed; if a definitive prediction remains elusive, our pioneering Neighborhood Global Class Attention (NGCA) mechanism is triggered, effectively identifying and spotlighting class-discriminative regions based on initial findings. Subsequently, in the Focus phase, this designated region is used from the original image to enhance recognition. Uniquely, LF-ViT employs consistent parameters across both phases, ensuring seamless end-to-end optimization. Our empirical tests affirm LF-ViT's prowess: it remarkably decreases Deit-S's FLOPs by 63\\% and concurrently amplifies throughput twofold. Code of this project is at https://github.com/edgeai1/LF-ViT.git.","url_abs":"https://arxiv.org/abs/2402.00033v1","url_pdf":"https://arxiv.org/pdf/2402.00033v1.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":"lf-vit-reducing-spatial-redundancy-in-vision","repo_url":"https://github.com/edgeai1/lf-vit","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"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":"ca","method_name":"Class Attention"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"focus","method_name":"Focus"},{"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"},{"method_slug":"vision-transformer","method_name":"Vision Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2402.00033","atlas_url":"https://app.syntology.ai/?focus=2402.00033","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.00033"}},"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/edgeai1/lf-vit","reach":{"status":"ok"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/edgeai1/LF-ViT","reach":{"status":"ok"}}],"summary":{"ran":7,"ran_draft_wrong":3,"unverified":8},"by_repo_kind":{"official":{"samples":18,"ran":10,"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":18,"samples":[{"code_sha256_prefix":"52f85fff66a980a4","entry":"Attention","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"52f85fff66a980a4"}},{"code_sha256_prefix":"a1b6bdfb470d9562","entry":"Block","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a1b6bdfb470d9562"}},{"code_sha256_prefix":"3d1ff83d44a53af8","entry":"MultiResoPatchEmbed","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3d1ff83d44a53af8"}},{"code_sha256_prefix":"11a9344aa6b3aaf2","entry":"accuracy","repo":"edgeai1/lf-vit","repo_kind":"official","path":"utils.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/utils.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":"11a9344aa6b3aaf2"}},{"code_sha256_prefix":"908619be92da9903","entry":"batch_index_select","repo":"edgeai1/lf-vit","repo_kind":"official","path":"utils.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/utils.py","link_basis":"harvester_set","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":"908619be92da9903"}},{"code_sha256_prefix":"8f49cc1ffec8b4b7","entry":"dynamic_evaluate","repo":"edgeai1/lf-vit","repo_kind":"official","path":"dynamic_inference.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/dynamic_inference.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8f49cc1ffec8b4b7"}},{"code_sha256_prefix":"dd836cf662c768c1","entry":"generate","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dd836cf662c768c1"}},{"code_sha256_prefix":"92d94f28ebc2079a","entry":"get_index","repo":"edgeai1/lf-vit","repo_kind":"official","path":"utils.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/utils.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":"92d94f28ebc2079a"}},{"code_sha256_prefix":"37f5e48a5790ef05","entry":"get_keep_indices","repo":"edgeai1/lf-vit","repo_kind":"official","path":"visualize.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/visualize.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":"37f5e48a5790ef05"}},{"code_sha256_prefix":"7d65fb83e43743c6","entry":"get_transform","repo":"edgeai1/lf-vit","repo_kind":"official","path":"visualize.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/visualize.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":"7d65fb83e43743c6"}},{"code_sha256_prefix":"e36d348c0df870e0","entry":"LFVisionTransformer","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.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":"e36d348c0df870e0"}},{"code_sha256_prefix":"f51a8394b17320e2","entry":"block_information","repo":"edgeai1/LF-ViT","repo_kind":"official","path":"deit/models_deit.py","file_url":"https://github.com/edgeai1/LF-ViT/blob/HEAD/deit/models_deit.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":"f51a8394b17320e2"}},{"code_sha256_prefix":"72c99ead58ffc65e","entry":"build_dataset","repo":"edgeai1/lf-vit","repo_kind":"official","path":"deit/datasets.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/deit/datasets.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":"72c99ead58ffc65e"}},{"code_sha256_prefix":"b6679d5755485cf9","entry":"build_dataset2","repo":"edgeai1/lf-vit","repo_kind":"official","path":"deit/datasets.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/deit/datasets.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":"b6679d5755485cf9"}},{"code_sha256_prefix":"3bc74137ab36aa79","entry":"build_transform","repo":"edgeai1/lf-vit","repo_kind":"official","path":"deit/datasets.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/deit/datasets.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":"3bc74137ab36aa79"}},{"code_sha256_prefix":"ca075d52aba3771f","entry":"evaluate_throughput","repo":"edgeai1/lf-vit","repo_kind":"official","path":"dynamic_inference.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/dynamic_inference.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":"ca075d52aba3771f"}},{"code_sha256_prefix":"b0434ead3a6e4aea","entry":"gen_masked_tokens","repo":"edgeai1/lf-vit","repo_kind":"official","path":"visualize.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/visualize.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":"b0434ead3a6e4aea"}},{"code_sha256_prefix":"1219d9ea900f99e7","entry":"generate_logits","repo":"edgeai1/lf-vit","repo_kind":"official","path":"dynamic_inference.py","file_url":"https://github.com/edgeai1/lf-vit/blob/HEAD/dynamic_inference.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":"1219d9ea900f99e7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}