api-server
Guides segment-geospatial's FastAPI service, samgeo-api CLI, segmentation endpoints, model/cache behavior, output formats, and safe API smoke checks.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- api-server
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides segment-geospatial's FastAPI service, samgeo-api CLI, segmentation endpoints, model/cache behavior, output formats, and safe API smoke checks.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md3.6 KB
- 参考文档references/troubleshooting.md2.1 KB
- 参考文档references/workflows.md2.2 KB
- 脚本scripts/api_smoke.py2.1 KB
03 SKILL.md 正文
SamGeo REST API server
Use this sub-skill when the task is about serving SamGeo segmentation over HTTP,
using the samgeo-api command, sending curl/Python client requests, validating
endpoint parameters, or debugging API model/image caches.
Read this when
- The user asks for
samgeo-api,uvicorn samgeo.api:app, FastAPI docs, or Swagger UI. - The task calls
GET /health,GET /models,DELETE /models,POST /segment/automatic,POST /segment/predict, orPOST /segment/text. - The user needs
output_format=geojson|geotiff|png|json|detections. - A request fails with invalid model ids, missing prompt parameters, bad output format, cache problems, or GPU memory retention.
Route elsewhere
- Direct Python class usage: core-segmentation or samgeo3-workflows.
- CRS/raster/vector prep before an API upload: geospatial-utilities.
- Optional model wrapper details: specialized-models.
API operating sequence
- Install
segment-geospatial[api]plus the model extra needed by requests. For SAM3 text endpoints, include[samgeo3]and verify CUDA/model access. - Run the safe smoke script before starting a service:
python scripts/api_smoke.py --local-testclient. - Start the service only when a listener is wanted:
samgeo-api --host 0.0.0.0 --port 8000. - Use
GET /modelsto inspect available and loaded models. - Use
DELETE /modelsto clear model cache and free GPU memory after large jobs.
References and scripts
- api-reference.md lists endpoints, parameters, model ids, output formats, and cache behavior.
- workflows.md gives server start, curl, and Python client examples.
- troubleshooting.md covers common API errors and cache/GPU recovery.
- scripts/api_smoke.py probes either the local FastAPI TestClient or a running server without loading model weights.
Native validation candidates
tests/test_api.py is a strong native candidate because it uses mocks for model
loads while validating endpoint errors, model registry exposure, output format
checks, SAM3 point prompt dispatch, and cache-key behavior.
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).