{"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/2dmamba-efficient-state-space-model-for-image","title":"2DMamba: Efficient State Space Model for Image Representation with Applications on Giga-Pixel Whole Slide Image Classification","arxiv_id":"2412.00678","date":"2024-12-01","proceeding":"CVPR 2025 1","authors":["Jingwei Zhang","Anh Tien Nguyen","Xi Han","Vincent Quoc-Huy Trinh","Hong Qin","Dimitris Samaras","Mahdi S. Hosseini"],"abstract":"Efficiently modeling large 2D contexts is essential for various fields including Giga-Pixel Whole Slide Imaging (WSI) and remote sensing. Transformer-based models offer high parallelism but face challenges due to their quadratic complexity for handling long sequences. Recently, Mamba introduced a selective State Space Model (SSM) with linear complexity and high parallelism, enabling effective and efficient modeling of wide context in 1D sequences. However, extending Mamba to vision tasks, which inherently involve 2D structures, results in spatial discrepancies due to the limitations of 1D sequence processing. On the other hand, current 2D SSMs inherently model 2D structures but they suffer from prohibitively slow computation due to the lack of efficient parallel algorithms. In this work, we propose 2DMamba, a novel 2D selective SSM framework that incorporates the 2D spatial structure of images into Mamba, with a highly optimized hardware-aware operator, adopting both spatial continuity and computational efficiency. We validate the versatility of our approach on both WSIs and natural images. Extensive experiments on 10 public datasets for WSI classification and survival analysis show that 2DMamba~improves up to $2.48\\%$ in AUC, $3.11\\%$ in F1 score, $2.47\\%$ in accuracy and $5.52\\%$ in C-index. Additionally, integrating our method with VMamba for natural imaging yields $0.5$ to $0.7$ improvements in mIoU on the ADE20k semantic segmentation dataset, and $0.2\\%$ accuracy improvement on ImageNet-1K classification dataset. Our code is available at https://github.com/AtlasAnalyticsLab/2DMamba.","url_abs":"https://arxiv.org/abs/2412.00678v1","url_pdf":"https://arxiv.org/pdf/2412.00678v1.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":"2dmamba-efficient-state-space-model-for-image","repo_url":"https://github.com/atlasanalyticslab/2dmamba","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"computational-efficiency","task_name":"Computational Efficiency"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"mamba","task_name":"Mamba"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"},{"task_slug":"survival-analysis","task_name":"Survival Analysis"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[{"method_slug":"mamba","method_name":"Mamba"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2412.00678","atlas_url":"https://app.syntology.ai/?focus=2412.00678","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2412.00678"}},"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/atlasanalyticslab/2dmamba","reach":{"status":"ok"}}],"summary":{"ran_violates":1,"unverified":7},"by_repo_kind":{"official":{"samples":8,"ran":1,"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":8,"samples":[{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/TransMIL.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/TransMIL.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"1aa879b87d59c39f","entry":"moore_penrose_iter_pinv","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/TransMIL.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/TransMIL.py","link_basis":"plan_row","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":"1aa879b87d59c39f"}},{"code_sha256_prefix":"d547c23b7746ffe5","entry":"npo2","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/pscan.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/pscan.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":"d547c23b7746ffe5"}},{"code_sha256_prefix":"8213e85fd713879a","entry":"pad_npo2","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/pscan.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/pscan.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":"8213e85fd713879a"}},{"code_sha256_prefix":"e34dee3e172aa021","entry":"pad_npo2_2d","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/pscan.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/pscan.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":"e34dee3e172aa021"}},{"code_sha256_prefix":"ebd6ae95c07e0b1a","entry":"reconstruct_2d_wsi","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/mamba_simple.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/mamba_simple.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":"ebd6ae95c07e0b1a"}},{"code_sha256_prefix":"5cdb591dfde1dab6","entry":"selective_scan_fn","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/pscan_2d.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/pscan_2d.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":"5cdb591dfde1dab6"}},{"code_sha256_prefix":"b50794ffb06b95c0","entry":"split_tensor","repo":"atlasanalyticslab/2dmamba","repo_kind":"official","path":"2DMambaMIL/models/MambaMIL_2D.py","file_url":"https://github.com/atlasanalyticslab/2dmamba/blob/HEAD/2DMambaMIL/models/MambaMIL_2D.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":"b50794ffb06b95c0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}