core-segmentation
Routes SamGeo SAM1 and SAM2 geospatial segmentation workflows including automatic masks, point and box prompts, batch or video prediction, and raster/vector outputs.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- core-segmentation
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Routes SamGeo SAM1 and SAM2 geospatial segmentation workflows including automatic masks, point and box prompts, batch or video prediction, and raster/vector outputs.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md4.4 KB
- 参考文档references/troubleshooting.md2.2 KB
- 参考文档references/workflows.md3.6 KB
- 脚本scripts/core_smoke.py1.9 KB
03 SKILL.md 正文
Core segmentation with SamGeo and SamGeo2
Use this sub-skill for original SAM and SAM2 package workflows: GeoTIFF or image segmentation, automatic mask generation, prompt-based masks, SAM2 batches or videos, and converting masks to geospatial vectors.
Read this when
- The user names
SamGeo,samgeo.SamGeo,samgeo.samgeo.SamGeo, SAM1,vit_h,vit_l, orvit_b. - The user names
SamGeo2, SAM2,sam2-hiera-*, SAM2 video prediction, or batch prompt prediction. - The task starts with an existing GeoTIFF, PNG/JPEG, map tile bounding box, or vector prompt file and needs masks or vector outputs.
- The user is confused about
point_crs, band selection, foreground/unique masks, or when to callset_image()beforepredict().
Route elsewhere
- SAM3/SAM3.1 text, tiled, instance, or video tracking workflows: read samgeo3-workflows.
- Mostly CRS/raster/vector helper work without model inference: read geospatial-utilities.
- FastSAM, HQ-SAM, LangSAM, captioning, detectree2, or FER notes: read specialized-models.
- HTTP serving or curl requests: read api-server.
Core decision sequence
- Verify the environment with the root
scripts/check_install.py; include--require-cudaif the user expects GPU inference. - Decide
SamGeovsSamGeo2:SamGeo: original SAM checkpoints (vit_h,vit_l,vit_b), simple automatic or prompt workflows.SamGeo2: SAM2 Hiera model ids, batch prompt prediction, video workflows, or newer SAM2 mask generation.
- Prepare imagery and prompts. For GeoTIFFs, inspect CRS and bands first. For
multi-band imagery, pass
bands=[r, g, b]when reading or setting images. - For automatic masks, construct the model with
automatic=Trueand callgenerate(source, output=...). - For prompt masks, construct with
automatic=False, callset_image(...), thenpredict(...)with points, boxes, labels, and optional CRS parameters. - Convert or validate outputs with
tiff_to_gpkg,tiff_to_geojson, or the utilities sub-skill after masks are written.
References and scripts
- workflows.md has step-by-step SAM1/SAM2 recipes, including automatic masks, prompts, video, outputs, and validation steps.
- api-reference.md records verified signatures, model ids, and key parameter meanings.
- troubleshooting.md covers checkpoint, coordinate, CRS, empty-mask, and SAM2 dependency failures.
- scripts/core_smoke.py safely imports
SamGeoandSamGeo2, prints method signatures, and reports device availability without downloading model weights.
Native validation candidates
Use these after full skill integration, not during planning:
tests/test_samgeo3.pybelongs to the SAM3 sub-skill, not here.tests/test_common.pylocal raster/image-prep cases validate shared helpers used by this sub-skill.tests/test_samgeo.pyis realistic evidence for SAM1 automatic/prompt masks but downloads map tiles and needs model checkpoints; run only if network and model assets are explicitly authorized.
Output expectations
- Mask raster outputs should exist at the requested path and preserve geospatial metadata when the source is georeferenced.
- Vector outputs should be valid GPKG, Shapefile, or GeoJSON. Empty masks should become valid empty vector layers rather than crashes.
- Prompt outputs should be checked visually or by mask statistics before running simplification, smoothing, or large batch/vector conversion.
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).