segment-geospatial 1.2.3__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/docker-publish.yml +4 -4
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.pre-commit-config.yaml +2 -2
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/PKG-INFO +9 -2
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/README.md +2 -0
- segment_geospatial-1.3.0/docs/api.md +224 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/index.md +2 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/mkdocs.yml +2 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/pyproject.toml +12 -3
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/__init__.py +1 -1
- segment_geospatial-1.3.0/samgeo/api.py +615 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/PKG-INFO +9 -2
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/SOURCES.txt +4 -0
- segment_geospatial-1.3.0/segment_geospatial.egg-info/entry_points.txt +2 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/requires.txt +7 -1
- segment_geospatial-1.3.0/tests/test_api.py +161 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.editorconfig +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/FUNDING.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/dependabot.yaml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/docker-image.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/docs-build.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/docs.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/draft-pdf.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/macos.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/pypi.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/ubuntu.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.github/workflows/windows.yml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/.gitignore +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/CITATION.cff +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/CODE_OF_CONDUCT.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/Dockerfile +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/LICENSE +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/MANIFEST.in +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/CNAME +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/assets/README.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/assets/favicon.png +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/assets/logo.png +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/assets/logo_rect.png +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/caption.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/changelog.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/changelog_update.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/common.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/contributing.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/detectree2.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/arcgis.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/automatic_mask_generator.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/automatic_mask_generator_hq.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/box_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/data/tree_boxes.geojson +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/detectree2.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/fast_sam.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/image_captioning.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/input_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/input_prompts_hq.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/maxar_open_data.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_automatic.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_box_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_point_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_predictor.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_text_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam2_video.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_automated_segmentation.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_batch_segmentation.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_box_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_image_segmentation.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_image_segmentation_jpg.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_interactive.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_object_tracking.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_point_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_point_prompts_batch.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_tiled_segmentation.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_video_masks.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_video_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/sam3_video_segmentation.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/satellite-predictor.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/satellite.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/text_prompts.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/text_prompts_batch.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/text_swimming_pools.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/examples/tree_mapping.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/faq.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/fast_sam.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/hq_sam.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/installation.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/overrides/main.html +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/samgeo.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/samgeo2.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/samgeo3.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/text_sam.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/usage.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/workshops/AIforGood_2025.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/workshops/IPPN_2024.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/workshops/cn_workshop.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/workshops/jupytext.toml +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/docs/workshops/purdue.ipynb +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/paper/10.21105.joss.05663.pdf +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/paper/paper.bib +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/paper/paper.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/LICENSE +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/README.md +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/__init__.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/icons/icon.png +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/install_plugin.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/install_plugin.sh +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/map_tools.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/metadata.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/resources.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/samgeo_plugin.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/test_plugin.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/requirements.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/requirements_dev.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/requirements_docs.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/caption.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/common.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/detectree2.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/fast_sam.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/fer.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/hq_sam.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/samgeo.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/samgeo2.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/samgeo3.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/text_sam.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/samgeo/utmconv.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/dependency_links.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/top_level.txt +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/setup.cfg +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/tests/__init__.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/tests/test_common.py +0 -0
- {segment_geospatial-1.2.3 → segment_geospatial-1.3.0}/tests/test_samgeo.py +0 -0
|
@@ -16,13 +16,13 @@ jobs:
|
|
|
16
16
|
uses: actions/checkout@v6
|
|
17
17
|
|
|
18
18
|
- name: Log in to Docker Hub
|
|
19
|
-
uses: docker/login-action@
|
|
19
|
+
uses: docker/login-action@v4
|
|
20
20
|
with:
|
|
21
21
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
22
22
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
23
23
|
|
|
24
24
|
- name: Log in to the Container registry
|
|
25
|
-
uses: docker/login-action@
|
|
25
|
+
uses: docker/login-action@v4
|
|
26
26
|
with:
|
|
27
27
|
registry: ghcr.io
|
|
28
28
|
username: ${{ github.actor }}
|
|
@@ -30,14 +30,14 @@ jobs:
|
|
|
30
30
|
|
|
31
31
|
- name: Extract metadata (tags, labels) for Docker
|
|
32
32
|
id: meta
|
|
33
|
-
uses: docker/metadata-action@
|
|
33
|
+
uses: docker/metadata-action@v6
|
|
34
34
|
with:
|
|
35
35
|
images: |
|
|
36
36
|
giswqs/segment-geospatial
|
|
37
37
|
ghcr.io/${{ github.repository }}
|
|
38
38
|
|
|
39
39
|
- name: Build and push Docker images
|
|
40
|
-
uses: docker/build-push-action@
|
|
40
|
+
uses: docker/build-push-action@v7
|
|
41
41
|
with:
|
|
42
42
|
context: .
|
|
43
43
|
push: true
|
|
@@ -12,14 +12,14 @@ repos:
|
|
|
12
12
|
args: ["--maxkb=500"]
|
|
13
13
|
|
|
14
14
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
15
|
-
rev: v0.15.
|
|
15
|
+
rev: v0.15.6
|
|
16
16
|
hooks:
|
|
17
17
|
- id: ruff
|
|
18
18
|
types_or: [pyi, jupyter]
|
|
19
19
|
args: [--fix, --unsafe-fixes]
|
|
20
20
|
|
|
21
21
|
- repo: https://github.com/codespell-project/codespell
|
|
22
|
-
rev: v2.4.
|
|
22
|
+
rev: v2.4.2
|
|
23
23
|
hooks:
|
|
24
24
|
- id: codespell
|
|
25
25
|
args:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: segment-geospatial
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Meta AI's Segment Anything Model (SAM) for Geospatial Data.
|
|
5
5
|
Author-email: Qiusheng Wu <giswqs@gmail.com>
|
|
6
6
|
License: MIT license
|
|
@@ -86,8 +86,13 @@ Requires-Dist: xarray; extra == "samgeo3"
|
|
|
86
86
|
Provides-Extra: text
|
|
87
87
|
Requires-Dist: segment_geospatial[samgeo2]; extra == "text"
|
|
88
88
|
Requires-Dist: groundingdino-py; extra == "text"
|
|
89
|
+
Provides-Extra: api
|
|
90
|
+
Requires-Dist: segment_geospatial[core]; extra == "api"
|
|
91
|
+
Requires-Dist: fastapi>=0.100.0; extra == "api"
|
|
92
|
+
Requires-Dist: uvicorn[standard]>=0.20.0; extra == "api"
|
|
93
|
+
Requires-Dist: python-multipart>=0.0.6; extra == "api"
|
|
89
94
|
Provides-Extra: all
|
|
90
|
-
Requires-Dist: segment-geospatial[fast,fer,hq,samgeo,samgeo2,samgeo3,text]; extra == "all"
|
|
95
|
+
Requires-Dist: segment-geospatial[api,fast,fer,hq,samgeo,samgeo2,samgeo3,text]; extra == "all"
|
|
91
96
|
Provides-Extra: extra
|
|
92
97
|
Requires-Dist: leafmap; extra == "extra"
|
|
93
98
|
Requires-Dist: segment-geospatial[all]; extra == "extra"
|
|
@@ -137,6 +142,7 @@ The **SamGeo** package draws its inspiration from [segment-anything-eo](https://
|
|
|
137
142
|
- Save input prompts as GeoJSON files
|
|
138
143
|
- Visualize segmentation results on interactive maps
|
|
139
144
|
- Segment objects from timeseries remote sensing imagery
|
|
145
|
+
- REST API for serving segmentation over HTTP (see [API docs](https://samgeo.gishub.org/api))
|
|
140
146
|
|
|
141
147
|
## QGIS Plugin
|
|
142
148
|
|
|
@@ -185,6 +191,7 @@ Depending on what tools you need to use, you might want to do:
|
|
|
185
191
|
- `segment-geospatial[text]`: Installs Grounding DINO to use SAMGeo 1 and 2 with text prompts
|
|
186
192
|
- `segment-geospatial[fer]`: Installs the dependencies to run the feature
|
|
187
193
|
edge reconstruction algorithm
|
|
194
|
+
- `segment-geospatial[api]`: Installs FastAPI and Uvicorn for serving segmentation as a REST API
|
|
188
195
|
|
|
189
196
|
Additionally, these other two optional imports are defined:
|
|
190
197
|
|
|
@@ -38,6 +38,7 @@ The **SamGeo** package draws its inspiration from [segment-anything-eo](https://
|
|
|
38
38
|
- Save input prompts as GeoJSON files
|
|
39
39
|
- Visualize segmentation results on interactive maps
|
|
40
40
|
- Segment objects from timeseries remote sensing imagery
|
|
41
|
+
- REST API for serving segmentation over HTTP (see [API docs](https://samgeo.gishub.org/api))
|
|
41
42
|
|
|
42
43
|
## QGIS Plugin
|
|
43
44
|
|
|
@@ -86,6 +87,7 @@ Depending on what tools you need to use, you might want to do:
|
|
|
86
87
|
- `segment-geospatial[text]`: Installs Grounding DINO to use SAMGeo 1 and 2 with text prompts
|
|
87
88
|
- `segment-geospatial[fer]`: Installs the dependencies to run the feature
|
|
88
89
|
edge reconstruction algorithm
|
|
90
|
+
- `segment-geospatial[api]`: Installs FastAPI and Uvicorn for serving segmentation as a REST API
|
|
89
91
|
|
|
90
92
|
Additionally, these other two optional imports are defined:
|
|
91
93
|
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# REST API
|
|
2
|
+
|
|
3
|
+
segment-geospatial includes a built-in REST API powered by [FastAPI](https://fastapi.tiangolo.com/) that allows you to run image segmentation over HTTP. This is useful for integrating segmentation into web applications, pipelines, and non-Python clients.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the API dependencies with the `api` extra:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install "segment-geospatial[api]"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To also install a specific SAM model backend, combine extras:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install "segment-geospatial[api,samgeo3]"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Starting the Server
|
|
20
|
+
|
|
21
|
+
Use the `samgeo-api` command:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
samgeo-api
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
samgeo-api --host 0.0.0.0 --port 8000 # Custom host/port
|
|
31
|
+
samgeo-api --preload sam2:sam2-hiera-large # Preload a model at startup
|
|
32
|
+
samgeo-api --reload # Auto-reload for development
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Alternatively, use `uvicorn` directly:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uvicorn samgeo.api:app --host 0.0.0.0 --port 8000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Once running, interactive API docs (Swagger UI) are available at [http://localhost:8000/docs](http://localhost:8000/docs).
|
|
42
|
+
|
|
43
|
+
## Endpoints
|
|
44
|
+
|
|
45
|
+
### Health Check
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
GET /health
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Returns the server status and version.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
curl http://localhost:8000/health
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{"status": "ok", "version": "1.2.3"}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### List Models
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
GET /models
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Returns available model versions/IDs and which models are currently loaded in memory.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
curl http://localhost:8000/models
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Clear Models
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
DELETE /models
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Clears the model cache and frees GPU memory.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
curl -X DELETE http://localhost:8000/models
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Automatic Segmentation
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
POST /segment/automatic
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Runs automatic mask generation on an uploaded image. Supports SAM, SAM2, and SAM3.
|
|
92
|
+
|
|
93
|
+
**Parameters (multipart form):**
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Default | Description |
|
|
96
|
+
|-----------|------|---------|-------------|
|
|
97
|
+
| `file` | file | required | Image file (TIFF, PNG, JPEG) |
|
|
98
|
+
| `model_version` | string | `sam2` | One of `sam`, `sam2`, `sam3` |
|
|
99
|
+
| `model_id` | string | auto | Model identifier (e.g., `sam2-hiera-large`) |
|
|
100
|
+
| `output_format` | string | `geojson` | One of `geojson`, `geotiff`, `png` |
|
|
101
|
+
| `foreground` | bool | `true` | Extract foreground objects only |
|
|
102
|
+
| `unique` | bool | `true` | Assign unique ID to each object |
|
|
103
|
+
| `min_size` | int | `0` | Minimum mask size in pixels |
|
|
104
|
+
| `max_size` | int | none | Maximum mask size in pixels |
|
|
105
|
+
| `points_per_side` | int | `32` | Points sampled per side (SAM/SAM2) |
|
|
106
|
+
| `pred_iou_thresh` | float | `0.8` | IoU threshold for filtering |
|
|
107
|
+
| `stability_score_thresh` | float | `0.95` | Stability score threshold |
|
|
108
|
+
|
|
109
|
+
**Example:**
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
curl -X POST http://localhost:8000/segment/automatic \
|
|
113
|
+
-F "file=@image.tif" \
|
|
114
|
+
-F "model_version=sam2" \
|
|
115
|
+
-F "output_format=geojson"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Prompt-based Segmentation
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
POST /segment/predict
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Runs segmentation with point or bounding box prompts. Supports SAM and SAM2.
|
|
125
|
+
|
|
126
|
+
**Parameters (multipart form):**
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Default | Description |
|
|
129
|
+
|-----------|------|---------|-------------|
|
|
130
|
+
| `file` | file | required | Image file (TIFF, PNG, JPEG) |
|
|
131
|
+
| `model_version` | string | `sam2` | One of `sam`, `sam2` |
|
|
132
|
+
| `model_id` | string | auto | Model identifier |
|
|
133
|
+
| `output_format` | string | `geojson` | One of `geojson`, `geotiff`, `png` |
|
|
134
|
+
| `point_coords` | string | none | JSON array of `[[x, y], ...]` |
|
|
135
|
+
| `point_labels` | string | none | JSON array of `[1, 0, ...]` (1=foreground, 0=background) |
|
|
136
|
+
| `boxes` | string | none | JSON array of `[[xmin, ymin, xmax, ymax], ...]` |
|
|
137
|
+
| `point_crs` | string | none | CRS string (e.g., `EPSG:4326`) |
|
|
138
|
+
| `multimask_output` | bool | `false` | Return multiple masks per prompt |
|
|
139
|
+
|
|
140
|
+
**Example with point prompts:**
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
curl -X POST http://localhost:8000/segment/predict \
|
|
144
|
+
-F "file=@image.tif" \
|
|
145
|
+
-F "point_coords=[[100, 200]]" \
|
|
146
|
+
-F "point_labels=[1]" \
|
|
147
|
+
-F "output_format=geojson"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Example with box prompts:**
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
curl -X POST http://localhost:8000/segment/predict \
|
|
154
|
+
-F "file=@image.tif" \
|
|
155
|
+
-F "boxes=[[10, 20, 300, 400]]" \
|
|
156
|
+
-F "output_format=geotiff"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Text-prompt Segmentation
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
POST /segment/text
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Runs text-prompt segmentation using SAM3.
|
|
166
|
+
|
|
167
|
+
**Parameters (multipart form):**
|
|
168
|
+
|
|
169
|
+
| Parameter | Type | Default | Description |
|
|
170
|
+
|-----------|------|---------|-------------|
|
|
171
|
+
| `file` | file | required | Image file (TIFF, PNG, JPEG) |
|
|
172
|
+
| `prompt` | string | required | Text description (e.g., `building`, `tree`) |
|
|
173
|
+
| `model_id` | string | auto | SAM3 model identifier |
|
|
174
|
+
| `backend` | string | `meta` | One of `meta`, `transformers` |
|
|
175
|
+
| `output_format` | string | `geojson` | One of `geojson`, `geotiff`, `png` |
|
|
176
|
+
| `confidence_threshold` | float | `0.5` | Detection confidence threshold |
|
|
177
|
+
| `min_size` | int | `0` | Minimum mask size in pixels |
|
|
178
|
+
| `max_size` | int | none | Maximum mask size in pixels |
|
|
179
|
+
|
|
180
|
+
**Example:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
curl -X POST http://localhost:8000/segment/text \
|
|
184
|
+
-F "file=@image.tif" \
|
|
185
|
+
-F "prompt=building" \
|
|
186
|
+
-F "output_format=geojson"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Caching
|
|
190
|
+
|
|
191
|
+
The API automatically caches models and image encodings for better performance:
|
|
192
|
+
|
|
193
|
+
- **Model cache**: Models are loaded once and reused across requests. Use `DELETE /models` to free GPU memory.
|
|
194
|
+
- **Image cache**: When the same image is sent multiple times (e.g., with different prompts), the expensive image encoding step is skipped. This makes subsequent requests significantly faster.
|
|
195
|
+
|
|
196
|
+
Example timing with a 13 MB GeoTIFF:
|
|
197
|
+
|
|
198
|
+
| Request | Description | Time |
|
|
199
|
+
|---------|-------------|------|
|
|
200
|
+
| 1st | Model load + image encoding | ~7s |
|
|
201
|
+
| 2nd | Same image, different prompt | ~0.4s |
|
|
202
|
+
| 3rd | Same image, another prompt | ~0.2s |
|
|
203
|
+
|
|
204
|
+
## Python Client Example
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
import requests
|
|
208
|
+
|
|
209
|
+
url = "http://localhost:8000/segment/text"
|
|
210
|
+
|
|
211
|
+
with open("image.tif", "rb") as f:
|
|
212
|
+
response = requests.post(
|
|
213
|
+
url,
|
|
214
|
+
files={"file": ("image.tif", f, "image/tiff")},
|
|
215
|
+
data={"prompt": "building", "output_format": "geojson"},
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
geojson = response.json()
|
|
219
|
+
print(f"Found {len(geojson['features'])} features")
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## API Reference
|
|
223
|
+
|
|
224
|
+
::: samgeo.api
|
|
@@ -38,6 +38,7 @@ The **SamGeo** package draws its inspiration from [segment-anything-eo](https://
|
|
|
38
38
|
- Save input prompts as GeoJSON files
|
|
39
39
|
- Visualize segmentation results on interactive maps
|
|
40
40
|
- Segment objects from timeseries remote sensing imagery
|
|
41
|
+
- REST API for serving segmentation over HTTP (see [API docs](https://samgeo.gishub.org/api))
|
|
41
42
|
|
|
42
43
|
## QGIS Plugin
|
|
43
44
|
|
|
@@ -61,6 +62,7 @@ Depending on what tools you need to use, you might want to do:
|
|
|
61
62
|
- `segment-geospatial[text]`: Installs Grounding DINO to use SAMGeo 1 and 2 with text prompts
|
|
62
63
|
- `segment-geospatial[fer]`: Installs the dependencies to run the feature
|
|
63
64
|
edge reconstruction algorithm
|
|
65
|
+
- `segment-geospatial[api]`: Installs FastAPI and Uvicorn for serving segmentation as a REST API
|
|
64
66
|
|
|
65
67
|
Additionally, these other two optional imports are defined:
|
|
66
68
|
|
|
@@ -44,6 +44,7 @@ nav:
|
|
|
44
44
|
- Home: index.md
|
|
45
45
|
- Installation: installation.md
|
|
46
46
|
- Usage: usage.md
|
|
47
|
+
- REST API: api.md
|
|
47
48
|
- Contributing: contributing.md
|
|
48
49
|
- FAQ: faq.md
|
|
49
50
|
- Changelog: changelog.md
|
|
@@ -98,4 +99,5 @@ nav:
|
|
|
98
99
|
- hq_sam module: hq_sam.md
|
|
99
100
|
- text_sam module: text_sam.md
|
|
100
101
|
- detectree2 module: detectree2.md
|
|
102
|
+
- api module: api.md
|
|
101
103
|
# - fer module: fer.md
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "segment-geospatial"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.0"
|
|
8
8
|
dynamic = [
|
|
9
9
|
"dependencies",
|
|
10
10
|
]
|
|
@@ -86,8 +86,14 @@ text = [
|
|
|
86
86
|
"segment_geospatial[samgeo2]",
|
|
87
87
|
"groundingdino-py",
|
|
88
88
|
]
|
|
89
|
+
api = [
|
|
90
|
+
"segment_geospatial[core]",
|
|
91
|
+
"fastapi>=0.100.0",
|
|
92
|
+
"uvicorn[standard]>=0.20.0",
|
|
93
|
+
"python-multipart>=0.0.6",
|
|
94
|
+
]
|
|
89
95
|
all = [
|
|
90
|
-
"segment-geospatial[fast, hq, fer, samgeo, samgeo2, samgeo3, text]",
|
|
96
|
+
"segment-geospatial[fast, hq, fer, samgeo, samgeo2, samgeo3, text, api]",
|
|
91
97
|
]
|
|
92
98
|
extra = [
|
|
93
99
|
"leafmap",
|
|
@@ -111,7 +117,7 @@ dependencies = {file = ["requirements.txt"]}
|
|
|
111
117
|
universal = true
|
|
112
118
|
|
|
113
119
|
[tool.bumpversion]
|
|
114
|
-
current_version = "1.
|
|
120
|
+
current_version = "1.3.0"
|
|
115
121
|
commit = true
|
|
116
122
|
tag = true
|
|
117
123
|
|
|
@@ -133,5 +139,8 @@ max-line-length = 88
|
|
|
133
139
|
|
|
134
140
|
[tool.setuptools_scm]
|
|
135
141
|
|
|
142
|
+
[project.scripts]
|
|
143
|
+
samgeo-api = "samgeo.api:main"
|
|
144
|
+
|
|
136
145
|
[project.urls]
|
|
137
146
|
Homepage = "https://github.com/opengeos/segment-geospatial"
|