To use SamGeo 3, install it as: pip install segment-geospatial[samgeo3] === versions === python 3.12.0 | segment-geospatial 1.4.2 | segment-anything 1.0 | torch 2.14.1+cpu | rasterio 1.5.2 | geopandas 1.2.0 | osmnx 2.1.1 device: CPU (8 threads), CUDA available: False === NAIP imagery === 2 NAIP tiles from 2023 overlap the patch, e.g. ia_m_4209359_sw_15_030_20230902_20240104 flown 02 Sep 2023 | 0.3 m | EPSG:26915 | bands: red, green, blue, near-infrared mosaic of 2 tiles; empty pixels: 0 patch: 1024 x 1024 pixels at 0.5 m = 512 x 512 m, resampled from 0.3 m; vegetated (NDVI > 0.2): 18% === OpenStreetMap buildings === 146 building footprints entirely inside the patch; area median 212 m², range 7-6,449 m² building house 121 semidetached_house 14 apartments 9 school 1 yes 1 === automatic mask generation (SAM ViT-B, CPU) === model loaded in 0.5 s: sam_vit_b_01ec64.pth, 375 MB, 94 M parameters generate(): 306 masks in 47 s vectorised to 306 polygons in sam_masks.gpkg; 34% of the patch is inside a mask area_m2 compactness rectangularity elongation ndvi count 306.00 306.00 306.00 306.00 306.00 10% 53.88 0.26 0.51 1.05 -0.10 50% 198.12 0.55 0.77 1.23 -0.01 90% 507.62 0.63 0.88 2.08 0.30 === filter: building-like segments === + 40 m² <= area <= 12,000 m² -> 284 segments left + NDVI < 0.15 (not vegetation) -> 211 segments left + rectangularity >= 0.75 -> 142 segments left + elongation <= 4 (not a road) -> 139 segments left precision: 81 of 139 kept segments match an OSM building with IoU >= 0.5 (58%) recall before filtering: 107 of 146 OSM buildings have a SAM mask with IoU >= 0.5 (73%) recall after filtering: 81 of 146 (55%); median IoU of matched buildings 0.73 recall after filtering, buildings < 100 m² (garages, sheds): 0% of 1; >= 100 m²: 56% of 145 === point prompts === set_image(): image embedding computed in 3.9 s (model load included) school roof 96 ms | 3 candidate masks: 5,698 m² (score 0.74), 1,320 m² (score 0.87), 637 m² (score 0.95) playing field 34 ms | 3 candidate masks: 55,036 m² (score 0.63), 11,163 m² (score 0.72), 5,292 m² (score 0.95) playground 33 ms | 3 candidate masks: 3,664 m² (score 0.70), 1,328 m² (score 0.90), 627 m² (score 0.62) apartment block 31 ms | 3 candidate masks: 2,237 m² (score 0.69), 1,394 m² (score 0.69), 275 m² (score 0.81) best mask for the school point written to school_point_mask.tif === box prompts from OpenStreetMap footprints === 146 box prompts in 4.0 s (28 ms per box) IoU with the OSM footprint: median 0.71, mean 0.71; >= 0.5: 99%, >= 0.75: 28% buildings median_iou area_m2 <50 1 0.19 100-300 131 0.70 300-1000 8 0.80 >1000 6 0.84 wrote 146 traced building polygons to sam_box_buildings.gpkg figures and outputs written to output/