geoai-py 0.5.6__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. geoai_py-0.7.0/.github/workflows/docker-image.yml +16 -0
  2. geoai_py-0.7.0/.github/workflows/docker-publish.yml +45 -0
  3. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/docs-build.yml +1 -1
  4. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/docs.yml +1 -1
  5. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/macos.yml +1 -1
  6. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/ubuntu.yml +1 -1
  7. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/windows.yml +1 -1
  8. geoai_py-0.7.0/Dockerfile +54 -0
  9. {geoai_py-0.5.6 → geoai_py-0.7.0}/PKG-INFO +2 -1
  10. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/data_visualization.ipynb +3 -3
  11. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_data.ipynb +1 -1
  12. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/edit_vector.ipynb +2 -2
  13. geoai_py-0.7.0/docs/examples/samgeo.ipynb +190 -0
  14. geoai_py-0.7.0/docs/examples/train_landcover_classification.ipynb +271 -0
  15. geoai_py-0.7.0/docs/examples/train_segmentation_model.ipynb +411 -0
  16. geoai_py-0.7.0/docs/sam.md +3 -0
  17. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/__init__.py +1 -1
  18. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/classify.py +23 -24
  19. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/geoai.py +10 -4
  20. geoai_py-0.7.0/geoai/sam.py +832 -0
  21. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/train.py +1041 -9
  22. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/utils.py +342 -0
  23. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/PKG-INFO +2 -1
  24. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/SOURCES.txt +8 -0
  25. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/requires.txt +1 -0
  26. {geoai_py-0.5.6 → geoai_py-0.7.0}/mkdocs.yml +5 -0
  27. {geoai_py-0.5.6 → geoai_py-0.7.0}/pyproject.toml +2 -2
  28. {geoai_py-0.5.6 → geoai_py-0.7.0}/requirements.txt +1 -0
  29. {geoai_py-0.5.6 → geoai_py-0.7.0}/.editorconfig +0 -0
  30. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/FUNDING.yml +0 -0
  31. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  32. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  33. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  34. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/dependabot.yml +0 -0
  35. {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/pypi.yml +0 -0
  36. {geoai_py-0.5.6 → geoai_py-0.7.0}/.gitignore +0 -0
  37. {geoai_py-0.5.6 → geoai_py-0.7.0}/.pre-commit-config.yaml +0 -0
  38. {geoai_py-0.5.6 → geoai_py-0.7.0}/LICENSE +0 -0
  39. {geoai_py-0.5.6 → geoai_py-0.7.0}/MANIFEST.in +0 -0
  40. {geoai_py-0.5.6 → geoai_py-0.7.0}/README.md +0 -0
  41. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/CNAME +0 -0
  42. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo.ico +0 -0
  43. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo.png +0 -0
  44. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo_rect.png +0 -0
  45. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/changelog.md +0 -0
  46. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/classify.md +0 -0
  47. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/contributing.md +0 -0
  48. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/download.md +0 -0
  49. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/_template.ipynb +0 -0
  50. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_africa.ipynb +0 -0
  51. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_china.ipynb +0 -0
  52. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_usa.ipynb +0 -0
  53. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_regularization.ipynb +0 -0
  54. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/car_detection.ipynb +0 -0
  55. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/create_vector.ipynb +0 -0
  56. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
  57. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/raster_viz.ipynb +0 -0
  58. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/vector_viz.ipynb +0 -0
  59. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_naip.ipynb +0 -0
  60. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_sentinel2.ipynb +0 -0
  61. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/geometric_properties.ipynb +0 -0
  62. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/globe_projection.ipynb +0 -0
  63. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/image_chips.ipynb +0 -0
  64. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/jupytext.toml +0 -0
  65. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/parking_spot_detection.ipynb +0 -0
  66. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/planetary_computer.ipynb +0 -0
  67. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
  68. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/regularization.ipynb +0 -0
  69. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/arcgis.ipynb +0 -0
  70. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
  71. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
  72. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/box_prompts.ipynb +0 -0
  73. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/fast_sam.ipynb +0 -0
  74. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/input_prompts.ipynb +0 -0
  75. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
  76. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
  77. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
  78. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/satellite.ipynb +0 -0
  79. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
  80. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/text_prompts.ipynb +0 -0
  81. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
  82. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/ship_detection.ipynb +0 -0
  83. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/solar_panel_detection.ipynb +0 -0
  84. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/text_prompt_segmentation.ipynb +0 -0
  85. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_building_footprints_usa.ipynb +0 -0
  86. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_car_detection.ipynb +0 -0
  87. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_object_detection_model.ipynb +0 -0
  88. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_ship_detection.ipynb +0 -0
  89. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_solar_panel_detection.ipynb +0 -0
  90. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_water_detection.ipynb +0 -0
  91. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/view_metadata.ipynb +0 -0
  92. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/water_dynamics.ipynb +0 -0
  93. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/wetland_mapping.ipynb +0 -0
  94. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/extract.md +0 -0
  95. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/faq.md +0 -0
  96. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/geoai.md +0 -0
  97. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/hf.md +0 -0
  98. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/index.md +0 -0
  99. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/installation.md +0 -0
  100. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/overrides/main.html +0 -0
  101. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/segment.md +0 -0
  102. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/segmentation.md +0 -0
  103. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/train.md +0 -0
  104. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/usage.md +0 -0
  105. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/utils.md +0 -0
  106. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/workshops/GeoAI_Workshop_2025.ipynb +0 -0
  107. {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/workshops/jupytext.toml +0 -0
  108. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/download.py +0 -0
  109. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/extract.py +1 -1
  110. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/hf.py +0 -0
  111. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/segment.py +0 -0
  112. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/segmentation.py +0 -0
  113. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/dependency_links.txt +0 -0
  114. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/entry_points.txt +0 -0
  115. {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/top_level.txt +0 -0
  116. {geoai_py-0.5.6 → geoai_py-0.7.0}/requirements_docs.txt +0 -0
  117. {geoai_py-0.5.6 → geoai_py-0.7.0}/setup.cfg +0 -0
  118. {geoai_py-0.5.6 → geoai_py-0.7.0}/tests/__init__.py +0 -0
  119. {geoai_py-0.5.6 → geoai_py-0.7.0}/tests/test_geoai.py +0 -0
@@ -0,0 +1,16 @@
1
+ name: Docker Image CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - name: Build the Docker image
16
+ run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
@@ -0,0 +1,45 @@
1
+ name: Publish Docker image
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ push_to_registries:
9
+ name: Push Docker image to multiple registries
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ packages: write
13
+ contents: read
14
+ steps:
15
+ - name: Check out the repo
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Log in to Docker Hub
19
+ uses: docker/login-action@v3
20
+ with:
21
+ username: ${{ secrets.DOCKER_USERNAME }}
22
+ password: ${{ secrets.DOCKER_PASSWORD }}
23
+
24
+ - name: Log in to the Container registry
25
+ uses: docker/login-action@v3
26
+ with:
27
+ registry: ghcr.io
28
+ username: ${{ github.actor }}
29
+ password: ${{ secrets.GITHUB_TOKEN }}
30
+
31
+ - name: Extract metadata (tags, labels) for Docker
32
+ id: meta
33
+ uses: docker/metadata-action@v5
34
+ with:
35
+ images: |
36
+ giswqs/geoai
37
+ ghcr.io/${{ github.repository }}
38
+
39
+ - name: Build and push Docker images
40
+ uses: docker/build-push-action@v6
41
+ with:
42
+ context: .
43
+ push: true
44
+ tags: ${{ steps.meta.outputs.tags }}
45
+ labels: ${{ steps.meta.outputs.labels }}
@@ -17,7 +17,7 @@ jobs:
17
17
  fetch-depth: 0
18
18
 
19
19
  - name: Install uv
20
- uses: astral-sh/setup-uv@v5
20
+ uses: astral-sh/setup-uv@v6
21
21
  with:
22
22
  version: "0.4.16"
23
23
  enable-cache: false
@@ -16,7 +16,7 @@ jobs:
16
16
  fetch-depth: 0
17
17
 
18
18
  - name: Install uv
19
- uses: astral-sh/setup-uv@v5
19
+ uses: astral-sh/setup-uv@v6
20
20
  with:
21
21
  version: "0.4.16"
22
22
  enable-cache: false
@@ -22,7 +22,7 @@ jobs:
22
22
  - uses: actions/checkout@v4
23
23
 
24
24
  - name: Install uv
25
- uses: astral-sh/setup-uv@v5
25
+ uses: astral-sh/setup-uv@v6
26
26
  with:
27
27
  version: "0.4.16"
28
28
  enable-cache: false
@@ -20,7 +20,7 @@ jobs:
20
20
  - uses: actions/checkout@v4
21
21
 
22
22
  - name: Install uv
23
- uses: astral-sh/setup-uv@v5
23
+ uses: astral-sh/setup-uv@v6
24
24
  with:
25
25
  version: "0.4.16"
26
26
  enable-cache: false
@@ -18,7 +18,7 @@ jobs:
18
18
  - uses: actions/checkout@v4
19
19
 
20
20
  - name: Install uv
21
- uses: astral-sh/setup-uv@v5
21
+ uses: astral-sh/setup-uv@v6
22
22
  with:
23
23
  version: "0.4.16"
24
24
  enable-cache: false
@@ -0,0 +1,54 @@
1
+ FROM quay.io/jupyter/base-notebook:latest
2
+
3
+ # -------------------------------------------------------
4
+ # 1. Install system-level packages (minimal, just git)
5
+ # -------------------------------------------------------
6
+ USER root
7
+ RUN apt-get update && \
8
+ apt-get install -y git && \
9
+ rm -rf /var/lib/apt/lists/*
10
+
11
+ # -------------------------------------------------------
12
+ # 2. Install geospatial Python packages via conda (base env)
13
+ # -------------------------------------------------------
14
+ RUN mamba install -n base -c conda-forge \
15
+ geoai \
16
+ overturemaps -y && \
17
+ fix-permissions "${CONDA_DIR}"
18
+
19
+ # -------------------------------------------------------
20
+ # 3. Environment variables
21
+ # -------------------------------------------------------
22
+ ENV PROJ_LIB=/opt/conda/share/proj
23
+ ENV GDAL_DATA=/opt/conda/share/gdal
24
+ ENV LOCALTILESERVER_CLIENT_PREFIX='proxy/{port}'
25
+
26
+ # -------------------------------------------------------
27
+ # 4. Copy source code (do this *after* package installs to improve caching)
28
+ # -------------------------------------------------------
29
+ COPY . /home/jovyan/geoai
30
+ WORKDIR /home/jovyan/geoai
31
+
32
+
33
+ # -------------------------------------------------------
34
+ # 5. Build and install geoai from source
35
+ # -------------------------------------------------------
36
+ # Prevent setuptools_scm issues if .git is missing
37
+ ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_GEOAI=0.0.0
38
+
39
+ RUN rm -rf /home/jovyan/geoai/geoai.egg-info && \
40
+ pip install . && \
41
+ mkdir -p /home/jovyan/work && \
42
+ fix-permissions /home/jovyan
43
+
44
+ # -------------------------------------------------------
45
+ # 6. Set back to default user
46
+ # -------------------------------------------------------
47
+ WORKDIR /home/jovyan
48
+ USER jovyan
49
+
50
+
51
+ # -------------------------------------------------------
52
+ # 7. Run the docker container
53
+ # -------------------------------------------------------
54
+ # docker run -it -p 8888:8888 -v $(pwd):/home/jovyan/work giswqs/geoai:latest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geoai-py
3
- Version: 0.5.6
3
+ Version: 0.7.0
4
4
  Summary: A Python package for using Artificial Intelligence (AI) with geospatial data
5
5
  Author-email: Qiusheng Wu <giswqs@gmail.com>
6
6
  License: MIT License
@@ -26,6 +26,7 @@ Requires-Dist: leafmap
26
26
  Requires-Dist: localtileserver
27
27
  Requires-Dist: mapclassify
28
28
  Requires-Dist: maplibre
29
+ Requires-Dist: opencv-python-headless
29
30
  Requires-Dist: overturemaps
30
31
  Requires-Dist: planetary-computer
31
32
  Requires-Dist: pystac-client
@@ -334,7 +334,7 @@
334
334
  "cell_type": "markdown",
335
335
  "metadata": {},
336
336
  "source": [
337
- "Visualize the raster data on an interactive map with Google Satellite imagery as the background:"
337
+ "Visualize the raster data on an interactive map with Esri.WorldImagery imagery as the background:"
338
338
  ]
339
339
  },
340
340
  {
@@ -343,14 +343,14 @@
343
343
  "metadata": {},
344
344
  "outputs": [],
345
345
  "source": [
346
- "view_raster(data, basemap=\"Google Satellite\")"
346
+ "view_raster(data, basemap=\"Esri.WorldImagery\")"
347
347
  ]
348
348
  },
349
349
  {
350
350
  "cell_type": "markdown",
351
351
  "metadata": {},
352
352
  "source": [
353
- "This interactive visualization places the sampled data in its real-world geographic context, allowing you to see how it aligns with the Google Satellite imagery.\n",
353
+ "This interactive visualization places the sampled data in its real-world geographic context, allowing you to see how it aligns with the Esri.WorldImagery imagery.\n",
354
354
  "\n",
355
355
  "## Key Takeaways\n",
356
356
  "\n",
@@ -58,7 +58,7 @@
58
58
  "outputs": [],
59
59
  "source": [
60
60
  "m = leafmap.Map(center=[47.6526, -117.5923], zoom=16)\n",
61
- "m.add_basemap(\"Google Satellite\")\n",
61
+ "m.add_basemap(\"Esri.WorldImagery\")\n",
62
62
  "m"
63
63
  ]
64
64
  },
@@ -51,7 +51,7 @@
51
51
  "outputs": [],
52
52
  "source": [
53
53
  "m = geoai.MapLibre()\n",
54
- "m.add_basemap(\"Google Satellite\")\n",
54
+ "m.add_basemap(\"Esri.WorldImagery\")\n",
55
55
  "url = \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/naip_train_buildings.geojson\""
56
56
  ]
57
57
  },
@@ -102,7 +102,7 @@
102
102
  ],
103
103
  "metadata": {
104
104
  "kernelspec": {
105
- "display_name": "Python 3 (ipykernel)",
105
+ "display_name": "geo",
106
106
  "language": "python",
107
107
  "name": "python3"
108
108
  },
@@ -0,0 +1,190 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Semantic Segmentation with SAM and GeoAI\n",
8
+ "\n",
9
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/samgeo.ipynb)\n",
10
+ "\n",
11
+ "## Install package\n",
12
+ "To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": [
21
+ "# %pip install geoai-py"
22
+ ]
23
+ },
24
+ {
25
+ "cell_type": "markdown",
26
+ "metadata": {},
27
+ "source": [
28
+ "## Import libraries"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": null,
34
+ "metadata": {},
35
+ "outputs": [],
36
+ "source": [
37
+ "import geoai\n",
38
+ "from geoai.sam import SamGeo"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "markdown",
43
+ "metadata": {},
44
+ "source": [
45
+ "## Download sample data"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "metadata": {},
52
+ "outputs": [],
53
+ "source": [
54
+ "url = (\n",
55
+ " \"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/sam_demo_image.tif\"\n",
56
+ ")\n",
57
+ "image = geoai.download_file(url)"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "markdown",
62
+ "metadata": {},
63
+ "source": [
64
+ "## Visualize data"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": null,
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": [
73
+ "geoai.view_raster(url)"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "markdown",
78
+ "metadata": {},
79
+ "source": [
80
+ "## Initialize model"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "sam = SamGeo(model=\"facebook/sam-vit-huge\", automatic=True)"
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "markdown",
94
+ "metadata": {},
95
+ "source": [
96
+ "## Automatic mask generation"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "code",
101
+ "execution_count": null,
102
+ "metadata": {},
103
+ "outputs": [],
104
+ "source": [
105
+ "sam.generate(source=image, output=\"masks.tif\", foreground=True)"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "markdown",
110
+ "metadata": {},
111
+ "source": [
112
+ "## Visualize results"
113
+ ]
114
+ },
115
+ {
116
+ "cell_type": "code",
117
+ "execution_count": null,
118
+ "metadata": {},
119
+ "outputs": [],
120
+ "source": [
121
+ "sam.show_masks()"
122
+ ]
123
+ },
124
+ {
125
+ "cell_type": "code",
126
+ "execution_count": null,
127
+ "metadata": {},
128
+ "outputs": [],
129
+ "source": [
130
+ "sam.show_anns(alpha=0.6)"
131
+ ]
132
+ },
133
+ {
134
+ "cell_type": "code",
135
+ "execution_count": null,
136
+ "metadata": {},
137
+ "outputs": [],
138
+ "source": [
139
+ "geoai.view_raster(\"masks.tif\", colormap=\"tab20\", opacity=0.6, basemap=url)"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "metadata": {},
146
+ "outputs": [],
147
+ "source": [
148
+ "geoai.create_split_map(\n",
149
+ " left_layer=\"masks.tif\",\n",
150
+ " right_layer=url,\n",
151
+ " left_args={\n",
152
+ " \"colormap\": \"tab20\",\n",
153
+ " \"opacity\": 1,\n",
154
+ " },\n",
155
+ ")"
156
+ ]
157
+ },
158
+ {
159
+ "cell_type": "markdown",
160
+ "metadata": {},
161
+ "source": [
162
+ "![image](https://github.com/user-attachments/assets/8735160b-efb3-4b3c-9b1f-f83188874585)"
163
+ ]
164
+ }
165
+ ],
166
+ "metadata": {
167
+ "jupytext": {
168
+ "default_lexer": "ipython3"
169
+ },
170
+ "kernelspec": {
171
+ "display_name": "Python 3",
172
+ "language": "python",
173
+ "name": "python3"
174
+ },
175
+ "language_info": {
176
+ "codemirror_mode": {
177
+ "name": "ipython",
178
+ "version": 3
179
+ },
180
+ "file_extension": ".py",
181
+ "mimetype": "text/x-python",
182
+ "name": "python",
183
+ "nbconvert_exporter": "python",
184
+ "pygments_lexer": "ipython3",
185
+ "version": "3.12.2"
186
+ }
187
+ },
188
+ "nbformat": 4,
189
+ "nbformat_minor": 4
190
+ }