{"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/hi-sam-marrying-segment-anything-model-for","title":"Hi-SAM: Marrying Segment Anything Model for Hierarchical Text Segmentation","arxiv_id":"2401.17904","date":"2024-01-31","proceeding":null,"authors":["Maoyuan Ye","Jing Zhang","Juhua Liu","Chenyu Liu","BaoCai Yin","Cong Liu","Bo Du","DaCheng Tao"],"abstract":"The Segment Anything Model (SAM), a profound vision foundation model pretrained on a large-scale dataset, breaks the boundaries of general segmentation and sparks various downstream applications. This paper introduces Hi-SAM, a unified model leveraging SAM for hierarchical text segmentation. Hi-SAM excels in segmentation across four hierarchies, including pixel-level text, word, text-line, and paragraph, while realizing layout analysis as well. Specifically, we first turn SAM into a high-quality pixel-level text segmentation (TS) model through a parameter-efficient fine-tuning approach. We use this TS model to iteratively generate the pixel-level text labels in a semi-automatical manner, unifying labels across the four text hierarchies in the HierText dataset. Subsequently, with these complete labels, we launch the end-to-end trainable Hi-SAM based on the TS architecture with a customized hierarchical mask decoder. During inference, Hi-SAM offers both automatic mask generation (AMG) mode and promptable segmentation (PS) mode. In the AMG mode, Hi-SAM segments pixel-level text foreground masks initially, then samples foreground points for hierarchical text mask generation and achieves layout analysis in passing. As for the PS mode, Hi-SAM provides word, text-line, and paragraph masks with a single point click. Experimental results show the state-of-the-art performance of our TS model: 84.86% fgIOU on Total-Text and 88.96% fgIOU on TextSeg for pixel-level text segmentation. Moreover, compared to the previous specialist for joint hierarchical detection and layout analysis on HierText, Hi-SAM achieves significant improvements: 4.73% PQ and 5.39% F1 on the text-line level, 5.49% PQ and 7.39% F1 on the paragraph level layout analysis, requiring $20\\times$ fewer training epochs. The code is available at https://github.com/ymy-k/Hi-SAM.","url_abs":"https://arxiv.org/abs/2401.17904v2","url_pdf":"https://arxiv.org/pdf/2401.17904v2.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":"hi-sam-marrying-segment-anything-model-for","repo_url":"https://github.com/ymy-k/hi-sam","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"hierarchical-text-segmentation","task_name":"Hierarchical Text Segmentation"},{"task_slug":"segmentation","task_name":"Segmentation"},{"task_slug":"text-segmentation","task_name":"Text Segmentation"},{"task_slug":"parameter-efficient-fine-tuning","task_name":"parameter-efficient fine-tuning"}],"methods":[{"method_slug":"sam","method_name":"SAM"},{"method_slug":"ts","method_name":"TS"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/hierarchical-text-segmentation-on-hiertext","task":"Hierarchical Text Segmentation","dataset":"HierText","model":"Hi-SAM","rank_in_archive_order":1,"of":1,"metrics":{"F-score (average)":"81.87","F-score (para., layout)":"75.97","F-score (stroke)":"83.36","F-score (text-line)":"85.30","F-score (word)":"82.86"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2401.17904","atlas_url":"https://app.syntology.ai/?focus=2401.17904","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2401.17904"}},"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/ymy-k/hi-sam","reach":null}],"summary":{"ran_fixture":1,"ran_honours":1,"ran_draft_wrong":3},"by_repo_kind":{"official":{"samples":5,"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":"ac863e38bcbe4181","entry":"get_IandU","repo":"ymy-k/hi-sam","repo_kind":"official","path":"eval_img.py","file_url":"https://github.com/ymy-k/hi-sam/blob/HEAD/eval_img.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ac863e38bcbe4181"}},{"code_sha256_prefix":"a108999f6dc23634","entry":"label_count","repo":"ymy-k/hi-sam","repo_kind":"official","path":"eval_img.py","file_url":"https://github.com/ymy-k/hi-sam/blob/HEAD/eval_img.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a108999f6dc23634"}},{"code_sha256_prefix":"68c887d10fe2881b","entry":"patchify","repo":"ymy-k/hi-sam","repo_kind":"official","path":"demo_hisam.py","file_url":"https://github.com/ymy-k/hi-sam/blob/HEAD/demo_hisam.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"68c887d10fe2881b"}},{"code_sha256_prefix":"eea971aeaba58f89","entry":"patchify_sliding","repo":"ymy-k/hi-sam","repo_kind":"official","path":"demo_hisam.py","file_url":"https://github.com/ymy-k/hi-sam/blob/HEAD/demo_hisam.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"eea971aeaba58f89"}},{"code_sha256_prefix":"a40b0b5aea35e448","entry":"unpatchify","repo":"ymy-k/hi-sam","repo_kind":"official","path":"demo_hisam.py","file_url":"https://github.com/ymy-k/hi-sam/blob/HEAD/demo_hisam.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a40b0b5aea35e448"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}