{"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/sam2-unet-segment-anything-2-makes-strong","title":"SAM2-UNet: Segment Anything 2 Makes Strong Encoder for Natural and Medical Image Segmentation","arxiv_id":"2408.08870","date":"2024-08-16","proceeding":null,"authors":["Xinyu Xiong","Zihuang Wu","Shuangyi Tan","Wenxue Li","Feilong Tang","Ying Chen","Siying Li","Jie Ma","Guanbin Li"],"abstract":"Image segmentation plays an important role in vision understanding. Recently, the emerging vision foundation models continuously achieved superior performance on various tasks. Following such success, in this paper, we prove that the Segment Anything Model 2 (SAM2) can be a strong encoder for U-shaped segmentation models. We propose a simple but effective framework, termed SAM2-UNet, for versatile image segmentation. Specifically, SAM2-UNet adopts the Hiera backbone of SAM2 as the encoder, while the decoder uses the classic U-shaped design. Additionally, adapters are inserted into the encoder to allow parameter-efficient fine-tuning. Preliminary experiments on various downstream tasks, such as camouflaged object detection, salient object detection, marine animal segmentation, mirror detection, and polyp segmentation, demonstrate that our SAM2-UNet can simply beat existing specialized state-of-the-art methods without bells and whistles. Project page: \\url{https://github.com/WZH0120/SAM2-UNet}.","url_abs":"https://arxiv.org/abs/2408.08870v1","url_pdf":"https://arxiv.org/pdf/2408.08870v1.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":"sam2-unet-segment-anything-2-makes-strong","repo_url":"https://github.com/wzh0120/sam2-unet","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"image-segmentation","task_name":"Image Segmentation"},{"task_slug":"marine-animal-segmentation","task_name":"Marine Animal Segmentation"},{"task_slug":"medical-image-segmentation","task_name":"Medical Image Segmentation"},{"task_slug":"mirror-detection","task_name":"Mirror Detection"},{"task_slug":"salient-object-detection-1","task_name":"Salient Object Detection"},{"task_slug":"segmentation","task_name":"Segmentation"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"},{"task_slug":"parameter-efficient-fine-tuning","task_name":"parameter-efficient fine-tuning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/image-segmentation-on-mas3k","task":"Image Segmentation","dataset":"MAS3K","model":"SAM2-UNet","rank_in_archive_order":1,"of":4,"metrics":{"E-measure":"0.943","MAE":"0.021","S-measure":"0.903","mIoU":"0.799"},"uses_additional_data":false},{"leaderboard":"/sota/image-segmentation-on-msd-mirror-segmentation","task":"Image Segmentation","dataset":"MSD (Mirror Segmentation Dataset)","model":"SAM2-UNet","rank_in_archive_order":1,"of":5,"metrics":{"F-measure":"0.957","IoU":"0.918","MAE":"0.022"},"uses_additional_data":false},{"leaderboard":"/sota/image-segmentation-on-pmd","task":"Image Segmentation","dataset":"PMD","model":"SAM2-UNet","rank_in_archive_order":1,"of":5,"metrics":{"F-measure":"0.826","IoU":"0.728","MAE":"0.027"},"uses_additional_data":false},{"leaderboard":"/sota/image-segmentation-on-rmas","task":"Image Segmentation","dataset":"RMAS","model":"SAM2-UNet","rank_in_archive_order":2,"of":4,"metrics":{"E-measure":"0.944","MAE":"0.022","S-measure":"0.874","mIoU":"0.738"},"uses_additional_data":false},{"leaderboard":"/sota/salient-object-detection-on-dut-omron-2","task":"Salient Object Detection","dataset":"DUT-OMRON","model":"SAM2-UNet","rank_in_archive_order":1,"of":8,"metrics":{"E-measure":"0.912","MAE":"0.039","S-measure":"0.884"},"uses_additional_data":false},{"leaderboard":"/sota/salient-object-detection-on-duts-te-1","task":"Salient Object Detection","dataset":"DUTS-TE","model":"SAM2-UNet","rank_in_archive_order":1,"of":8,"metrics":{"E-measure":" 0.959","MAE":"0.020","Smeasure":"0.934"},"uses_additional_data":false},{"leaderboard":"/sota/salient-object-detection-on-ecssd-1","task":"Salient Object Detection","dataset":"ECSSD","model":"SAM2-UNet","rank_in_archive_order":1,"of":10,"metrics":{"E-measure":"0.970","MAE":"0.020","S-measure":"0.950"},"uses_additional_data":false},{"leaderboard":"/sota/salient-object-detection-on-hku-is-1","task":"Salient Object Detection","dataset":"HKU-IS","model":"SAM2-UNet","rank_in_archive_order":1,"of":9,"metrics":{"E-measure":"0.971","MAE":"0.019","S-measure":"0.941"},"uses_additional_data":false},{"leaderboard":"/sota/salient-object-detection-on-pascal-s-1","task":"Salient Object Detection","dataset":"PASCAL-S","model":"SAM2-UNet","rank_in_archive_order":2,"of":10,"metrics":{"E-measure":"0.931","MAE":"0.043","S-measure":"0.894"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2408.08870","atlas_url":"https://app.syntology.ai/?focus=2408.08870","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2408.08870"}},"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/wzh0120/sam2-unet","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_violates":1,"ran_draft_wrong":2,"ran_honours":1,"ran_fixture":1,"unverified":4},"by_repo_kind":{"official":{"samples":9,"ran":5,"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":0,"samples":[{"code_sha256_prefix":"7ceaad42da42edd5","entry":"compute_axial_cis","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/position_encoding.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/position_encoding.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7ceaad42da42edd5"}},{"code_sha256_prefix":"a6c3974188a5ffb0","entry":"get_1d_sine_pe","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/sam2_utils.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/sam2_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a6c3974188a5ffb0"}},{"code_sha256_prefix":"bb060d29525f90eb","entry":"init_t_xy","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/position_encoding.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/position_encoding.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bb060d29525f90eb"}},{"code_sha256_prefix":"f8f09f78b474ee7c","entry":"reshape_for_broadcast","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/position_encoding.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/position_encoding.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f8f09f78b474ee7c"}},{"code_sha256_prefix":"4ee20f090e58c425","entry":"select_closest_cond_frames","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/sam2_utils.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/sam2_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4ee20f090e58c425"}},{"code_sha256_prefix":"31a4fffe09fed1c5","entry":"build_sam2","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/build_sam.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/build_sam.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"31a4fffe09fed1c5"}},{"code_sha256_prefix":"6cd9b91468681cef","entry":"build_sam2_video_predictor","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/build_sam.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/build_sam.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6cd9b91468681cef"}},{"code_sha256_prefix":"d3df9ada3e05fa55","entry":"do_pool","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/backbones/hieradet.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/backbones/hieradet.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d3df9ada3e05fa55"}},{"code_sha256_prefix":"f2e72d81f39d65cd","entry":"get_activation_fn","repo":"wzh0120/sam2-unet","repo_kind":"official","path":"sam2/modeling/sam2_utils.py","file_url":"https://github.com/wzh0120/sam2-unet/blob/HEAD/sam2/modeling/sam2_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f2e72d81f39d65cd"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}