{"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/segment-anything-in-medical-images","title":"Segment Anything in Medical Images","arxiv_id":"2304.12306","date":"2023-04-24","proceeding":null,"authors":["Jun Ma","Yuting He","Feifei Li","Lin Han","Chenyu You","Bo wang"],"abstract":"Medical image segmentation is a critical component in clinical practice, facilitating accurate diagnosis, treatment planning, and disease monitoring. However, existing methods, often tailored to specific modalities or disease types, lack generalizability across the diverse spectrum of medical image segmentation tasks. Here we present MedSAM, a foundation model designed for bridging this gap by enabling universal medical image segmentation. The model is developed on a large-scale medical image dataset with 1,570,263 image-mask pairs, covering 10 imaging modalities and over 30 cancer types. We conduct a comprehensive evaluation on 86 internal validation tasks and 60 external validation tasks, demonstrating better accuracy and robustness than modality-wise specialist models. By delivering accurate and efficient segmentation across a wide spectrum of tasks, MedSAM holds significant potential to expedite the evolution of diagnostic tools and the personalization of treatment plans.","url_abs":"https://arxiv.org/abs/2304.12306v3","url_pdf":"https://arxiv.org/pdf/2304.12306v3.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":"segment-anything-in-medical-images","repo_url":"https://github.com/bowang-lab/medsam","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"segment-anything-in-medical-images","repo_url":"https://github.com/sqhuang0103/samreg","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"segment-anything-in-medical-images","repo_url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"diagnostic","task_name":"Diagnostic"},{"task_slug":"image-segmentation","task_name":"Image Segmentation"},{"task_slug":"medical-image-segmentation","task_name":"Medical Image Segmentation"},{"task_slug":"segmentation","task_name":"Segmentation"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2304.12306","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2304.12306"}},"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/bowang-lab/medsam","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/sqhuang0103/samreg","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images","reach":null}],"summary":{"ran_honours":1,"ran_draft_wrong":1,"ran_violates":1,"ran_fixture":3,"unverified":8},"by_repo_kind":{"official":{"samples":9,"ran":2,"repositories":1},"listed":{"samples":4,"ran":3,"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":5,"samples":[{"code_sha256_prefix":"f55c31d782e48ffb","entry":"collate_fn","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"f55c31d782e48ffb"}},{"code_sha256_prefix":"98f85b51aaf3c040","entry":"dice_coefficient","repo":"yuhoo0302/segment-anything-model-for-medical-images","repo_kind":"listed","path":"train_only_box.py","file_url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images/blob/HEAD/train_only_box.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"98f85b51aaf3c040"}},{"code_sha256_prefix":"c4ecf5b56b1a1f02","entry":"dice_coefficient","repo":"yuhoo0302/segment-anything-model-for-medical-images","repo_kind":"listed","path":"test_only_box.py","file_url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images/blob/HEAD/test_only_box.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4ecf5b56b1a1f02"}},{"code_sha256_prefix":"733d7f0bedcb74c2","entry":"get_rel_pos","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/modeling/image_encoder.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/modeling/image_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"733d7f0bedcb74c2"}},{"code_sha256_prefix":"d73df93071fdcccc","entry":"limit_rect","repo":"yuhoo0302/segment-anything-model-for-medical-images","repo_kind":"listed","path":"test_only_box.py","file_url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images/blob/HEAD/test_only_box.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d73df93071fdcccc"}},{"code_sha256_prefix":"105fa08885dc36cc","entry":"window_partition","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/modeling/image_encoder.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/modeling/image_encoder.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"105fa08885dc36cc"}},{"code_sha256_prefix":"29f9549a51637994","entry":"build_sam_vit_b","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/build_sam.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/build_sam.py","link_basis":"first_harvest_node","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":"29f9549a51637994"}},{"code_sha256_prefix":"5be47294e439b183","entry":"build_sam_vit_h","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/build_sam.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/build_sam.py","link_basis":"first_harvest_node","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":"5be47294e439b183"}},{"code_sha256_prefix":"07aaa957cb49eba1","entry":"build_sam_vit_l","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/build_sam.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/build_sam.py","link_basis":"first_harvest_node","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":"07aaa957cb49eba1"}},{"code_sha256_prefix":"0793e0bfc7283cba","entry":"dice_coefficient","repo":"bowang-lab/medsam","repo_kind":"official","path":"comparisons/nnU-Net/infer_nnunet_2D.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/comparisons/nnU-Net/infer_nnunet_2D.py","link_basis":"first_harvest_node","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":"0793e0bfc7283cba"}},{"code_sha256_prefix":"1a7d041e8f7f901e","entry":"getLargestCC","repo":"bowang-lab/medsam","repo_kind":"official","path":"extensions/seg_3dnii_sparse_marker/medsam_infer_3Dbox_adrenal.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/extensions/seg_3dnii_sparse_marker/medsam_infer_3Dbox_adrenal.py","link_basis":"first_harvest_node","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":"1a7d041e8f7f901e"}},{"code_sha256_prefix":"51f06686c44f5a62","entry":"get_bbox","repo":"bowang-lab/medsam","repo_kind":"official","path":"extensions/seg_3dnii_sparse_marker/medsam_infer_3Dbox_adrenal.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/extensions/seg_3dnii_sparse_marker/medsam_infer_3Dbox_adrenal.py","link_basis":"first_harvest_node","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":"51f06686c44f5a62"}},{"code_sha256_prefix":"35808dce17a4103f","entry":"train_sam","repo":"yuhoo0302/segment-anything-model-for-medical-images","repo_kind":"listed","path":"train_only_box.py","file_url":"https://github.com/yuhoo0302/segment-anything-model-for-medical-images/blob/HEAD/train_only_box.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":"35808dce17a4103f"}},{"code_sha256_prefix":"27be441cc8213e52","entry":"window_unpartition","repo":"bowang-lab/medsam","repo_kind":"official","path":"segment_anything/modeling/image_encoder.py","file_url":"https://github.com/bowang-lab/medsam/blob/HEAD/segment_anything/modeling/image_encoder.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":"27be441cc8213e52"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}