{"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/text4seg-reimagining-image-segmentation-as","title":"Text4Seg: Reimagining Image Segmentation as Text Generation","arxiv_id":"2410.09855","date":"2024-10-13","proceeding":null,"authors":["Mengcheng Lan","Chaofeng Chen","Yue Zhou","Jiaxing Xu","Yiping Ke","Xinjiang Wang","Litong Feng","Wayne Zhang"],"abstract":"Multimodal Large Language Models (MLLMs) have shown exceptional capabilities in vision-language tasks; however, effectively integrating image segmentation into these models remains a significant challenge. In this paper, we introduce Text4Seg, a novel text-as-mask paradigm that casts image segmentation as a text generation problem, eliminating the need for additional decoders and significantly simplifying the segmentation process. Our key innovation is semantic descriptors, a new textual representation of segmentation masks where each image patch is mapped to its corresponding text label. This unified representation allows seamless integration into the auto-regressive training pipeline of MLLMs for easier optimization. We demonstrate that representing an image with $16\\times16$ semantic descriptors yields competitive segmentation performance. To enhance efficiency, we introduce the Row-wise Run-Length Encoding (R-RLE), which compresses redundant text sequences, reducing the length of semantic descriptors by 74% and accelerating inference by $3\\times$, without compromising performance. Extensive experiments across various vision tasks, such as referring expression segmentation and comprehension, show that Text4Seg achieves state-of-the-art performance on multiple datasets by fine-tuning different MLLM backbones. Our approach provides an efficient, scalable solution for vision-centric tasks within the MLLM framework.","url_abs":"https://arxiv.org/abs/2410.09855v1","url_pdf":"https://arxiv.org/pdf/2410.09855v1.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":"text4seg-reimagining-image-segmentation-as","repo_url":"https://github.com/mc-lan/text4seg","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}}],"tasks":[{"task_slug":"image-segmentation","task_name":"Image Segmentation"},{"task_slug":"referring-expression","task_name":"Referring Expression"},{"task_slug":"referring-expression-segmentation","task_name":"Referring Expression Segmentation"},{"task_slug":"segmentation","task_name":"Segmentation"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"},{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.09855","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.09855"}},"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":"deterministic:regex_extraction","url":"https://github.com/mc-lan/Text4Seg","reach":{"status":"ok","spdx":"NOASSERTION"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mc-lan/text4seg","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"ran":4,"ran_draft_wrong":1,"ran_fixture":2,"unverified":5},"by_repo_kind":{"official":{"samples":12,"ran":7,"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":12,"samples":[{"code_sha256_prefix":"de467f8ba53ec4a4","entry":"collate_fn","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/infer_refer_seg.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/infer_refer_seg.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"de467f8ba53ec4a4"}},{"code_sha256_prefix":"e5321304736f43a1","entry":"decode_mask","repo":"mc-lan/text4seg","repo_kind":"official","path":"llava/eval/utils.py","file_url":"https://github.com/mc-lan/text4seg/blob/HEAD/llava/eval/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"e5321304736f43a1"}},{"code_sha256_prefix":"6a0145687dd13bee","entry":"decode_mask_s","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/utils.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"6a0145687dd13bee"}},{"code_sha256_prefix":"fec9d7679b542a15","entry":"get_chunk","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/infer_refer_seg.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/infer_refer_seg.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"fec9d7679b542a15"}},{"code_sha256_prefix":"733d7f0bedcb74c2","entry":"get_rel_pos","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"733d7f0bedcb74c2"}},{"code_sha256_prefix":"18d30ac60d5a69d2","entry":"translate_sequence","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/utils.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"18d30ac60d5a69d2"}},{"code_sha256_prefix":"105fa08885dc36cc","entry":"window_partition","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"105fa08885dc36cc"}},{"code_sha256_prefix":"f9bc5f31ce61cee8","entry":"build_sam_vit_b","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/build_sam.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/segment_anything/build_sam.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":"f9bc5f31ce61cee8"}},{"code_sha256_prefix":"6b77c1f11fff3ed6","entry":"build_sam_vit_h","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/build_sam.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/segment_anything/build_sam.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":"6b77c1f11fff3ed6"}},{"code_sha256_prefix":"3f8890e695469246","entry":"build_sam_vit_l","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/build_sam.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/segment_anything/build_sam.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":"3f8890e695469246"}},{"code_sha256_prefix":"2a5e65f48eefb34b","entry":"gget_chunk","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/infer_refer_seg.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/infer_refer_seg.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NOASSERTION","inline_ok":false,"mcp_get_code":{"code_sha256":"2a5e65f48eefb34b"}},{"code_sha256_prefix":"27be441cc8213e52","entry":"window_unpartition","repo":"mc-lan/Text4Seg","repo_kind":"official","path":"ms-swift/text4seg/segment_anything/modeling/image_encoder.py","file_url":"https://github.com/mc-lan/Text4Seg/blob/HEAD/ms-swift/text4seg/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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"27be441cc8213e52"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}