{"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-model-for-road-network-graph","title":"Segment Anything Model for Road Network Graph Extraction","arxiv_id":"2403.16051","date":"2024-03-24","proceeding":null,"authors":["Congrui Hetang","Haoru Xue","Cindy Le","Tianwei Yue","Wenping Wang","Yihui He"],"abstract":"We propose SAM-Road, an adaptation of the Segment Anything Model (SAM) for extracting large-scale, vectorized road network graphs from satellite imagery. To predict graph geometry, we formulate it as a dense semantic segmentation task, leveraging the inherent strengths of SAM. The image encoder of SAM is fine-tuned to produce probability masks for roads and intersections, from which the graph vertices are extracted via simple non-maximum suppression. To predict graph topology, we designed a lightweight transformer-based graph neural network, which leverages the SAM image embeddings to estimate the edge existence probabilities between vertices. Our approach directly predicts the graph vertices and edges for large regions without expensive and complex post-processing heuristics, and is capable of building complete road network graphs spanning multiple square kilometers in a matter of seconds. With its simple, straightforward, and minimalist design, SAM-Road achieves comparable accuracy with the state-of-the-art method RNGDet++, while being 40 times faster on the City-scale dataset. We thus demonstrate the power of a foundational vision model when applied to a graph learning task. The code is available at https://github.com/htcr/sam_road.","url_abs":"https://arxiv.org/abs/2403.16051v3","url_pdf":"https://arxiv.org/pdf/2403.16051v3.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-model-for-road-network-graph","repo_url":"https://github.com/htcr/sam_road","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"graph-learning","task_name":"Graph Learning"},{"task_slug":"graph-neural-network","task_name":"Graph Neural Network"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"}],"methods":[{"method_slug":"sam","method_name":"SAM"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2403.16051","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.16051"}},"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/htcr/sam_road","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":17,"unverified":1},"by_repo_kind":{"official":{"samples":18,"ran":17,"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":"eace594ace06c68f","entry":"create_output_dir_and_save_config","repo":"htcr/sam_road","repo_kind":"official","path":"utils.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"eace594ace06c68f"}},{"code_sha256_prefix":"9847c4aa680f7f58","entry":"crop_img_patch","repo":"htcr/sam_road","repo_kind":"official","path":"inferencer.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/inferencer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9847c4aa680f7f58"}},{"code_sha256_prefix":"62990ee83bc6c9e9","entry":"draw_line_segments_on_image","repo":"htcr/sam_road","repo_kind":"official","path":"spacenet/generate_labels.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/spacenet/generate_labels.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"62990ee83bc6c9e9"}},{"code_sha256_prefix":"2f135d04199d9188","entry":"draw_points_on_image","repo":"htcr/sam_road","repo_kind":"official","path":"graph_extraction.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/graph_extraction.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2f135d04199d9188"}},{"code_sha256_prefix":"998429d0ff5eb4a1","entry":"draw_points_on_image","repo":"htcr/sam_road","repo_kind":"official","path":"spacenet/generate_labels.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/spacenet/generate_labels.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"998429d0ff5eb4a1"}},{"code_sha256_prefix":"43d91f90853adbd0","entry":"edge_list_to_adj_table","repo":"htcr/sam_road","repo_kind":"official","path":"graph_utils.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/graph_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"43d91f90853adbd0"}},{"code_sha256_prefix":"0bf072401f5943d4","entry":"edge_list_to_adj_table","repo":"htcr/sam_road","repo_kind":"official","path":"graph_utils.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/graph_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0bf072401f5943d4"}},{"code_sha256_prefix":"68ccab6be670bfc4","entry":"filter_nodes","repo":"htcr/sam_road","repo_kind":"official","path":"graph_utils.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/graph_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"68ccab6be670bfc4"}},{"code_sha256_prefix":"53810f783e40cd12","entry":"get_img_paths","repo":"htcr/sam_road","repo_kind":"official","path":"inferencer.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/inferencer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"53810f783e40cd12"}},{"code_sha256_prefix":"e65200eaf5162974","entry":"get_patch_info_one_img","repo":"htcr/sam_road","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/dataset.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e65200eaf5162974"}},{"code_sha256_prefix":"dff7a9d2d4290664","entry":"get_points_and_scores_from_mask","repo":"htcr/sam_road","repo_kind":"official","path":"graph_extraction.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/graph_extraction.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dff7a9d2d4290664"}},{"code_sha256_prefix":"49fc6bdb42872104","entry":"graph_collate_fn","repo":"htcr/sam_road","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/dataset.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"49fc6bdb42872104"}},{"code_sha256_prefix":"c4b20ca211d254a0","entry":"rasterize_graph","repo":"htcr/sam_road","repo_kind":"official","path":"triage.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/triage.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c4b20ca211d254a0"}},{"code_sha256_prefix":"787e3dce7cf3f6a1","entry":"read_rgb_img","repo":"htcr/sam_road","repo_kind":"official","path":"dataset.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/dataset.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"787e3dce7cf3f6a1"}},{"code_sha256_prefix":"acad5f61c59c85f5","entry":"visualize_image_and_graph","repo":"htcr/sam_road","repo_kind":"official","path":"triage.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/triage.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"acad5f61c59c85f5"}},{"code_sha256_prefix":"b7d7f725d4dc325c","entry":"visualize_pred_gt_pair","repo":"htcr/sam_road","repo_kind":"official","path":"triage.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/triage.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b7d7f725d4dc325c"}},{"code_sha256_prefix":"0b3109c04bded2ae","entry":"within_margin","repo":"htcr/sam_road","repo_kind":"official","path":"spacenet_metrics/spacenet_convert.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/spacenet_metrics/spacenet_convert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0b3109c04bded2ae"}},{"code_sha256_prefix":"9666fa4a61dfac77","entry":"get_batch_img_patches","repo":"htcr/sam_road","repo_kind":"official","path":"inferencer.py","file_url":"https://github.com/htcr/sam_road/blob/HEAD/inferencer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9666fa4a61dfac77"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}