segment-geospatial 1.2.2__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.
Files changed (132) hide show
  1. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/docker-publish.yml +4 -4
  2. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/draft-pdf.yml +1 -1
  3. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.pre-commit-config.yaml +3 -3
  4. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/PKG-INFO +9 -2
  5. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/README.md +2 -0
  6. segment_geospatial-1.3.0/docs/api.md +224 -0
  7. segment_geospatial-1.3.0/docs/detectree2.md +3 -0
  8. segment_geospatial-1.3.0/docs/examples/detectree2.ipynb +376 -0
  9. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/index.md +2 -0
  10. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/mkdocs.yml +4 -0
  11. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/pyproject.toml +12 -3
  12. segment_geospatial-1.3.0/samgeo/__init__.py +23 -0
  13. segment_geospatial-1.3.0/samgeo/api.py +615 -0
  14. segment_geospatial-1.3.0/samgeo/detectree2.py +502 -0
  15. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/samgeo3.py +11 -1
  16. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/PKG-INFO +9 -2
  17. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/SOURCES.txt +7 -0
  18. segment_geospatial-1.3.0/segment_geospatial.egg-info/entry_points.txt +2 -0
  19. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/requires.txt +7 -1
  20. segment_geospatial-1.3.0/tests/test_api.py +161 -0
  21. segment_geospatial-1.2.2/samgeo/__init__.py +0 -10
  22. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.editorconfig +0 -0
  23. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/FUNDING.yml +0 -0
  24. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  25. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  26. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  27. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/dependabot.yaml +0 -0
  28. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/docker-image.yml +0 -0
  29. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/docs-build.yml +0 -0
  30. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/docs.yml +0 -0
  31. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/macos.yml +0 -0
  32. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/pypi.yml +0 -0
  33. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/ubuntu.yml +0 -0
  34. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.github/workflows/windows.yml +0 -0
  35. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/.gitignore +0 -0
  36. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/CITATION.cff +0 -0
  37. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/CODE_OF_CONDUCT.md +0 -0
  38. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/Dockerfile +0 -0
  39. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/LICENSE +0 -0
  40. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/MANIFEST.in +0 -0
  41. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/CNAME +0 -0
  42. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/assets/README.md +0 -0
  43. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/assets/favicon.png +0 -0
  44. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/assets/logo.png +0 -0
  45. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/assets/logo_rect.png +0 -0
  46. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/caption.md +0 -0
  47. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/changelog.md +0 -0
  48. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/changelog_update.py +0 -0
  49. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/common.md +0 -0
  50. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/contributing.md +0 -0
  51. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/arcgis.ipynb +0 -0
  52. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/automatic_mask_generator.ipynb +0 -0
  53. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/automatic_mask_generator_hq.ipynb +0 -0
  54. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/box_prompts.ipynb +0 -0
  55. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/data/tree_boxes.geojson +0 -0
  56. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/fast_sam.ipynb +0 -0
  57. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/image_captioning.ipynb +0 -0
  58. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/input_prompts.ipynb +0 -0
  59. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/input_prompts_hq.ipynb +0 -0
  60. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/maxar_open_data.ipynb +0 -0
  61. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_automatic.ipynb +0 -0
  62. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_box_prompts.ipynb +0 -0
  63. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_point_prompts.ipynb +0 -0
  64. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_predictor.ipynb +0 -0
  65. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_text_prompts.ipynb +0 -0
  66. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam2_video.ipynb +0 -0
  67. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_automated_segmentation.ipynb +0 -0
  68. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_batch_segmentation.ipynb +0 -0
  69. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_box_prompts.ipynb +0 -0
  70. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_image_segmentation.ipynb +0 -0
  71. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_image_segmentation_jpg.ipynb +0 -0
  72. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_interactive.ipynb +0 -0
  73. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_object_tracking.ipynb +0 -0
  74. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_point_prompts.ipynb +0 -0
  75. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_point_prompts_batch.ipynb +0 -0
  76. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_tiled_segmentation.ipynb +0 -0
  77. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_video_masks.ipynb +0 -0
  78. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_video_prompts.ipynb +0 -0
  79. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/sam3_video_segmentation.ipynb +0 -0
  80. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/satellite-predictor.ipynb +0 -0
  81. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/satellite.ipynb +0 -0
  82. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/text_prompts.ipynb +0 -0
  83. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/text_prompts_batch.ipynb +0 -0
  84. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/text_swimming_pools.ipynb +0 -0
  85. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/examples/tree_mapping.ipynb +0 -0
  86. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/faq.md +0 -0
  87. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/fast_sam.md +0 -0
  88. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/hq_sam.md +0 -0
  89. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/installation.md +0 -0
  90. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/overrides/main.html +0 -0
  91. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/samgeo.md +0 -0
  92. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/samgeo2.md +0 -0
  93. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/samgeo3.md +0 -0
  94. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/text_sam.md +0 -0
  95. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/usage.md +0 -0
  96. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/workshops/AIforGood_2025.ipynb +0 -0
  97. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/workshops/IPPN_2024.ipynb +0 -0
  98. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/workshops/cn_workshop.ipynb +0 -0
  99. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/workshops/jupytext.toml +0 -0
  100. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/docs/workshops/purdue.ipynb +0 -0
  101. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/paper/10.21105.joss.05663.pdf +0 -0
  102. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/paper/paper.bib +0 -0
  103. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/paper/paper.md +0 -0
  104. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/LICENSE +0 -0
  105. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/README.md +0 -0
  106. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/__init__.py +0 -0
  107. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/icons/icon.png +0 -0
  108. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/install_plugin.py +0 -0
  109. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/install_plugin.sh +0 -0
  110. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/map_tools.py +0 -0
  111. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/metadata.txt +0 -0
  112. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/resources.py +0 -0
  113. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/samgeo_plugin.py +0 -0
  114. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/qgis-samgeo-plugin/test_plugin.py +0 -0
  115. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/requirements.txt +0 -0
  116. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/requirements_dev.txt +0 -0
  117. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/requirements_docs.txt +0 -0
  118. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/caption.py +0 -0
  119. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/common.py +0 -0
  120. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/fast_sam.py +0 -0
  121. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/fer.py +0 -0
  122. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/hq_sam.py +0 -0
  123. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/samgeo.py +0 -0
  124. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/samgeo2.py +0 -0
  125. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/text_sam.py +0 -0
  126. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/samgeo/utmconv.py +0 -0
  127. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/dependency_links.txt +0 -0
  128. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/segment_geospatial.egg-info/top_level.txt +0 -0
  129. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/setup.cfg +0 -0
  130. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/tests/__init__.py +0 -0
  131. {segment_geospatial-1.2.2 → segment_geospatial-1.3.0}/tests/test_common.py +0 -0
  132. {segment_geospatial-1.2.2 → 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@v3
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@v3
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@v5
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@v6
40
+ uses: docker/build-push-action@v7
41
41
  with:
42
42
  context: .
43
43
  push: true
@@ -14,7 +14,7 @@ jobs:
14
14
  # This should be the path to the paper within your repo.
15
15
  paper-path: paper/paper.md
16
16
  - name: Upload
17
- uses: actions/upload-artifact@v6
17
+ uses: actions/upload-artifact@v7
18
18
  with:
19
19
  name: paper
20
20
  # This is the output path where Pandoc will write the compiled
@@ -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.14.14
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.1
22
+ rev: v2.4.2
23
23
  hooks:
24
24
  - id: codespell
25
25
  args:
@@ -29,6 +29,6 @@ repos:
29
29
  ]
30
30
 
31
31
  - repo: https://github.com/kynan/nbstripout
32
- rev: 0.9.0
32
+ rev: 0.9.1
33
33
  hooks:
34
34
  - id: nbstripout
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: segment-geospatial
3
- Version: 1.2.2
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
@@ -0,0 +1,3 @@
1
+ # detectree2 module
2
+
3
+ ::: samgeo.detectree2