alessandro trinca tornidor commited on
Commit
0914710
1 Parent(s): b00385f

[feat] prepare entire docker build with nvidia GPU on hf space cloning https://huggingface.co/spaces/aletrn/samgis

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .coveragerc +9 -0
  2. .dockerignore +16 -0
  3. .gitignore +278 -0
  4. .idea/.gitignore +3 -0
  5. .idea/inspectionProfiles/profiles_settings.xml +6 -0
  6. .idea/vcs.xml +6 -0
  7. Dockerfile +173 -0
  8. LICENSE.txt +21 -0
  9. README.md +124 -4
  10. dockerfiles/apt_preferences_debian +9 -0
  11. dockerfiles/apt_preferences_ubuntu +9 -0
  12. dockerfiles/debian.sources +17 -0
  13. dockerfiles/dockerfile-fastapi-fastsam-api +1 -0
  14. dockerfiles/dockerfile-lambda-fastsam-api +36 -0
  15. dockerfiles/dockerfile-lisa-base +140 -0
  16. dockerfiles/dockerfile-lisa-predictions +45 -0
  17. dockerfiles/dockerfile-samgis-base +132 -0
  18. dockerfiles/ubuntu.sources +18 -0
  19. docs/.gitignore +0 -0
  20. docs/Changelog.md +37 -0
  21. docs/Makefile +20 -0
  22. docs/_static/.gitignore +0 -0
  23. docs/brief_project_presentation.md +20 -0
  24. docs/conf.py +72 -0
  25. docs/external_links.rst +5 -0
  26. docs/external_links_md.md +2 -0
  27. docs/index.rst +27 -0
  28. docs/make.bat +35 -0
  29. docs/modules.rst +7 -0
  30. docs/openapi.rst +11 -0
  31. docs/other_resources.rst +9 -0
  32. docs/samgis.io.rst +53 -0
  33. docs/samgis.prediction_api.rst +21 -0
  34. docs/samgis.rst +20 -0
  35. docs/samgis.utilities.rst +29 -0
  36. docs/specs/openapi.yaml +177 -0
  37. events/colico_point_rectangle_output.json +1 -0
  38. events/colico_prompt1.json +5 -0
  39. events/example_output.json +19 -0
  40. events/payload_lisa_teglio.json +5 -0
  41. events/payload_multiprompt_api_request_body.json +48 -0
  42. events/payload_multiprompt_api_response_body_failure.json +1 -0
  43. events/payload_multiprompt_api_response_body_success.json +8 -0
  44. events/payload_point.json +14 -0
  45. events/payload_point2.json +14 -0
  46. events/payload_point_eolie.json +24 -0
  47. events/payload_point_error_int_str.json +62 -0
  48. events/payload_point_rectangle_colico.json +48 -0
  49. events/payload_rectangle.json +12 -0
  50. events/payloads_body_base64.json +52 -0
.coveragerc ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ [run]
2
+ source = samgis
3
+ omit = ./venv/*,__version__.py,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py,./tests/*
4
+
5
+ [report]
6
+ omit = ./venv/*,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py,./tests/*
7
+
8
+ exclude_lines =
9
+ if __name__ == .__main__.:
.dockerignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ venv/
2
+ *.pyc
3
+ __cache__
4
+ .idea
5
+ tmp/
6
+ .env*
7
+ __pycache__
8
+ .DS_Store
9
+ .pytest_cache
10
+ node_modules
11
+ dist
12
+ static/node_modules
13
+ static/dist
14
+ static/.env*
15
+ .coverage
16
+ .git
.gitignore ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Created by https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
3
+
4
+ ### Linux ###
5
+ *~
6
+
7
+ # temporary files which can be created if a process still has a handle open of a deleted file
8
+ .fuse_hidden*
9
+
10
+ # KDE directory preferences
11
+ .directory
12
+
13
+ # Linux trash folder which might appear on any partition or disk
14
+ .Trash-*
15
+
16
+ # .nfs files are created when an open file is removed but is still being accessed
17
+ .nfs*
18
+
19
+ ### OSX ###
20
+ *.DS_Store
21
+ .AppleDouble
22
+ .LSOverride
23
+
24
+ # Icon must end with two \r
25
+ Icon
26
+
27
+ # Thumbnails
28
+ ._*
29
+
30
+ # Files that might appear in the root of a volume
31
+ .DocumentRevisions-V100
32
+ .fseventsd
33
+ .Spotlight-V100
34
+ .TemporaryItems
35
+ .Trashes
36
+ .VolumeIcon.icns
37
+ .com.apple.timemachine.donotpresent
38
+
39
+ # Directories potentially created on remote AFP share
40
+ .AppleDB
41
+ .AppleDesktop
42
+ Network Trash Folder
43
+ Temporary Items
44
+ .apdisk
45
+
46
+ # CMake
47
+ cmake-build-debug/
48
+
49
+ # Ruby plugin and RubyMine
50
+ /.rakeTasks
51
+
52
+ # Crashlytics plugin (for Android Studio and IntelliJ)
53
+ com_crashlytics_export_strings.xml
54
+ crashlytics.properties
55
+ crashlytics-build.properties
56
+ fabric.properties
57
+
58
+ ### Python ###
59
+ # Byte-compiled / optimized / DLL files
60
+ __pycache__/
61
+ *.py[cod]
62
+ *$py.class
63
+
64
+ # C extensions
65
+ *.so
66
+
67
+ # Distribution / packaging
68
+ .Python
69
+ build/
70
+ develop-eggs/
71
+ dist/
72
+ downloads/
73
+ eggs/
74
+ .eggs/
75
+ lib/
76
+ lib64/
77
+ parts/
78
+ sdist/
79
+ var/
80
+ wheels/
81
+ *.egg-info/
82
+ .installed.cfg
83
+ *.egg
84
+
85
+ # PyInstaller
86
+ # Usually these files are written by a python script from a template
87
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
88
+ *.manifest
89
+ *.spec
90
+
91
+ # Installer logs
92
+ pip-log.txt
93
+ pip-delete-this-directory.txt
94
+
95
+ # Unit test / coverage reports
96
+ htmlcov/
97
+ .tox/
98
+ .coverage
99
+ .coverage.*
100
+ .cache
101
+ .pytest_cache/
102
+ nosetests.xml
103
+ coverage.xml
104
+ *.cover
105
+ .hypothesis/
106
+
107
+ # Translations
108
+ *.mo
109
+ *.pot
110
+
111
+ # Flask stuff:
112
+ instance/
113
+ .webassets-cache
114
+
115
+ # Scrapy stuff:
116
+ .scrapy
117
+
118
+ # Sphinx documentation
119
+ docs/_build/doctrees/*
120
+ docs/_build/html/*
121
+
122
+ # PyBuilder
123
+ target/
124
+
125
+ # Jupyter Notebook
126
+ .ipynb_checkpoints
127
+
128
+ # pyenv
129
+ .python-version
130
+
131
+ # celery beat schedule file
132
+ celerybeat-schedule.*
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .env*
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+
160
+ ### VisualStudioCode ###
161
+ .vscode/*
162
+ !.vscode/settings.json
163
+ !.vscode/tasks.json
164
+ !.vscode/launch.json
165
+ !.vscode/extensions.json
166
+ .history
167
+
168
+ ### Windows ###
169
+ # Windows thumbnail cache files
170
+ Thumbs.db
171
+ ehthumbs.db
172
+ ehthumbs_vista.db
173
+
174
+ # Folder config file
175
+ Desktop.ini
176
+
177
+ # Recycle Bin used on file shares
178
+ $RECYCLE.BIN/
179
+
180
+ # Windows Installer files
181
+ *.cab
182
+ *.msi
183
+ *.msm
184
+ *.msp
185
+
186
+ # Windows shortcuts
187
+ *.lnk
188
+
189
+ # Build folder
190
+
191
+ */build/*
192
+
193
+ # custom
194
+ *.ori
195
+ tmp
196
+ nohup.out
197
+ /tests/events.tar
198
+ function_dump_*.json
199
+
200
+ # onnx models
201
+ *.onnx
202
+
203
+ # End of https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
204
+
205
+ ## .idea files
206
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
207
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
208
+
209
+ # User-specific stuff
210
+ .idea/**/workspace.xml
211
+ .idea/**/tasks.xml
212
+ .idea/**/usage.statistics.xml
213
+ .idea/**/dictionaries
214
+ .idea/**/shelf
215
+
216
+ # Generated files
217
+ .idea/**/contentModel.xml
218
+
219
+ # Sensitive or high-churn files
220
+ .idea/**/dataSources/
221
+ .idea/**/dataSources.ids
222
+ .idea/**/dataSources.local.xml
223
+ .idea/**/sqlDataSources.xml
224
+ .idea/**/dynamic.xml
225
+ .idea/**/uiDesigner.xml
226
+ .idea/**/dbnavigator.xml
227
+
228
+ # Gradle
229
+ .idea/**/gradle.xml
230
+ .idea/**/libraries
231
+
232
+ # Gradle and Maven with auto-import
233
+ # When using Gradle or Maven with auto-import, you should exclude module files,
234
+ # since they will be recreated, and may cause churn. Uncomment if using
235
+ # auto-import.
236
+ # .idea/modules.xml
237
+ .idea/*.iml
238
+ # .idea/modules
239
+
240
+ # CMake
241
+ cmake-build-*/
242
+
243
+ # Mongo Explorer plugin
244
+ .idea/**/mongoSettings.xml
245
+
246
+ # File-based project format
247
+ *.iws
248
+
249
+ # IntelliJ
250
+ out/
251
+
252
+ # mpeltonen/sbt-idea plugin
253
+ .idea_modules/
254
+
255
+ # JIRA plugin
256
+ atlassian-ide-plugin.xml
257
+
258
+ # Cursive Clojure plugin
259
+ .idea/replstate.xml
260
+
261
+ # Crashlytics plugin (for Android Studio and IntelliJ)
262
+ com_crashlytics_export_strings.xml
263
+ crashlytics.properties
264
+ crashlytics-build.properties
265
+ fabric.properties
266
+
267
+ # Editor-based Rest Client
268
+ .idea/httpRequests
269
+
270
+ # Android studio 3.1+ serialized cache file
271
+ .idea/caches/build_file_checksums.ser
272
+
273
+ # Sonarlint plugin
274
+ .idea/sonarlint
275
+ /.idea/modules.xml
276
+
277
+ # node_modules
278
+ node_modules
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
Dockerfile ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+
11
+
12
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
13
+
14
+ LABEL authors="alessandro@trinca.tornidor.com"
15
+
16
+ ARG ARCH
17
+ ARG LAMBDA_TASK_ROOT
18
+ ARG PYTHONPATH
19
+ ARG POETRY_NO_INTERACTION
20
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
21
+ ARG POETRY_VIRTUALENVS_CREATE
22
+ ARG POETRY_CACHE_DIR
23
+ ARG DEPENDENCY_GROUP
24
+
25
+ RUN echo "ARCH: $ARCH ..."
26
+
27
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
28
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
29
+ RUN test -n ${DEPENDENCY_GROUP:?}
30
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
31
+ RUN echo "arg dep:"
32
+
33
+ # Set working directory to function root directory
34
+ WORKDIR ${LAMBDA_TASK_ROOT}
35
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
36
+
37
+ RUN cat /etc/lsb-release
38
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
39
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
40
+
41
+ RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
42
+ COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
43
+ COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
44
+ #RUN echo "run update noble..."
45
+ #RUN apt update
46
+ #RUN apt update && apt install -t noble zlib1g -y
47
+ RUN git lfs install
48
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
49
+
50
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
51
+
52
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
53
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
54
+
55
+ RUN which poetry && poetry --version && poetry config --list
56
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
57
+ RUN poetry config installer.max-workers 7
58
+ RUN echo "# poetry config --list #" && poetry config --list
59
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
60
+ #RUN . ${LAMBDA_TASK_ROOT}/.venv/bin/activate && ${LAMBDA_TASK_ROOT}/.venv/bin/python --version && ${LAMBDA_TASK_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
61
+ RUN poetry run python -m pip install pip wheel setuptools --upgrade
62
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root -vvv
63
+
64
+
65
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as runtime
66
+
67
+ ARG ARCH
68
+ ARG LAMBDA_TASK_ROOT
69
+
70
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
71
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
72
+
73
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
74
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
75
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
76
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
77
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
78
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
79
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
80
+
81
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
82
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
83
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
84
+
85
+
86
+ ### conditional section
87
+ FROM node:20-slim AS node_fastapi
88
+
89
+ ARG DEPENDENCY_GROUP
90
+ ENV PNPM_HOME="/pnpm"
91
+ ENV PATH="$PNPM_HOME:$PATH"
92
+
93
+ RUN corepack enable
94
+
95
+ COPY ./static /appnode
96
+ WORKDIR /appnode
97
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
98
+
99
+
100
+ FROM node_fastapi AS node_prod_deps
101
+
102
+ ARG DEPENDENCY_GROUP
103
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
104
+ pnpm install --prod --frozen-lockfile; else \
105
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
106
+ # here multiple conditions concatenated to avoid failing on check
107
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
108
+
109
+
110
+ FROM node_fastapi AS node_build
111
+
112
+ ARG DEPENDENCY_GROUP
113
+ ARG VITE__MAP_DESCRIPTION
114
+ ARG VITE__SAMGIS_SPACE
115
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
116
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
117
+
118
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
119
+ pnpm install --frozen-lockfile; else \
120
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
121
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
122
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
123
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
124
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
125
+
126
+
127
+ FROM runtime
128
+ ARG FASTAPI_STATIC
129
+ RUN mkdir ${FASTAPI_STATIC}
130
+
131
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
132
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
133
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
134
+
135
+
136
+ # Include global arg in this stage of the build
137
+ ARG LAMBDA_TASK_ROOT="/var/task"
138
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
139
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
140
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
141
+ ENV IS_AWS_LAMBDA=""
142
+
143
+ # Set working directory to function root directory
144
+ WORKDIR ${LAMBDA_TASK_ROOT}
145
+
146
+ COPY samgis ${LAMBDA_TASK_ROOT}/samgis
147
+ COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
148
+
149
+ RUN ls -l /usr/bin/which
150
+ RUN /usr/bin/which python
151
+ RUN python -v
152
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
153
+ RUN echo "PATH: ${PATH}."
154
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
155
+ RUN ls -l ${LAMBDA_TASK_ROOT}
156
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
157
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
158
+ RUN python -c "import sys; print(sys.path)"
159
+ RUN python -c "import cv2"
160
+ RUN python -c "import fastapi"
161
+ RUN python -c "import geopandas"
162
+ RUN python -c "import loguru"
163
+ RUN python -c "import onnxruntime"
164
+ RUN python -c "import rasterio"
165
+ RUN python -c "import uvicorn"
166
+ RUN df -h
167
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
168
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
169
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/
170
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist
171
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules
172
+
173
+ CMD ["uvicorn", "wrappers.fastapi_wrapper:app", "--host", "0.0.0.0", "--port", "7860"]
LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Alessandro Trinca Tornidor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,10 +1,130 @@
1
  ---
