segment-geospatial
Guides segment-geospatial/SamGeo workflows for geospatial SAM segmentation, SAM2/SAM3 model variants, REST API serving, raster/vector IO, and optional text or caption model integrations.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- segment-geospatial
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides segment-geospatial/SamGeo workflows for geospatial SAM segmentation, SAM2/SAM3 model variants, REST API serving, raster/vector IO, and optional text or caption model integrations.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/installation-and-dependencies.md5.3 KB
- 参考文档references/model-and-workflow-overview.md5.0 KB
- 参考文档references/repo-provenance.md2.3 KB
- 参考文档references/repo-routing-metadata.json508 B
- 参考文档references/troubleshooting.md5.9 KB
- 脚本scripts/check_install.py5.8 KB
03 SKILL.md 正文
segment-geospatial (SamGeo)
Use this repo skill when a task involves the segment-geospatial package, the
samgeo Python import, or geospatial image segmentation with SAM-family models.
It is self-contained operating guidance distilled from package code, docs,
examples, tests, and installed-package inspection for version 1.4.1.
First choose the route
| User task | Read |
|---|---|
| Segment a GeoTIFF or image with SAM1/SAM2, automatic masks, point prompts, box prompts, or SAM2 video | core-segmentation |
| Use SAM3/SAM3.1, text prompts, point/box instance prompts, tiled large-image segmentation, batch images, or SAM3 video tracking | samgeo3-workflows |
| Download map tiles, handle CRS, prepare multi-band imagery, convert raster masks to vectors, split/merge rasters, inspect raster metadata, or use UTM helpers | geospatial-utilities |
| Use FastSAM, HQ-SAM, LangSAM/GroundingDINO text prompts, BLIP image captioning, or optional detectree2/FER notes | specialized-models |
Serve segmentation over HTTP, call samgeo-api, validate API parameters, handle output formats, or troubleshoot model/image caches |
api-server |
Read model-and-workflow-overview.md for the package map and installation-and-dependencies.md before choosing extras or CUDA packages. Read troubleshooting.md for cross-cutting install, GPU, model-download, CRS, and optional-dependency failures.
Minimal install and import checks
Use a fresh environment. Python 3.10-3.12 is exercised by the repository CI; Python 3.11 is a safe default for ML/geospatial dependencies.
pip install "segment-geospatial[samgeo2,samgeo3,fast,hq,text,api]"
python - <<'PY'
import samgeo
from samgeo.model_registry import AVAILABLE_MODELS
print(samgeo.__version__)
print(AVAILABLE_MODELS)
PY
For SAM3 runtime work, verify CUDA before promising a run:
import torch
print(torch.__version__, torch.version.cuda)
print(torch.cuda.is_available(), torch.cuda.device_count())
Run the bundled safe diagnostic when an environment looks questionable:
python scripts/check_install.py --check-optional
python scripts/check_install.py --require-cuda
The scripts only import modules and inspect lightweight API state; they do not download model weights or start a service.
Package entry points and outputs
- Python import:
samgeo. - Distribution:
segment-geospatial. - CLI entry point:
samgeo-apifor the FastAPI service. - Main classes:
SamGeo,SamGeo2,SamGeo3,SamGeo3Video,LangSAM, FastSAM/HQ-SAM wrappers, andImageCaptioner. - Typical inputs: GeoTIFF, PNG/JPEG, NumPy arrays, URLs, point coordinates, bounding boxes, GeoJSON/vector prompts, and videos/time-series frames.
- Typical outputs: mask GeoTIFF/PNG, vector GeoPackage/Shapefile/GeoJSON, JSON/detections from the API, caption/feature lists, and blended videos.
Operating rules
- Do not tell users to open notebooks, scripts, tests, or docs from the original checkout. Use the bundled references and scripts in this skill.
- Distinguish pixel coordinates from geographic coordinates. If points or boxes
are in a CRS, pass
point_crsorbox_crswhere the selected API supports it. - SamGeo preserves the source raster CRS during segmentation; it does not automatically reproject masks to EPSG:4326.
- SAM3/SAM3.1 guidance should be treated as CUDA-backed unless the task is only inspecting imports or mock-backed tests. CPU import checks are not proof of real SAM3 runtime capability.
- Model-weight downloads, Hugging Face authentication, map-tile downloads, long-running inference, notebooks, QGIS plugin operations, and detectree2 or GDAL-specific paths require explicit user/environment readiness.
- The user requested
not importfor this generated skill run; do not run the repo-skill import helper unless a later instruction explicitly approves it.
Provenance and refresh
Read repo-provenance.md before deciding this skill matches a new checkout. If the commit, package version, public APIs, or major example/test paths differ, refresh the skill before relying on stale routing or API details.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).