2
- title: Samgis Lisa On Cuda
3
- emoji: 📉
4
- colorFrom: blue
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: SamGIS
3
+ emoji: 🗺️
4
+ colorFrom: red
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ license: mit
9
  ---
10
 
11
+ ## Segment Anything models
12
+ It's possible to prepare the model files using https://github.com/vietanhdev/samexporter/ or using the ones
13
+ from https://huggingface.co/aletrn/sam-quantized (copy them within the folder `/machine_learning_models`).
14
+
15
+ ## SamGIS - HuggingFace version
16
+
17
+ The SamGIS HuggingSpace url is https://huggingface.co/spaces/aletrn/samgis.
18
+ Build the docker image this way:
19
+
20
+ ```bash
21
+ # clean any old active containers
22
+ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
23
+
24
+ # build the base docker image from the repository root folder using ARGs:
25
+ # - DEPENDENCY_GROUP=fastapi used by poetry
26
+ # VITE__MAP_DESCRIPTION, VITE__SAMGIS_SPACE used by 'docker build'
27
+ (
28
+ set -o allexport && source <(cat ./static/.env|grep VITE__) && set +o allexport;
29
+ env|grep VITE__;
30
+ docker build . -f dockerfiles/dockerfile-samgis-base --progress=plain \
31
+ --build-arg DEPENDENCY_GROUP=fastapi \
32
+ --build-arg VITE__MAP_DESCRIPTION=${VITE__MAP_DESCRIPTION} \
33
+ --build-arg VITE__SAMGIS_SPACE=${VITE__SAMGIS_SPACE} \
34
+ --tag registry.gitlab.com/aletrn/gis-prediction
35
+ )
36
+
37
+ # build the image, use the tag "samgis-huggingface"
38
+ docker build . --tag example-docker-namespace/samgis-huggingface --progress=plain
39
+ ```
40
+
41
+ Run the container (keep it on background) and show logs
42
+
43
+ ```bash
44
+ docker run -d --name samgis-huggingface -p 7860:7860 example-docker-namespace/samgis-huggingface; docker logs -f samgis-huggingface
45
+ ```
46
+
47
+ Test it with curl using a json payload:
48
+
49
+ ```bash
50
+ URL=http://localhost:7860/infer_samgis
51
+ curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
52
+ ```
53
+
54
+ or better visiting the swagger page on http://localhost:7860/docs
55
+
56
+
57
+ ## SamGIS - lambda AWS version
58
+
59
+ Build the docker image this way:
60
+
61
+ ```bash
62
+ # clean any old active containers
63
+ docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
64
+
65
+ # build the base docker image with the docker aws repository tag
66
+ docker build . -f dockerfiles/dockerfile-samgis-base --build-arg DEPENDENCY_GROUP=aws_lambda \
67
+ --tag example-docker-namespace/samgis-base-aws-lambda --progress=plain
68
+
69
+ # build the final docker image
70
+ docker build . -f dockerfiles/dockerfile-lambda-fastsam-api --tag example-docker-namespace/lambda-fastsam-api --progress=plain
71
+ ```
72
+
73
+ Run the container (keep it on background) and show logs
74
+
75
+ ```bash
76
+ docker run -d --name lambda-fastsam-api -p 8080:8080 lambda-fastsam-api; docker logs -f lambda-fastsam-api
77
+ ```
78
+
79
+ Test it with curl using a json payload:
80
+
81
+ ```bash
82
+ URL=http://localhost:8080/2015-03-31/functions/function/invocations
83
+ curl -d@./events/payload_point_eolie.json -H 'accept: application/json' ${URL}
84
+ ```
85
+
86
+ ### Publish the aws lambda docker image
87
+ Login on aws ECR with the correct aws profile (change the example `example-docker-namespace/` repository url with the one from
88
+ the [ECR push command instructions page](https://eu-west-1.console.aws.amazon.com/ecr/repositories/)).
89
+
90
+ ### Dependencies installation and local tests
91
+ The docker build process needs only the base dependency group plus the `aws_lambda` or `fastapi` optional one.
92
+ Install also the `test` and/or `docs` groups if needed.
93
+
94
+ ### Tests
95
+
96
+ Tests are defined in the `tests` folder in this project. Use PIP to install the test dependencies and run tests.
97
+
98
+ ```bash
99
+ python -m pytest --cov=samgis --cov-report=term-missing && coverage html
100
+ ```
101
+
102
+ ### How to update the static documentation with sphinx
103
+
104
+ This project documentation uses sphinx-apidoc: it's a tool for automatic generation of Sphinx sources that, using the autodoc
105
+ extension, document a whole package in the style of other automatic API documentation tools. See the
106
+ [documentation page](https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html) for details.
107
+ Run the command from the project root:
108
+
109
+ ```bash
110
+ # missing docs folder (run from project root) initialize this way
111
+ cd docs && sphinx-quickstart -p SamGIS -r 1.0.0 -l python --master index
112
+
113
+ # update docs folder (from project root)
114
+ sphinx-apidoc -f -o docs samgis
115
+ ```
116
+
117
+ Then it's possible to generate the HTML pages
118
+
119
+ ```bash
120
+ cd docs && make html && ../
121
+
122
+ # to clean old files
123
+ cd docs && make clean html && cd ../
124
+ ```
125
+
126
+ The static documentation it's now ready at the path `docs/_build/html/index.html`.
127
+
128
+ To create a work in progress openapi json or yaml file use
129
+ - `extract-openapi-fastapi.py`
130
+ - `extract-openapi-lambda.py` (useful to export the json schema request and response from lambda app api)
dockerfiles/apt_preferences_debian ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Explanation: Uninstall or do not install any Debian-originated
2
+ Explanation: package versions other than those in the stable distro
3
+ Package: *
4
+ Pin: release a=stable
5
+ Pin-Priority: 900
6
+
7
+ Package: zlib1g
8
+ Pin: release a=trixie
9
+ Pin-Priority: -10
dockerfiles/apt_preferences_ubuntu ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Explanation: Uninstall or do not install any Debian-originated
2
+ Explanation: package versions other than those in the stable distro
3
+ Package: *
4
+ Pin: release a=stable
5
+ Pin-Priority: 900
6
+
7
+ Package: zlib1g
8
+ Pin: release a=noble
9
+ Pin-Priority: -10
dockerfiles/debian.sources ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Types: deb deb-src
2
+ URIs: http://deb.debian.org/debian
3
+ Suites: bookworm bookworm-updates
4
+ Components: main
5
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
6
+
7
+ Types: deb deb-src
8
+ URIs: http://deb.debian.org/debian-security
9
+ Suites: bookworm-security
10
+ Components: main
11
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
12
+
13
+ Types: deb
14
+ URIs: http://deb.debian.org/debian
15
+ Suites: trixie
16
+ Components: main
17
+ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
dockerfiles/dockerfile-fastapi-fastsam-api ADDED
@@ -0,0 +1 @@
 
 
1
+ Dockerfile
dockerfiles/dockerfile-lambda-fastsam-api ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM localhost/samgis-base-aws-lambda:latest
2
+
3
+ # Include global arg in this stage of the build
4
+ ARG LAMBDA_TASK_ROOT="/var/task"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
7
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
8
+ ENV IS_AWS_LAMBDA="True"
9
+
10
+ # Set working directory to function root directory
11
+ WORKDIR ${LAMBDA_TASK_ROOT}
12
+ COPY ./samgis ${LAMBDA_TASK_ROOT}/samgis
13
+ COPY ./wrappers ${LAMBDA_TASK_ROOT}/wrappers
14
+
15
+ RUN ls -l /usr/bin/which
16
+ RUN /usr/bin/which python
17
+ RUN python -v
18
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
19
+ RUN echo "PATH: ${PATH}."
20
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
21
+ RUN ls -l ${LAMBDA_TASK_ROOT}
22
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
23
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
24
+ RUN python -c "import sys; print(sys.path)"
25
+ RUN python -c "import awslambdaric"
26
+ RUN python -c "import cv2"
27
+ RUN python -c "import geopandas"
28
+ RUN python -c "import onnxruntime"
29
+ RUN python -c "import rasterio"
30
+ RUN df -h
31
+ RUN ls -l /lambda-entrypoint.sh
32
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
33
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
34
+
35
+ ENTRYPOINT ["/lambda-entrypoint.sh"]
36
+ CMD [ "wrappers.lambda_wrapper.lambda_handler" ]
dockerfiles/dockerfile-lisa-base ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+
11
+
12
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
13
+
14
+ LABEL authors="alessandro@trinca.tornidor.com"
15
+
16
+ ARG ARCH
17
+ ARG LAMBDA_TASK_ROOT
18
+ ARG PYTHONPATH
19
+ ARG POETRY_NO_INTERACTION
20
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
21
+ ARG POETRY_VIRTUALENVS_CREATE
22
+ ARG POETRY_CACHE_DIR
23
+ ARG DEPENDENCY_GROUP
24
+
25
+ RUN echo "ARCH: $ARCH ..."
26
+
27
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
28
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
29
+ RUN test -n ${DEPENDENCY_GROUP:?}
30
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
31
+ RUN echo "arg dep:"
32
+
33
+ # Set working directory to function root directory
34
+ WORKDIR ${LAMBDA_TASK_ROOT}
35
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
36
+
37
+ RUN cat /etc/lsb-release
38
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
39
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
40
+
41
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
42
+ RUN chmod 755 /clone3-workaround
43
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
44
+
45
+ RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
46
+ COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
47
+ COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
48
+ #RUN echo "run update noble..."
49
+ #RUN apt update
50
+ #RUN apt update && apt install -t noble zlib1g -y
51
+ RUN git lfs install
52
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
53
+
54
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
55
+
56
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
57
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
58
+
59
+ RUN which poetry && poetry --version && poetry config --list
60
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
61
+ RUN poetry config installer.max-workers 7
62
+ RUN echo "# poetry config --list #" && poetry config --list
63
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
64
+ #RUN . ${LAMBDA_TASK_ROOT}/.venv/bin/activate && ${LAMBDA_TASK_ROOT}/.venv/bin/python --version && ${LAMBDA_TASK_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
65
+ RUN poetry run python -m pip install pip wheel setuptools --upgrade
66
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root -vvv
67
+
68
+
69
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as runtime
70
+
71
+ ARG ARCH
72
+ ARG LAMBDA_TASK_ROOT
73
+
74
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
75
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
76
+
77
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
78
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
79
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
80
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
81
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
82
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
83
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
84
+
85
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
86
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
87
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
88
+
89
+
90
+ ### conditional section
91
+ FROM node:20-slim AS node_fastapi
92
+
93
+ ARG DEPENDENCY_GROUP
94
+ ENV PNPM_HOME="/pnpm"
95
+ ENV PATH="$PNPM_HOME:$PATH"
96
+
97
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
98
+ RUN chmod 755 /clone3-workaround
99
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
100
+ RUN corepack enable
101
+
102
+ COPY ./static /appnode
103
+ WORKDIR /appnode
104
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
105
+
106
+
107
+ FROM node_fastapi AS node_prod_deps
108
+
109
+ ARG DEPENDENCY_GROUP
110
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
111
+ pnpm install --prod --frozen-lockfile; else \
112
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
113
+ # here multiple conditions concatenated to avoid failing on check
114
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
115
+
116
+
117
+ FROM node_fastapi AS node_build
118
+
119
+ ARG DEPENDENCY_GROUP
120
+ ARG VITE__MAP_DESCRIPTION
121
+ ARG VITE__SAMGIS_SPACE
122
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
123
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
124
+
125
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
126
+ pnpm install --frozen-lockfile; else \
127
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
128
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
129
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
130
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
131
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
132
+
133
+
134
+ FROM runtime
135
+ ARG FASTAPI_STATIC
136
+ RUN mkdir ${FASTAPI_STATIC}
137
+
138
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
139
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
140
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
dockerfiles/dockerfile-lisa-predictions ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM registry.gitlab.com/aletrn/gis-lisa-base:1.2.2
2
+
3
+ # Include global arg in this stage of the build
4
+ ARG LAMBDA_TASK_ROOT="/var/task"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
7
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
8
+ ENV IS_AWS_LAMBDA=""
9
+
10
+ # Set working directory to function root directory
11
+ WORKDIR ${LAMBDA_TASK_ROOT}
12
+
13
+ ADD https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64 /clone3-workaround
14
+ RUN chmod 755 /clone3-workaround
15
+ SHELL ["/clone3-workaround","/bin/sh", "-c"]
16
+
17
+ COPY scripts ${LAMBDA_TASK_ROOT}/scripts
18
+ COPY samgis ${LAMBDA_TASK_ROOT}/samgis
19
+ COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
20
+
21
+ RUN ls -l /usr/bin/which
22
+ RUN /usr/bin/which python
23
+ RUN python -v
24
+ RUN echo "PYTHONPATH: ${PYTHONPATH}."
25
+ RUN echo "PATH: ${PATH}."
26
+ RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
27
+ RUN ls -l ${LAMBDA_TASK_ROOT}
28
+ RUN ls -ld ${LAMBDA_TASK_ROOT}
29
+ RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
30
+ RUN python -c "import sys; print(sys.path)"
31
+ RUN python -c "import cv2"
32
+ RUN python -c "import fastapi"
33
+ RUN python -c "import geopandas"
34
+ RUN python -c "import loguru"
35
+ RUN python -c "import onnxruntime"
36
+ RUN python -c "import rasterio"
37
+ RUN python -c "import uvicorn"
38
+ RUN df -h
39
+ RUN ls -l ${LAMBDA_TASK_ROOT}/samgis/
40
+ RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
41
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/
42
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist
43
+ RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules
44
+
45
+ CMD ["uvicorn", "wrappers.fastapi_wrapper:app", "--host", "0.0.0.0", "--port", "7860"]
dockerfiles/dockerfile-samgis-base ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Include global ARGs at the dockerfile top
2
+ ARG ARCH="x86_64"
3
+ ARG LAMBDA_TASK_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
+ ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
+ ARG POETRY_NO_INTERACTION=1
7
+ ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
+ ARG POETRY_VIRTUALENVS_CREATE=1
9
+ ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
+ ARG RIE="https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie"
11
+
12
+
13
+ FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
14
+
15
+ ARG ARCH
16
+ ARG LAMBDA_TASK_ROOT
17
+ ARG PYTHONPATH
18
+ ARG POETRY_NO_INTERACTION
19
+ ARG POETRY_VIRTUALENVS_IN_PROJECT
20
+ ARG POETRY_VIRTUALENVS_CREATE
21
+ ARG POETRY_CACHE_DIR
22
+ ARG RIE
23
+ ARG DEPENDENCY_GROUP
24
+ ARG ZLIB1G="http://ftp.it.debian.org/debian/pool/main/z/zlib/zlib1g_1.3.dfsg-3+b1_amd64.deb"
25
+
26
+ RUN echo "ARCH: $ARCH ..."
27
+
28
+ RUN echo "ARG RIE: $RIE ..."
29
+ RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
30
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
31
+ RUN test -n ${DEPENDENCY_GROUP:?}
32
+ RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
33
+ RUN echo "arg dep:"
34
+
35
+ # Set working directory to function root directory
36
+ WORKDIR ${LAMBDA_TASK_ROOT}
37
+ COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
38
+
39
+ RUN cat /etc/lsb-release
40
+ # avoid segment-geospatial exception caused by missing libGL.so.1 library
41
+ RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
42
+ RUN apt update && apt install -y libgl1 curl python3-pip && apt clean
43
+ COPY ./dockerfiles/apt_preferences_debian /etc/apt/preferences
44
+ COPY ./dockerfiles/debian.sources /etc/apt/sources.list.d/debian.sources
45
+ RUN apt update && apt install -t trixie zlib1g -y && apt clean
46
+ RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
47
+
48
+ RUN ls -l /etc/apt/sources* /etc/apt/preferences*
49
+ RUN curl -Lo /usr/local/bin/aws-lambda-rie ${RIE}
50
+
51
+ # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
52
+ RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
53
+
54
+ RUN which poetry && poetry --version && poetry config --list
55
+ RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
56
+ RUN echo "# poetry config --list #" && poetry config --list
57
+ RUN poetry install --with ${DEPENDENCY_GROUP} --no-root
58
+
59
+
60
+ FROM python:3.11-slim-bookworm as runtime
61
+
62
+ ARG ARCH
63
+ ARG LAMBDA_TASK_ROOT
64
+
65
+ ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
66
+ PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
67
+
68
+ RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
69
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
70
+ RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
71
+ RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
72
+ COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
73
+ RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
74
+ COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
75
+
76
+ RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
77
+ RUN ls -ld ${LAMBDA_TASK_ROOT}/
78
+ RUN ls -lA ${LAMBDA_TASK_ROOT}/
79
+
80
+ COPY --from=builder_global /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
81
+ RUN chmod +x /usr/local/bin/aws-lambda-rie
82
+ COPY ./scripts/lambda-entrypoint.sh /lambda-entrypoint.sh
83
+ RUN chmod +x /lambda-entrypoint.sh
84
+
85
+
86
+ ### conditional section
87
+ FROM node:20-slim AS node_fastapi
88
+
89
+ ARG DEPENDENCY_GROUP
90
+ ENV PNPM_HOME="/pnpm"
91
+ ENV PATH="$PNPM_HOME:$PATH"
92
+ RUN corepack enable
93
+
94
+ COPY ./static /appnode
95
+ WORKDIR /appnode
96
+ # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
97
+
98
+
99
+ FROM node_fastapi AS node_prod_deps
100
+
101
+ ARG DEPENDENCY_GROUP
102
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
103
+ pnpm install --prod --frozen-lockfile; else \
104
+ echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
105
+ # here multiple conditions concatenated to avoid failing on check
106
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
107
+
108
+
109
+ FROM node_fastapi AS node_build
110
+
111
+ ARG DEPENDENCY_GROUP
112
+ ARG VITE__MAP_DESCRIPTION
113
+ ARG VITE__SAMGIS_SPACE
114
+ RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
115
+ RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
116
+
117
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
118
+ pnpm install --frozen-lockfile; else \
119
+ echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
120
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
121
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
122
+ pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
123
+ RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
124
+
125
+
126
+ FROM runtime
127
+ ARG FASTAPI_STATIC
128
+ RUN mkdir ${FASTAPI_STATIC}
129
+
130
+ COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
131
+ COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
132
+ COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
dockerfiles/ubuntu.sources ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ deb http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
2
+ deb-src http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
3
+
4
+ deb http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
5
+ deb-src http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
6
+
7
+ deb http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
8
+ deb-src http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
9
+
10
+
11
+ deb http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
12
+ deb-src http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
13
+
14
+ deb http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
15
+ deb-src http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
16
+
17
+ deb http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse
18
+ deb-src http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse
docs/.gitignore ADDED
File without changes
docs/Changelog.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ ## Version 1.2.2
4
+ - update dependencies version
5
+
6
+ ## Version 1.2.1
7
+ - update dependencies version
8
+
9
+ ## Version 1.2.0
10
+ - code refactor to separate core functionality (instance segmentation) from other code
11
+ - updated test coverage
12
+
13
+ ## Version 1.1.0
14
+ - Added this changelog
15
+ - specific backend branch code uses terrain providers like nextzen and MapBox Terrain-RGB v1
16
+ - update test coverage
17
+ - update python dependencies versions
18
+ - update node dependencies versions
19
+
20
+ ## Version 1.0.2
21
+ - HuggingFace frontend demo: update the navbar url to SamGIS docs
22
+ - add two openapi docs builder scripts
23
+ - update samgis version within docs
24
+ - remove unused package.json
25
+
26
+ ## Version 1.0.1
27
+ - fixed zlib1g security vulnerability in python:3.11-slim-bookworm docker image, see https://security-tracker.debian.org/tracker/CVE-2023-45853
28
+
29
+ ## Version 1.0.0
30
+ First release:
31
+ - user onboarding tour with driver.js
32
+ - code decoupling between the AWS lambda wrapper and the backend...
33
+ - ...now also deployed on this HuggingSpace space demo (here some explanation about adding a SPA vuejs frontend)
34
+ - request input validation using Pydantic
35
+ - support for array prompts (both rectangle and point types)
36
+ - tiles download/merge/crop steps uses contextily by geopandas
37
+ - CSS frontend style with Tailwind
docs/Makefile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
docs/_static/.gitignore ADDED
File without changes
docs/brief_project_presentation.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # About this project
2
+
3
+ SamGIS is an attempt to perform [machine learning](https://developer.ibm.com/learningpaths/get-started-artificial-intelligence/ai-basics/ai-beginners-guide) [instance segmentation](https://en.wikipedia.org/wiki/Image_segmentation) on [geospatial data](https://en.wikipedia.org/wiki/Geographic_data_and_information) even without the use of dedicated graphics cards.
4
+ The user interact on a [leaflet](https://leafletjs.com) webmap choosing areas to recognize and a backend responds with a [geojson](https://it.wikipedia.org/wiki/GeoJSON) containing one or more recognized polygons within the initial webmap.
5
+
6
+ The backend perform machine learning inference using a [Segment Anything](https://segment-anything.com) model and [ONNXRuntime](https://onnxruntime.ai) as runtime.
7
+
8
+ Check about implementation details on my [blog](https://trinca.tornidor.com/projects/samgis-segment-anything-applied-to-GIS).
9
+
10
+ # Self-hosted demo
11
+
12
+ You can visit my self-hosted demo [here](https://ml-trinca.tornidor.com).
13
+ Since this demo uses a python container backend hosted on my AWS account I keep it under authentication to prevent abuses.
14
+ [Here](https://docs.ml-trinca.tornidor.com/openapi) the OpenAPI swagger documentation.
15
+
16
+ # HuggingFace Space demo
17
+
18
+ I added also a demo on this [HuggingFace Space](https://huggingface.co/spaces/aletrn/samgis). It's
19
+ possible to find [here](https://aletrn-samgis.hf.space/) the direct space url and
20
+ [here](https://aletrn-samgis.hf.space/docs#/) the OpenAPI swagger documentation.
docs/conf.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+ import os
9
+ import sys
10
+
11
+ project = 'SamGIS'
12
+ copyright = '2023-now, alessandro trinca tornidor'
13
+ author = 'alessandro trinca tornidor'
14
+ release = '1.2.2'
15
+
16
+ # -- General configuration ---------------------------------------------------
17
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
18
+ sys.path.insert(0, os.path.abspath('..'))
19
+
20
+ extensions = [
21
+ 'sphinx.ext.autodoc',
22
+ 'sphinx.ext.viewcode',
23
+ 'sphinx.ext.napoleon',
24
+ 'sphinx_autodoc_typehints',
25
+ 'sphinxcontrib.openapi',
26
+ 'myst_parser',
27
+ # 'sphinx_autodoc_defaultargs'
28
+ ]
29
+ # Napoleon settings
30
+ napoleon_google_docstring = True
31
+
32
+ #
33
+ typehints_defaults = "comma"
34
+
35
+ templates_path = ['_templates']
36
+ exclude_patterns = [
37
+ '_build', 'Thumbs.db', '.DS_Store', 'build/*', 'machine_learning_models', 'machine_learning_models/*'
38
+ ]
39
+
40
+ source_suffix = {
41
+ '.rst': 'restructuredtext',
42
+ '.txt': 'restructuredtext',
43
+ '.md': 'markdown',
44
+ }
45
+
46
+ # default args values
47
+ rst_prolog = """
48
+ .. |default| raw:: html
49
+
50
+ <div class="default-value-section">""" + \
51
+ ' <span class="default-value-label">Default:</span>'
52
+
53
+ # -- Options for HTML output -------------------------------------------------
54
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
55
+
56
+ html_theme = 'alabaster'
57
+ html_sidebars = {
58
+ '**': [
59
+ 'about.html',
60
+ 'navigation.html',
61
+ 'relations.html',
62
+ 'searchbox.html',
63
+ 'donate.html',
64
+ ]
65
+ }
66
+ html_static_path = ['_static']
67
+ html_theme_options = {
68
+ "description": "Segment Anything applied to geodata",
69
+ "fixed_sidebar": True,
70
+ "sidebar_collapse": False,
71
+ 'globaltoc_collapse': False
72
+ }
docs/external_links.rst ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ External links
2
+ ==============
3
+
4
+ .. include:: external_links_md.md
5
+ :parser: myst_parser.sphinx_
docs/external_links_md.md ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ - My [SamGIS demo website](https://ml-trinca.tornidor.com)
2
+ - My [personal website](https://trinca.tornidor.com)
docs/index.rst ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .. SamGIS documentation master file, created by
2
+ sphinx-quickstart on Thu Nov 23 21:51:08 2023.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ Welcome to SamGIS's documentation!
7
+ ==================================
8
+
9
+ .. include:: brief_project_presentation.md
10
+ :parser: myst_parser.sphinx_
11
+ .. include:: Changelog.md
12
+ :parser: myst_parser.sphinx_
13
+
14
+ .. toctree::
15
+ :maxdepth: 2
16
+ :hidden:
17
+
18
+ modules
19
+ other_resources
20
+
21
+
22
+ Indices and tables documentation
23
+ ================================
24
+
25
+ * :ref:`genindex`
26
+ * :ref:`modindex`
27
+ * :ref:`search`
docs/make.bat ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
docs/modules.rst ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ samgis
2
+ ======
3
+
4
+ .. toctree::
5
+ :maxdepth: 4
6
+
7
+ samgis
docs/openapi.rst ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OpenAPI Specs
2
+ =============
3
+
4
+ This API is under oauth authentication for the self-hosted version (now it works as a lambda AWS).
5
+ Contact the maintainer/administrator for more info about this.
6
+
7
+ .. openapi:: specs/openapi.yaml
8
+ :paths:
9
+ /lambda-ml-fastsam-api
10
+ :examples:
11
+ :encoding: utf-8
docs/other_resources.rst ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Other resources
2
+ ===============
3
+
4
+ .. toctree::
5
+ :maxdepth: 4
6
+
7
+ external_links
8
+
9
+ openapi
docs/samgis.io.rst ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ samgis.io package
2
+ =================
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ samgis.io.coordinates\_pixel\_conversion module
8
+ -----------------------------------------------
9
+
10
+ .. automodule:: samgis.io.coordinates_pixel_conversion
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ samgis.io.geo\_helpers module
16
+ -----------------------------
17
+
18
+ .. automodule:: samgis.io.geo_helpers
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
22
+
23
+ samgis.io.raster\_helpers module
24
+ --------------------------------
25
+
26
+ .. automodule:: samgis.io.raster_helpers
27
+ :members:
28
+ :undoc-members:
29
+ :show-inheritance:
30
+
31
+ samgis.io.tms2geotiff module
32
+ ----------------------------
33
+
34
+ .. automodule:: samgis.io.tms2geotiff
35
+ :members:
36
+ :undoc-members:
37
+ :show-inheritance:
38
+
39
+ samgis.io.wrappers\_helpers module
40
+ ----------------------------------
41
+
42
+ .. automodule:: samgis.io.wrappers_helpers
43
+ :members:
44
+ :undoc-members:
45
+ :show-inheritance:
46
+
47
+ Module contents
48
+ ---------------
49
+
50
+ .. automodule:: samgis.io
51
+ :members:
52
+ :undoc-members:
53
+ :show-inheritance:
docs/samgis.prediction_api.rst ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ samgis.prediction\_api package
2
+ ==============================
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ samgis.prediction\_api.predictors module
8
+ ----------------------------------------
9
+
10
+ .. automodule:: samgis.prediction_api.predictors
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ Module contents
16
+ ---------------
17
+
18
+ .. automodule:: samgis.prediction_api
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
docs/samgis.rst ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ samgis package
2
+ ==============
3
+
4
+ Subpackages
5
+ -----------
6
+
7
+ .. toctree::
8
+ :maxdepth: 4
9
+
10
+ samgis.io
11
+ samgis.prediction_api
12
+ samgis.utilities
13
+
14
+ Module contents
15
+ ---------------
16
+
17
+ .. automodule:: samgis
18
+ :members:
19
+ :undoc-members:
20
+ :show-inheritance:
docs/samgis.utilities.rst ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ samgis.utilities package
2
+ ========================
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ samgis.utilities.constants module
8
+ ---------------------------------
9
+
10
+ .. automodule:: samgis.utilities.constants
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ samgis.utilities.type\_hints module
16
+ -----------------------------------
17
+
18
+ .. automodule:: samgis.utilities.type_hints
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
22
+
23
+ Module contents
24
+ ---------------
25
+
26
+ .. automodule:: samgis.utilities
27
+ :members:
28
+ :undoc-members:
29
+ :show-inheritance:
docs/specs/openapi.yaml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Swagger SamGIS - OpenAPI 3.0
4
+ description: |-
5
+ Segment Anything applied to GIS.
6
+ Some useful links:
7
+ - [SamGIS online demo](https://ml-trinca.tornidor.com)
8
+ - [SamGIS documentation](https://docs.ml-trinca.tornidor.com)
9
+ - [My blog](https://trinca.tornidor.com)
10
+ contact:
11
+ name: alessandro's website
12
+ url: https://trinca.tornidor.com
13
+ license:
14
+ name: MIT License
15
+ url: https://opensource.org/license/mit/
16
+ version: "1.2.0"
17
+ servers:
18
+ - url: https://localhost:8000/
19
+ tags:
20
+ - name: samgis-aws
21
+ description: segment anything applied to gis (self-hosted demo)
22
+ externalDocs:
23
+ url: https://ml-trinca.tornidor.com/
24
+ - name: samgis-huggingface
25
+ description: segment anything applied to gis (huggingface demo)
26
+ externalDocs:
27
+ url: https://huggingface.co/spaces/aletrn/samgis
28
+ - name: segment-anything
29
+ description: segment anything machine learning model
30
+ externalDocs:
31
+ url: http://segment-anything.com
32
+ - name: gis
33
+ externalDocs:
34
+ url: https://it.wikipedia.org/wiki/Geographic_information_system
35
+ paths:
36
+ /lambda-ml-fastsam-api:
37
+ post:
38
+ tags:
39
+ - samgis
40
+ summary: Make GIS ML predictions
41
+ requestBody:
42
+ description: input request for GIS ML predictions
43
+ content:
44
+ application/json:
45
+ schema:
46
+ $ref: '#/components/schemas/ApiRequestBody'
47
+ required: true
48
+ responses:
49
+ '200':
50
+ description: successful operation
51
+ content:
52
+ application/json:
53
+ schema:
54
+ $ref: '#/components/schemas/ApiResponseBodySuccess'
55
+ '400':
56
+ description: Bad request
57
+ content:
58
+ application/json:
59
+ schema:
60
+ $ref: '#/components/schemas/ApiResponseBodyFailure'
61
+ '422':
62
+ description: Unprocessable Entity
63
+ content:
64
+ application/json:
65
+ schema:
66
+ $ref: '#/components/schemas/ApiResponseBodyFailure'
67
+ '500':
68
+ description: Internal Server Error
69
+ content:
70
+ application/json:
71
+ schema:
72
+ $ref: '#/components/schemas/ApiResponseBodyFailure'
73
+ components:
74
+ schemas:
75
+ ApiRequestBody:
76
+ required:
77
+ - bbox
78
+ - prompt
79
+ - zoom
80
+ type: object
81
+ properties:
82
+ bbox:
83
+ type: object
84
+ properties:
85
+ ne:
86
+ type: object
87
+ properties:
88
+ lat:
89
+ type: number
90
+ example: 46.180194387028855
91
+ lng:
92
+ type: number
93
+ example: 9.426848938165525
94
+ sw:
95
+ type: object
96
+ properties:
97
+ lat:
98
+ type: number
99
+ example: 46.17511301243843
100
+ lng:
101
+ type: number
102
+ example: 9.415862610040527
103
+ prompt:
104
+ type: array
105
+ items:
106
+ type: object
107
+ properties:
108
+ id:
109
+ type: integer
110
+ format: int32
111
+ example: 448
112
+ type:
113
+ type: string
114
+ example: point
115
+ data:
116
+ type: object
117
+ properties:
118
+ lat:
119
+ type: number
120
+ example: 46.176256754439535
121
+ lng:
122
+ type: number
123
+ example: 9.421805260519237
124
+ label:
125
+ type: integer
126
+ format: int32
127
+ example: 1
128
+ zoom:
129
+ type: integer
130
+ format: int32
131
+ example: 17
132
+ source_type:
133
+ type: string
134
+ example: OpenStreetMap
135
+ ApiResponseBodyFailure:
136
+ type: object
137
+ properties:
138
+ duration_run:
139
+ type: number
140
+ example: 0.063
141
+ message:
142
+ type: string
143
+ example: Bad Request
144
+ request_id:
145
+ type: string
146
+ example: test_invoke_id
147
+ ApiResponseBodySuccess:
148
+ type: object
149
+ properties:
150
+ n_predictions:
151
+ type: integer
152
+ format: int32
153
+ example: 1
154
+ geojson:
155
+ type: string
156
+ example: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"raster_val":255.0},"geometry":{"type":"Polygon","coordinates":[[[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532]]]},"id":0},{"type":"Feature","properties":{"raster_val":0.0},"geometry":{"type":"Polygon","coordinates":[[[9.143199920654297,46.30271068141335],[9.495105743408203,46.30271068141335],[9.495105743408203,46.13999860748669],[9.143199920654297,46.13999860748669],[9.143199920654297,46.30271068141335]],[[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532]]]},"id":1}]}'
157
+ n_shapes_geojson:
158
+ type: integer
159
+ format: int32
160
+ example: 5
161
+ duration_run:
162
+ type: number
163
+ example: 6.703
164
+ message:
165
+ type: string
166
+ example: ok
167
+ request_id:
168
+ type: string
169
+ example: test_invoke_id
170
+ securitySchemes:
171
+ samgis_auth:
172
+ type: oauth2
173
+ flows:
174
+ implicit:
175
+ authorizationUrl: https://example.auth0.com/oauth/authorize
176
+ scopes:
177
+ write:lambda-ml-fastsam-api: Make GIS ML predictions
events/colico_point_rectangle_output.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"n_predictions": 1, "geojson": "{\"type\": \"FeatureCollection\", \"features\": [{\"id\": \"0\", \"type\": \"Feature\", \"properties\": {\"raster_val\": 0.0}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[9.43674087524414, 46.17780978687552], [9.43674087524414, 46.17709660889324], [9.437084197998045, 46.17709660889324], [9.437084197998045, 46.17733433591508], [9.437427520751953, 46.17733433591508], [9.437427520751953, 46.17780978687552], [9.43674087524414, 46.17780978687552]]]}}, {\"id\": \"1\", \"type\": \"Feature\", \"properties\": {\"raster_val\": 255.0}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[9.426441192626953, 46.18921937663871], [9.429531097412108, 46.18921937663871], [9.429531097412108, 46.18898170100372], [9.43124771118164, 46.18898170100372], [9.43124771118164, 46.18874402434101], [9.432277679443358, 46.18874402434101], [9.432277679443358, 46.18850634665056], [9.432964324951172, 46.18850634665056], [9.432964324951172, 46.18826866793239], [9.433307647705078, 46.18826866793239], [9.433307647705078, 46.18803098818649], [9.433994293212889, 46.18803098818649], [9.433994293212889, 46.18779330741286], [9.435024261474608, 46.18779330741286], [9.435024261474608, 46.18755562561149], [9.436397552490234, 46.18755562561149], [9.436397552490234, 46.18731794278239], [9.43777084350586, 46.18731794278239], [9.43777084350586, 46.187080258925576], [9.438800811767578, 46.187080258925576], [9.438800811767578, 46.18684257404102], [9.43948745727539, 46.18684257404102], [9.43948745727539, 46.186604888128734], [9.44498062133789, 46.186604888128734], [9.44498062133789, 46.186367201188716], [9.447727203369139, 46.186367201188716], [9.447727203369139, 46.18612951322096], [9.44875717163086, 46.18612951322096], [9.44875717163086, 46.18589182422548], [9.449100494384766, 46.18589182422548], [9.449100494384766, 46.18517875107263], [9.449443817138674, 46.18517875107263], [9.449443817138674, 46.182801773760346], [9.449100494384766, 46.182801773760346], [9.449100494384766, 46.182564070376564], [9.44875717163086, 46.182564070376564], [9.44875717163086, 46.18232636596505], [9.445323944091797, 46.18232636596505], [9.445323944091797, 46.1820886605258], [9.443607330322267, 46.1820886605258], [9.443607330322267, 46.1818509540588], [9.44223403930664, 46.1818509540588], [9.44223403930664, 46.181613246564076], [9.441547393798828, 46.181613246564076], [9.441547393798828, 46.1813755380416], [9.441204071044922, 46.1813755380416], [9.441204071044922, 46.17994926532421], [9.441547393798828, 46.17994926532421], [9.441547393798828, 46.178998396291114], [9.441204071044922, 46.178998396291114], [9.441204071044922, 46.17709660889324], [9.440174102783201, 46.17709660889324], [9.440174102783201, 46.180424693674304], [9.439830780029297, 46.180424693674304], [9.439830780029297, 46.18066240630774], [9.439144134521484, 46.18066240630774], [9.439144134521484, 46.180424693674304], [9.438457489013672, 46.180424693674304], [9.438457489013672, 46.180186980013126], [9.438114166259766, 46.180186980013126], [9.438114166259766, 46.17876067646348], [9.438457489013672, 46.17876067646348], [9.438457489013672, 46.17804751081413], [9.438800811767578, 46.17804751081413], [9.438800811767578, 46.17685888084364], [9.439144134521484, 46.17685888084364], [9.439144134521484, 46.17638342166123], [9.438800811767578, 46.17638342166123], [9.438800811767578, 46.1756702251795], [9.438457489013672, 46.1756702251795], [9.438457489013672, 46.17543249096342], [9.438114166259766, 46.17543249096342], [9.438114166259766, 46.1751947557196], [9.43674087524414, 46.1751947557196], [9.43674087524414, 46.17495701944803], [9.436397552490234, 46.17495701944803], [9.436397552490234, 46.17471928214871], [9.436054229736328, 46.17471928214871], [9.436054229736328, 46.17448154382164], [9.435710906982424, 46.17448154382164], [9.435710906982424, 46.17400606408425], [9.435367584228517, 46.17400606408425], [9.435367584228517, 46.17376832267393], [9.435024261474608, 46.17376832267393], [9.435024261474608, 46.17400606408425], [9.434680938720703, 46.17400606408425], [9.434680938720703, 46.174243804466826], [9.433994293212889, 46.174243804466826], [9.433994293212889, 46.17376832267393], [9.433650970458984, 46.17376832267393], [9.433650970458984, 46.17305509227646], [9.434337615966797, 46.17305509227646], [9.434337615966797, 46.17281734675514], [9.434680938720703, 46.17281734675514], [9.434680938720703, 46.1718663543923], [9.434337615966797, 46.1718663543923], [9.434337615966797, 46.1716286037322], [9.433994293212889, 46.1716286037322], [9.433994293212889, 46.171390852044354], [9.432621002197267, 46.171390852044354], [9.432621002197267, 46.171153099328755], [9.432277679443358, 46.171153099328755], [9.432277679443358, 46.170915345585406], [9.431934356689453, 46.170915345585406], [9.431934356689453, 46.1702020781888], [9.43124771118164, 46.1702020781888], [9.43124771118164, 46.16996432033442], [9.430904388427736, 46.16996432033442], [9.430904388427736, 46.169726561452286], [9.43124771118164, 46.169726561452286], [9.43124771118164, 46.1694888015424], [9.433650970458984, 46.1694888015424], [9.433650970458984, 46.16925104060475], [9.433994293212889, 46.16925104060475], [9.433994293212889, 46.16901327863934], [9.434337615966797, 46.16901327863934], [9.434337615966797, 46.16853775162525], [9.434680938720703, 46.16853775162525], [9.434680938720703, 46.16806222050013], [9.435024261474608, 46.16806222050013], [9.435024261474608, 46.16758668526397], [9.435367584228517, 46.16758668526397], [9.435367584228517, 46.16734891610425], [9.43948745727539, 46.16734891610425], [9.43948745727539, 46.16711114591677], [9.439830780029297, 46.16711114591677], [9.439830780029297, 46.16544672582708], [9.43948745727539, 46.16544672582708], [9.43948745727539, 46.16497116798016], [9.438800811767578, 46.16497116798016], [9.438800811767578, 46.16473338751506], [9.432621002197267, 46.16473338751506], [9.432621002197267, 46.16449560602219], [9.429531097412108, 46.16449560602219], [9.429531097412108, 46.16473338751506], [9.429187774658201, 46.16473338751506], [9.429187774658201, 46.16497116798016], [9.428844451904297, 46.16497116798016], [9.428844451904297, 46.16520894741751], [9.428157806396484, 46.16520894741751], [9.428157806396484, 46.16497116798016], [9.427127838134766, 46.16497116798016], [9.427127838134766, 46.16473338751506], [9.426097869873047, 46.16473338751506], [9.426097869873047, 46.16449560602219], [9.425411224365234, 46.16449560602219], [9.425411224365234, 46.16425782350156], [9.424724578857424, 46.16425782350156], [9.424724578857424, 46.163782255376994], [9.42403793334961, 46.163782255376994], [9.42403793334961, 46.16354446977307], [9.42300796508789, 46.16354446977307], [9.42300796508789, 46.16306889548191], [9.422664642333984, 46.16306889548191], [9.422664642333984, 46.162831106794684], [9.422321319580078, 46.162831106794684], [9.422321319580078, 46.162355526336924], [9.421977996826174, 46.162355526336924], [9.421977996826174, 46.1618799417681], [9.421634674072264, 46.1618799417681], [9.421634674072264, 46.161404353088194], [9.42129135131836, 46.161404353088194], [9.42129135131836, 46.16116655720659], [9.420948028564453, 46.16116655720659], [9.420948028564453, 46.16092876029722], [9.420604705810547, 46.16092876029722], [9.420604705810547, 46.16069096236007], [9.42026138305664, 46.16069096236007], [9.42026138305664, 46.16021536340248], [9.419918060302734, 46.16021536340248], [9.419918060302734, 46.15973976033379], [9.419574737548828, 46.15973976033379], [9.419574737548828, 46.159501957257795], [9.419231414794922, 46.159501957257795], [9.419231414794922, 46.159026348022486], [9.418888092041016, 46.159026348022486], [9.418888092041016, 46.15855073467608], [9.418544769287108, 46.15855073467608], [9.418544769287108, 46.15831292646123], [9.418201446533203, 46.15831292646123], [9.418201446533203, 46.158075117218594], [9.417858123779297, 46.158075117218594], [9.417858123779297, 46.15783730694818], [9.41751480102539, 46.15783730694818], [9.41751480102539, 46.15759949565], [9.417171478271484, 46.15759949565], [9.417171478271484, 46.15736168332404], [9.416828155517578, 46.15736168332404], [9.416828155517578, 46.15712386997031], [9.416484832763672, 46.15712386997031], [9.416484832763672, 46.15664824017952], [9.416141510009766, 46.15664824017952], [9.416141510009766, 46.15641042374246], [9.415454864501953, 46.15641042374246], [9.415454864501953, 46.15617260627763], [9.415111541748047, 46.15617260627763], [9.415111541748047, 46.15593478778501], [9.414081573486328, 46.15593478778501], [9.414081573486328, 46.15569696826462], [9.413738250732422, 46.15569696826462], [9.413738250732422, 46.155459147716456], [9.41305160522461, 46.155459147716456], [9.41305160522461, 46.15641042374246], [9.412708282470703, 46.15641042374246], [9.412708282470703, 46.15688605558881], [9.412364959716799, 46.15688605558881], [9.412364959716799, 46.15712386997031], [9.41202163696289, 46.15712386997031], [9.41202163696289, 46.15736168332404], [9.411678314208983, 46.15736168332404], [9.411678314208983, 46.15712386997031], [9.411334991455078, 46.15712386997031], [9.411334991455078, 46.15688605558881], [9.410648345947264, 46.15688605558881], [9.410648345947264, 46.15664824017952], [9.407901763916016, 46.15664824017952], [9.407901763916016, 46.15688605558881], [9.40755844116211, 46.15688605558881], [9.40755844116211, 46.16092876029722], [9.407215118408203, 46.16092876029722], [9.407215118408203, 46.16116655720659], [9.402751922607422, 46.16116655720659], [9.402751922607422, 46.16092876029722], [9.40206527709961, 46.16092876029722], [9.40206527709961, 46.16116655720659], [9.401378631591797, 46.16116655720659], [9.401378631591797, 46.161404353088194], [9.401721954345703, 46.161404353088194], [9.401721954345703, 46.162355526336924], [9.40206527709961, 46.162355526336924], [9.40206527709961, 46.16306889548191], [9.402408599853516, 46.16306889548191], [9.402408599853516, 46.16330668314137], [9.40206527709961, 46.16330668314137], [9.40206527709961, 46.16616005488923], [9.401721954345703, 46.16616005488923], [9.401721954345703, 46.16711114591677], [9.401378631591797, 46.16711114591677], [9.401378631591797, 46.16853775162525], [9.40103530883789, 46.16853775162525], [9.40103530883789, 46.16901327863934], [9.400691986083984, 46.16901327863934], [9.400691986083984, 46.16925104060475], [9.40000534057617, 46.16925104060475], [9.40000534057617, 46.1694888015424], [9.399662017822266, 46.1694888015424], [9.399662017822266, 46.169726561452286], [9.39931869506836, 46.169726561452286], [9.39931869506836, 46.170915345585406], [9.401378631591797, 46.170915345585406], [9.401378631591797, 46.171153099328755], [9.40206527709961, 46.171153099328755], [9.40206527709961, 46.171390852044354], [9.402751922607422, 46.171390852044354], [9.402751922607422, 46.1716286037322], [9.403438568115234, 46.1716286037322], [9.403438568115234, 46.17210410402464], [9.403781890869139, 46.17210410402464], [9.403781890869139, 46.172579600206056], [9.404125213623047, 46.172579600206056], [9.404125213623047, 46.17281734675514], [9.40481185913086, 46.17281734675514], [9.40481185913086, 46.17305509227646], [9.405841827392578, 46.17305509227646], [9.405841827392578, 46.17329283677004], [9.406185150146484, 46.17329283677004], [9.406185150146484, 46.17353058023586], [9.406871795654297, 46.17353058023586], [9.406871795654297, 46.17376832267393], [9.40755844116211, 46.17376832267393], [9.40755844116211, 46.17400606408425], [9.407901763916016, 46.17400606408425], [9.407901763916016, 46.174243804466826], [9.408588409423828, 46.174243804466826], [9.408588409423828, 46.17471928214871], [9.40927505493164, 46.17471928214871], [9.40927505493164, 46.17495701944803], [9.409618377685547, 46.17495701944803], [9.409618377685547, 46.1751947557196], [9.409961700439453, 46.1751947557196], [9.409961700439453, 46.17543249096342], [9.41030502319336, 46.17543249096342], [9.41030502319336, 46.1756702251795], [9.410648345947264, 46.1756702251795], [9.410648345947264, 46.17590795836782], [9.410991668701172, 46.17590795836782], [9.410991668701172, 46.1761456905284], [9.411334991455078, 46.1761456905284], [9.411334991455078, 46.17638342166123], [9.411678314208983, 46.17638342166123], [9.411678314208983, 46.17662115176631], [9.41202163696289, 46.17662115176631], [9.41202163696289, 46.17685888084364], [9.412364959716799, 46.17685888084364], [9.412364959716799, 46.17709660889324], [9.412708282470703, 46.17709660889324], [9.412708282470703, 46.17733433591508], [9.413394927978517, 46.17733433591508], [9.413394927978517, 46.177572061909174], [9.413738250732422, 46.177572061909174], [9.413738250732422, 46.17780978687552], [9.414081573486328, 46.17780978687552], [9.414081573486328, 46.17804751081413], [9.414424896240234, 46.17804751081413], [9.414424896240234, 46.17828523372499], [9.41476821899414, 46.17828523372499], [9.41476821899414, 46.17852295560811], [9.415111541748047, 46.17852295560811], [9.415111541748047, 46.183277177444694], [9.415454864501953, 46.183277177444694], [9.415454864501953, 46.18422797248055], [9.415111541748047, 46.18422797248055], [9.415111541748047, 46.18446566867017], [9.41476821899414, 46.18446566867017], [9.41476821899414, 46.18470336383206], [9.414081573486328, 46.18470336383206], [9.414081573486328, 46.184941057966206], [9.41305160522461, 46.184941057966206], [9.41305160522461, 46.18612951322096], [9.412708282470703, 46.18612951322096], [9.412708282470703, 46.186367201188716], [9.412364959716799, 46.186367201188716], [9.412364959716799, 46.186604888128734], [9.41202163696289, 46.186604888128734], [9.41202163696289, 46.18779330741286], [9.412364959716799, 46.18779330741286], [9.412364959716799, 46.18803098818649], [9.41305160522461, 46.18803098818649], [9.41305160522461, 46.18826866793239], [9.41751480102539, 46.18826866793239], [9.41751480102539, 46.18850634665056], [9.420948028564453, 46.18850634665056], [9.420948028564453, 46.18874402434101], [9.423694610595703, 46.18874402434101], [9.423694610595703, 46.18898170100372], [9.426441192626953, 46.18898170100372], [9.426441192626953, 46.18921937663871]], [[9.43674087524414, 46.17780978687552], [9.43674087524414, 46.17709660889324], [9.437084197998045, 46.17709660889324], [9.437084197998045, 46.17733433591508], [9.437427520751953, 46.17733433591508], [9.437427520751953, 46.17780978687552], [9.43674087524414, 46.17780978687552]]]}}, {\"id\": \"2\", \"type\": \"Feature\", \"properties\": {\"raster_val\": 255.0}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[9.405155181884766, 46.15664824017952], [9.405155181884766, 46.15617260627763], [9.405498504638674, 46.15617260627763], [9.405498504638674, 46.15641042374246], [9.405841827392578, 46.15641042374246], [9.405841827392578, 46.15664824017952], [9.405155181884766, 46.15664824017952]]]}}, {\"id\": \"3\", \"type\": \"Feature\", \"properties\": {\"raster_val\": 255.0}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[9.41030502319336, 46.15403220284411], [9.410648345947264, 46.15403220284411], [9.410648345947264, 46.15379437510149], [9.411334991455078, 46.15379437510149], [9.411334991455078, 46.153318716532915], [9.410991668701172, 46.153318716532915], [9.410991668701172, 46.153080885706956], [9.41030502319336, 46.153080885706956], [9.41030502319336, 46.153318716532915], [9.409961700439453, 46.153318716532915], [9.409961700439453, 46.15379437510149], [9.41030502319336, 46.15379437510149], [9.41030502319336, 46.15403220284411]]]}}, {\"id\": \"4\", \"type\": \"Feature\", \"properties\": {\"raster_val\": 0.0}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[9.143199920654297, 46.30271068141335], [9.143199920654297, 46.13999860748669], [9.495105743408203, 46.13999860748669], [9.495105743408203, 46.30271068141335], [9.143199920654297, 46.30271068141335]], [[9.426441192626953, 46.18921937663871], [9.426441192626953, 46.18898170100372], [9.423694610595703, 46.18898170100372], [9.423694610595703, 46.18874402434101], [9.420948028564453, 46.18874402434101], [9.420948028564453, 46.18850634665056], [9.41751480102539, 46.18850634665056], [9.41751480102539, 46.18826866793239], [9.41305160522461, 46.18826866793239], [9.41305160522461, 46.18803098818649], [9.412364959716799, 46.18803098818649], [9.412364959716799, 46.18779330741286], [9.41202163696289, 46.18779330741286], [9.41202163696289, 46.186604888128734], [9.412364959716799, 46.186604888128734], [9.412364959716799, 46.186367201188716], [9.412708282470703, 46.186367201188716], [9.412708282470703, 46.18612951322096], [9.41305160522461, 46.18612951322096], [9.41305160522461, 46.184941057966206], [9.414081573486328, 46.184941057966206], [9.414081573486328, 46.18470336383206], [9.41476821899414, 46.18470336383206], [9.41476821899414, 46.18446566867017], [9.415111541748047, 46.18446566867017], [9.415111541748047, 46.18422797248055], [9.415454864501953, 46.18422797248055], [9.415454864501953, 46.183277177444694], [9.415111541748047, 46.183277177444694], [9.415111541748047, 46.17852295560811], [9.41476821899414, 46.17852295560811], [9.41476821899414, 46.17828523372499], [9.414424896240234, 46.17828523372499], [9.414424896240234, 46.17804751081413], [9.414081573486328, 46.17804751081413], [9.414081573486328, 46.17780978687552], [9.413738250732422, 46.17780978687552], [9.413738250732422, 46.177572061909174], [9.413394927978517, 46.177572061909174], [9.413394927978517, 46.17733433591508], [9.412708282470703, 46.17733433591508], [9.412708282470703, 46.17709660889324], [9.412364959716799, 46.17709660889324], [9.412364959716799, 46.17685888084364], [9.41202163696289, 46.17685888084364], [9.41202163696289, 46.17662115176631], [9.411678314208983, 46.17662115176631], [9.411678314208983, 46.17638342166123], [9.411334991455078, 46.17638342166123], [9.411334991455078, 46.1761456905284], [9.410991668701172, 46.1761456905284], [9.410991668701172, 46.17590795836782], [9.410648345947264, 46.17590795836782], [9.410648345947264, 46.1756702251795], [9.41030502319336, 46.1756702251795], [9.41030502319336, 46.17543249096342], [9.409961700439453, 46.17543249096342], [9.409961700439453, 46.1751947557196], [9.409618377685547, 46.1751947557196], [9.409618377685547, 46.17495701944803], [9.40927505493164, 46.17495701944803], [9.40927505493164, 46.17471928214871], [9.408588409423828, 46.17471928214871], [9.408588409423828, 46.174243804466826], [9.407901763916016, 46.174243804466826], [9.407901763916016, 46.17400606408425], [9.40755844116211, 46.17400606408425], [9.40755844116211, 46.17376832267393], [9.406871795654297, 46.17376832267393], [9.406871795654297, 46.17353058023586], [9.406185150146484, 46.17353058023586], [9.406185150146484, 46.17329283677004], [9.405841827392578, 46.17329283677004], [9.405841827392578, 46.17305509227646], [9.40481185913086, 46.17305509227646], [9.40481185913086, 46.17281734675514], [9.404125213623047, 46.17281734675514], [9.404125213623047, 46.172579600206056], [9.403781890869139, 46.172579600206056], [9.403781890869139, 46.17210410402464], [9.403438568115234, 46.17210410402464], [9.403438568115234, 46.1716286037322], [9.402751922607422, 46.1716286037322], [9.402751922607422, 46.171390852044354], [9.40206527709961, 46.171390852044354], [9.40206527709961, 46.171153099328755], [9.401378631591797, 46.171153099328755], [9.401378631591797, 46.170915345585406], [9.39931869506836, 46.170915345585406], [9.39931869506836, 46.169726561452286], [9.399662017822266, 46.169726561452286], [9.399662017822266, 46.1694888015424], [9.40000534057617, 46.1694888015424], [9.40000534057617, 46.16925104060475], [9.400691986083984, 46.16925104060475], [9.400691986083984, 46.16901327863934], [9.40103530883789, 46.16901327863934], [9.40103530883789, 46.16853775162525], [9.401378631591797, 46.16853775162525], [9.401378631591797, 46.16711114591677], [9.401721954345703, 46.16711114591677], [9.401721954345703, 46.16616005488923], [9.40206527709961, 46.16616005488923], [9.40206527709961, 46.16330668314137], [9.402408599853516, 46.16330668314137], [9.402408599853516, 46.16306889548191], [9.40206527709961, 46.16306889548191], [9.40206527709961, 46.162355526336924], [9.401721954345703, 46.162355526336924], [9.401721954345703, 46.161404353088194], [9.401378631591797, 46.161404353088194], [9.401378631591797, 46.16116655720659], [9.40206527709961, 46.16116655720659], [9.40206527709961, 46.16092876029722], [9.402751922607422, 46.16092876029722], [9.402751922607422, 46.16116655720659], [9.407215118408203, 46.16116655720659], [9.407215118408203, 46.16092876029722], [9.40755844116211, 46.16092876029722], [9.40755844116211, 46.15688605558881], [9.407901763916016, 46.15688605558881], [9.407901763916016, 46.15664824017952], [9.410648345947264, 46.15664824017952], [9.410648345947264, 46.15688605558881], [9.411334991455078, 46.15688605558881], [9.411334991455078, 46.15712386997031], [9.411678314208983, 46.15712386997031], [9.411678314208983, 46.15736168332404], [9.41202163696289, 46.15736168332404], [9.41202163696289, 46.15712386997031], [9.412364959716799, 46.15712386997031], [9.412364959716799, 46.15688605558881], [9.412708282470703, 46.15688605558881], [9.412708282470703, 46.15641042374246], [9.41305160522461, 46.15641042374246], [9.41305160522461, 46.155459147716456], [9.413738250732422, 46.155459147716456], [9.413738250732422, 46.15569696826462], [9.414081573486328, 46.15569696826462], [9.414081573486328, 46.15593478778501], [9.415111541748047, 46.15593478778501], [9.415111541748047, 46.15617260627763], [9.415454864501953, 46.15617260627763], [9.415454864501953, 46.15641042374246], [9.416141510009766, 46.15641042374246], [9.416141510009766, 46.15664824017952], [9.416484832763672, 46.15664824017952], [9.416484832763672, 46.15712386997031], [9.416828155517578, 46.15712386997031], [9.416828155517578, 46.15736168332404], [9.417171478271484, 46.15736168332404], [9.417171478271484, 46.15759949565], [9.41751480102539, 46.15759949565], [9.41751480102539, 46.15783730694818], [9.417858123779297, 46.15783730694818], [9.417858123779297, 46.158075117218594], [9.418201446533203, 46.158075117218594], [9.418201446533203, 46.15831292646123], [9.418544769287108, 46.15831292646123], [9.418544769287108, 46.15855073467608], [9.418888092041016, 46.15855073467608], [9.418888092041016, 46.159026348022486], [9.419231414794922, 46.159026348022486], [9.419231414794922, 46.159501957257795], [9.419574737548828, 46.159501957257795], [9.419574737548828, 46.15973976033379], [9.419918060302734, 46.15973976033379], [9.419918060302734, 46.16021536340248], [9.42026138305664, 46.16021536340248], [9.42026138305664, 46.16069096236007], [9.420604705810547, 46.16069096236007], [9.420604705810547, 46.16092876029722], [9.420948028564453, 46.16092876029722], [9.420948028564453, 46.16116655720659], [9.42129135131836, 46.16116655720659], [9.42129135131836, 46.161404353088194], [9.421634674072264, 46.161404353088194], [9.421634674072264, 46.1618799417681], [9.421977996826174, 46.1618799417681], [9.421977996826174, 46.162355526336924], [9.422321319580078, 46.162355526336924], [9.422321319580078, 46.162831106794684], [9.422664642333984, 46.162831106794684], [9.422664642333984, 46.16306889548191], [9.42300796508789, 46.16306889548191], [9.42300796508789, 46.16354446977307], [9.42403793334961, 46.16354446977307], [9.42403793334961, 46.163782255376994], [9.424724578857424, 46.163782255376994], [9.424724578857424, 46.16425782350156], [9.425411224365234, 46.16425782350156], [9.425411224365234, 46.16449560602219], [9.426097869873047, 46.16449560602219], [9.426097869873047, 46.16473338751506], [9.427127838134766, 46.16473338751506], [9.427127838134766, 46.16497116798016], [9.428157806396484, 46.16497116798016], [9.428157806396484, 46.16520894741751], [9.428844451904297, 46.16520894741751], [9.428844451904297, 46.16497116798016], [9.429187774658201, 46.16497116798016], [9.429187774658201, 46.16473338751506], [9.429531097412108, 46.16473338751506], [9.429531097412108, 46.16449560602219], [9.432621002197267, 46.16449560602219], [9.432621002197267, 46.16473338751506], [9.438800811767578, 46.16473338751506], [9.438800811767578, 46.16497116798016], [9.43948745727539, 46.16497116798016], [9.43948745727539, 46.16544672582708], [9.439830780029297, 46.16544672582708], [9.439830780029297, 46.16711114591677], [9.43948745727539, 46.16711114591677], [9.43948745727539, 46.16734891610425], [9.435367584228517, 46.16734891610425], [9.435367584228517, 46.16758668526397], [9.435024261474608, 46.16758668526397], [9.435024261474608, 46.16806222050013], [9.434680938720703, 46.16806222050013], [9.434680938720703, 46.16853775162525], [9.434337615966797, 46.16853775162525], [9.434337615966797, 46.16901327863934], [9.433994293212889, 46.16901327863934], [9.433994293212889, 46.16925104060475], [9.433650970458984, 46.16925104060475], [9.433650970458984, 46.1694888015424], [9.43124771118164, 46.1694888015424], [9.43124771118164, 46.169726561452286], [9.430904388427736, 46.169726561452286], [9.430904388427736, 46.16996432033442], [9.43124771118164, 46.16996432033442], [9.43124771118164, 46.1702020781888], [9.431934356689453, 46.1702020781888], [9.431934356689453, 46.170915345585406], [9.432277679443358, 46.170915345585406], [9.432277679443358, 46.171153099328755], [9.432621002197267, 46.171153099328755], [9.432621002197267, 46.171390852044354], [9.433994293212889, 46.171390852044354], [9.433994293212889, 46.1716286037322], [9.434337615966797, 46.1716286037322], [9.434337615966797, 46.1718663543923], [9.434680938720703, 46.1718663543923], [9.434680938720703, 46.17281734675514], [9.434337615966797, 46.17281734675514], [9.434337615966797, 46.17305509227646], [9.433650970458984, 46.17305509227646], [9.433650970458984, 46.17376832267393], [9.433994293212889, 46.17376832267393], [9.433994293212889, 46.174243804466826], [9.434680938720703, 46.174243804466826], [9.434680938720703, 46.17400606408425], [9.435024261474608, 46.17400606408425], [9.435024261474608, 46.17376832267393], [9.435367584228517, 46.17376832267393], [9.435367584228517, 46.17400606408425], [9.435710906982424, 46.17400606408425], [9.435710906982424, 46.17448154382164], [9.436054229736328, 46.17448154382164], [9.436054229736328, 46.17471928214871], [9.436397552490234, 46.17471928214871], [9.436397552490234, 46.17495701944803], [9.43674087524414, 46.17495701944803], [9.43674087524414, 46.1751947557196], [9.438114166259766, 46.1751947557196], [9.438114166259766, 46.17543249096342], [9.438457489013672, 46.17543249096342], [9.438457489013672, 46.1756702251795], [9.438800811767578, 46.1756702251795], [9.438800811767578, 46.17638342166123], [9.439144134521484, 46.17638342166123], [9.439144134521484, 46.17685888084364], [9.438800811767578, 46.17685888084364], [9.438800811767578, 46.17804751081413], [9.438457489013672, 46.17804751081413], [9.438457489013672, 46.17876067646348], [9.438114166259766, 46.17876067646348], [9.438114166259766, 46.180186980013126], [9.438457489013672, 46.180186980013126], [9.438457489013672, 46.180424693674304], [9.439144134521484, 46.180424693674304], [9.439144134521484, 46.18066240630774], [9.439830780029297, 46.18066240630774], [9.439830780029297, 46.180424693674304], [9.440174102783201, 46.180424693674304], [9.440174102783201, 46.17709660889324], [9.441204071044922, 46.17709660889324], [9.441204071044922, 46.178998396291114], [9.441547393798828, 46.178998396291114], [9.441547393798828, 46.17994926532421], [9.441204071044922, 46.17994926532421], [9.441204071044922, 46.1813755380416], [9.441547393798828, 46.1813755380416], [9.441547393798828, 46.181613246564076], [9.44223403930664, 46.181613246564076], [9.44223403930664, 46.1818509540588], [9.443607330322267, 46.1818509540588], [9.443607330322267, 46.1820886605258], [9.445323944091797, 46.1820886605258], [9.445323944091797, 46.18232636596505], [9.44875717163086, 46.18232636596505], [9.44875717163086, 46.182564070376564], [9.449100494384766, 46.182564070376564], [9.449100494384766, 46.182801773760346], [9.449443817138674, 46.182801773760346], [9.449443817138674, 46.18517875107263], [9.449100494384766, 46.18517875107263], [9.449100494384766, 46.18589182422548], [9.44875717163086, 46.18589182422548], [9.44875717163086, 46.18612951322096], [9.447727203369139, 46.18612951322096], [9.447727203369139, 46.186367201188716], [9.44498062133789, 46.186367201188716], [9.44498062133789, 46.186604888128734], [9.43948745727539, 46.186604888128734], [9.43948745727539, 46.18684257404102], [9.438800811767578, 46.18684257404102], [9.438800811767578, 46.187080258925576], [9.43777084350586, 46.187080258925576], [9.43777084350586, 46.18731794278239], [9.436397552490234, 46.18731794278239], [9.436397552490234, 46.18755562561149], [9.435024261474608, 46.18755562561149], [9.435024261474608, 46.18779330741286], [9.433994293212889, 46.18779330741286], [9.433994293212889, 46.18803098818649], [9.433307647705078, 46.18803098818649], [9.433307647705078, 46.18826866793239], [9.432964324951172, 46.18826866793239], [9.432964324951172, 46.18850634665056], [9.432277679443358, 46.18850634665056], [9.432277679443358, 46.18874402434101], [9.43124771118164, 46.18874402434101], [9.43124771118164, 46.18898170100372], [9.429531097412108, 46.18898170100372], [9.429531097412108, 46.18921937663871], [9.426441192626953, 46.18921937663871]], [[9.405155181884766, 46.15664824017952], [9.405155181884766, 46.15617260627763], [9.405498504638674, 46.15617260627763], [9.405498504638674, 46.15641042374246], [9.405841827392578, 46.15641042374246], [9.405841827392578, 46.15664824017952], [9.405155181884766, 46.15664824017952]], [[9.41030502319336, 46.15403220284411], [9.41030502319336, 46.15379437510149], [9.409961700439453, 46.15379437510149], [9.409961700439453, 46.153318716532915], [9.41030502319336, 46.153318716532915], [9.41030502319336, 46.153080885706956], [9.410991668701172, 46.153080885706956], [9.410991668701172, 46.153318716532915], [9.411334991455078, 46.153318716532915], [9.411334991455078, 46.15379437510149], [9.410648345947264, 46.15379437510149], [9.410648345947264, 46.15403220284411], [9.41030502319336, 46.15403220284411]]]}}]}", "n_shapes_geojson": 5, "duration_run": 153.70355319976807, "message": "ok", "request_id": "test_invoke_id"}
events/colico_prompt1.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [
2
+ {"type": "point", "data": [870, 500], "label": 1},
3
+ {"type": "point", "data": [820, 600], "label": 0},
4
+ {"type": "rectangle", "data": [757, 470, 876, 616]}
5
+ ]
events/example_output.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "FeatureCollection",
3
+ "features": [
4
+ {
5
+ "type": "Feature",
6
+ "geometry": {
7
+ "type": "Polygon",
8
+ "coordinates": [
9
+ [
10
+ [46.143, 9.361],
11
+ [46.151, 9.401],
12
+ [46.137, 9.353]
13
+ ]
14
+ ]
15
+ },
16
+ "properties": {"name": "Colico"}
17
+ }
18
+ ]
19
+ }
events/payload_lisa_teglio.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "bbox":{"ne":{"lat":46.172594687922256,"lng":10.079248798586057},"sw":{"lat":46.16789155404419,"lng":10.069077862001585}},
3
+ "string_prompt": "you are a skilled gis analyst with a lot of expertise in photogrammetry and gis field. You need to identify the areas with trees in this photogrammetric image. Please output segmentation mask and explain why.",
4
+ "zoom":17,"source_type":"Esri.WorldImagery"
5
+ }
events/payload_multiprompt_api_request_body.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox": {
3
+ "ne": {
4
+ "lat": 46.180194387028855,
5
+ "lng": 9.426848938165525
6
+ },
7
+ "sw": {
8
+ "lat": 46.17511301243843,
9
+ "lng": 9.415862610040527
10
+ }
11
+ },
12
+ "prompt": [
13
+ {
14
+ "id": 448,
15
+ "type": "point",
16
+ "data": {
17
+ "lat": 46.176256754439535,
18
+ "lng": 9.421805260519237
19
+ },
20
+ "label": 1
21
+ },
22
+ {
23
+ "id": 607,
24
+ "type": "point",
25
+ "data": {
26
+ "lat": 46.17625675443,
27
+ "lng": 9.4218052604
28
+ },
29
+ "label": 0
30
+ },
31
+ {
32
+ "id": 861,
33
+ "type": "rectangle",
34
+ "data": {
35
+ "ne": {
36
+ "lat": 46.19067068238,
37
+ "lng": 9.44815864957
38
+ },
39
+ "sw": {
40
+ "lat": 46.17625678,
41
+ "lng": 9.42180525
42
+ }
43
+ }
44
+ }
45
+ ],
46
+ "zoom": 17,
47
+ "source_type": "OpenStreetMap.Mapnik"
48
+ }
events/payload_multiprompt_api_response_body_failure.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"duration_run": 0.063, "message": "Bad Request", "request_id": "test_invoke_id"}
events/payload_multiprompt_api_response_body_success.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "n_predictions": 1,
3
+ "geojson": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"raster_val\":255.0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532]]]},\"id\":0},{\"type\":\"Feature\",\"properties\":{\"raster_val\":0.0},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[9.143199920654297,46.30271068141335],[9.495105743408203,46.30271068141335],[9.495105743408203,46.13999860748669],[9.143199920654297,46.13999860748669],[9.143199920654297,46.30271068141335]],[[9.426854252815245,46.17510931936532],[9.426854252815245,46.18019812286394],[9.415857195854185,46.18019812286394],[9.415857195854185,46.17510931936532],[9.426854252815245,46.17510931936532]]]},\"id\":1}]}",
4
+ "n_shapes_geojson": 5,
5
+ "duration_run": 6.703,
6
+ "message": "ok",
7
+ "request_id": "test_invoke_id"
8
+ }
events/payload_point.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox": {
3
+ "ne": {"lat": 45.699, "lng": 127.1},
4
+ "sw": {"lat": 30.1, "lng": 148.492}
5
+ },
6
+ "prompt": [{
7
+ "type": "point",
8
+ "data": {"lat": 36.91, "lng": 136.854},
9
+ "label": 0
10
+ }],
11
+ "zoom": 6,
12
+ "source_type": "OpenStreetMap",
13
+ "debug": true
14
+ }
events/payload_point2.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox": {
3
+ "ne": {"lat": 38.03932961278458, "lng": 15.36808069832851},
4
+ "sw": {"lat": 37.455509218936974, "lng": 14.632807441554068}
5
+ },
6
+ "prompt": [{
7
+ "type": "point",
8
+ "data": {"lat": 37.0, "lng": 15.0},
9
+ "label": 0
10
+ }],
11
+ "zoom": 10,
12
+ "source_type": "OpenStreetMap",
13
+ "debug": true
14
+ }
events/payload_point_eolie.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox": {
3
+ "ne": {
4
+ "lat": 39.036252959636606,
5
+ "lng": 15.040283203125002
6
+ },
7
+ "sw": {
8
+ "lat": 38.302869955150044,
9
+ "lng": 13.634033203125002
10
+ }
11
+ },
12
+ "prompt": [
13
+ {
14
+ "type": "point",
15
+ "data": {
16
+ "lat": 38.48542007717153,
17
+ "lng": 14.921846904165468
18
+ },
19
+ "label": 1
20
+ }
21
+ ],
22
+ "zoom": 10,
23
+ "source_type": "OpenStreetMap"
24
+ }
events/payload_point_error_int_str.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input": {
3
+ "version": "2.0",
4
+ "routeKey": "POST /lambda-ml-fastsam-api",
5
+ "rawPath": "/preview/lambda-ml-fastsam-api",
6
+ "rawQueryString": "",
7
+ "headers": {
8
+ "accept-encoding": "gzip",
9
+ "authorization": "Bearer aaa.bbb.ccc",
10
+ "cdn-loop": "cloudflare; loops=1; subreqs=1",
11
+ "cf-connecting-ip": "2a06:98c0:3600::103",
12
+ "cf-connecting-o2o": "1",
13
+ "cf-ew-via": "15",
14
+ "cf-ray": "82f7a58375170e5d-MXP",
15
+ "cf-visitor": "{\"scheme\":\"https\"}",
16
+ "cf-worker": "example-domain.com",
17
+ "content-length": "257",
18
+ "content-type": "application/json",
19
+ "host": "example-domain-aws.execute-api.eu-west-1.amazonaws.com",
20
+ "x-amzn-trace-id": "Root=1-656bc9e7-3ea67446317bedcb13ac07e2",
21
+ "x-forwarded-for": "2a06:98c0:3600::103, 162.158.129.178",
22
+ "x-forwarded-port": "443",
23
+ "x-forwarded-proto": "https"
24
+ },
25
+ "requestContext": {
26
+ "accountId": "01234567890",
27
+ "apiId": "example-domain-aws",
28
+ "authorizer": {
29
+ "jwt": {
30
+ "claims": {
31
+ "aud": "[http://preview-ml-lambda/ https://xxx.eu.auth0.com/userinfo]",
32
+ "azp": "qYZNGiwEHeZe2QCVXljIDWENwSfKhd8T",
33
+ "exp": "1701649239",
34
+ "iat": "1701562839",
35
+ "iss": "https://xxx.eu.auth0.com/",
36
+ "scope": "openid profile email",
37
+ "sub": "auth0|sub-auth-xxxx"
38
+ },
39
+ "scopes": null
40
+ }
41
+ },
42
+ "domainName": "example-domain-aws.execute-api.eu-west-1.amazonaws.com",
43
+ "domainPrefix": "example-domain-aws",
44
+ "http": {
45
+ "method": "POST",
46
+ "path": "/preview/lambda-ml-fastsam-api",
47
+ "protocol": "HTTP/1.1",
48
+ "sourceIp": "162.158.129.178",
49
+ "userAgent": ""
50
+ },
51
+ "requestId": "PVx8KhjijoEEJPw=",
52
+ "routeKey": "POST /lambda-ml-fastsam-api",
53
+ "stage": "preview",
54
+ "time": "03/Dec/2023:00:20:55 +0000",
55
+ "timeEpoch": 1701562855106
56
+ },
57
+ "body": "{\"bbox\":{\"ne\":{\"lat\":-1.4939713066293112,\"lng\":155.30273437500003},\"sw\":{\"lat\":-52.32191088594772,\"lng\":65.30273437500001}},\"prompt\":[{\"type\":\"point\",\"data\":{\"lat\":-42.488301979602255,\"lng\":146.77734375000003},\"label\":0}],\"zoom\":4,\"source_type\":\"Satellite\"}",
58
+ "isBase64Encoded": false
59
+ },
60
+ "output": {}
61
+
62
+ }
events/payload_point_rectangle_colico.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input": {
3
+ "bbox": {
4
+ "ne": {
5
+ "lat": 46.302592089330524,
6
+ "lng": 9.49493408203125
7
+ },
8
+ "sw": {
9
+ "lat": 46.14011755129237,
10
+ "lng": 9.143371582031252
11
+ }
12
+ },
13
+ "prompt": [
14
+ {
15
+ "type": "rectangle",
16
+ "data": {
17
+ "lat": 46.18363372751015,
18
+ "lng": 9.443607330322267
19
+ },
20
+ "label": 1
21
+ },
22
+ {
23
+ "type": "point",
24
+ "data": {
25
+ "lat": 46.159620858924264,
26
+ "lng": 9.427127838134767
27
+ },
28
+ "label": 0
29
+ },
30
+ {
31
+ "type": "rectangle",
32
+ "data": {
33
+ "ne": {
34
+ "lat": 46.19052657426052,
35
+ "lng": 9.402408599853517
36
+ },
37
+ "sw": {
38
+ "lat": 46.15652933208947,
39
+ "lng": 9.442920684814455
40
+ }
41
+ }
42
+ }
43
+ ],
44
+ "zoom": 12,
45
+ "source_type": "Satellite"
46
+ },
47
+ "output": {}
48
+ }
events/payload_rectangle.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bbox": {
3
+ "ne": {"lat": 45.699, "lng": 127.1},
4
+ "sw": {"lat": 30.1, "lng": 148.492}
5
+ },
6
+ "prompt": [{
7
+ "type": "rectangle",
8
+ "data": [400, 460, 524, 628]
9
+ }],
10
+ "zoom": 6,
11
+ "source_type": "Satellite"
12
+ }
events/payloads_body_base64.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "2.0",
3
+ "routeKey": "POST /prediction",
4
+ "rawPath": "/localhost/prediction",
5
+ "rawQueryString": "",
6
+ "headers": {
7
+ "accept": "application/json, text/plain, */*",
8
+ "accept-encoding": "gzip, deflate, br",
9
+ "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
10
+ "authorization": "Bearer ey...",
11
+ "content-length": "126",
12
+ "content-type": "application/json",
13
+ "host": "xxx.execute-api.eu-west-1.amazonaws.com",
14
+ "origin": "http://localhost:3000",
15
+ "referer": "http://localhost:3000/",
16
+ "sec-fetch-dest": "empty",
17
+ "sec-fetch-mode": "cors",
18
+ "sec-fetch-site": "cross-site",
19
+ "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
20
+ "x-amzn-trace-id": "Root=1-xxx-aaaa",
21
+ "x-forwarded-for": "1.1.1.1",
22
+ "x-forwarded-port": "443",
23
+ "x-forwarded-proto": "https"
24
+ },
25
+ "requestContext": {
26
+ "accountId": "123",
27
+ "apiId": "api-id-aws",
28
+ "authorizer": {
29
+ "jwt": {
30
+ "claims": {
31
+ "scope": "openid profile email"
32
+ },
33
+ "scopes": null
34
+ }
35
+ },
36
+ "domainName": "xxx.execute-api.eu-west-1.amazonaws.com",
37
+ "domainPrefix": "xxx",
38
+ "http": {
39
+ "method": "POST",
40
+ "path": "/localhost/prediction",
41
+ "protocol": "HTTP/1.1",
42
+ "sourceIp": "52.143.157.36",
43
+ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
44
+ },
45
+ "requestId": "aaa-bbbb=",
46
+ "routeKey": "POST /prediction",
47
+ "stage": "localhost",
48
+ "time": "21/May/2023:19:32:35 +0000",
49
+ "timeEpoch": 1684697555723
50
+ },
51
+ "body": "eyJiYm94IjogWzEsIDIsIDMsIDRdLCAicG9pbnRzIjogW1s1LCA2XV19"
52
+ }