geoai-py 0.5.6__tar.gz → 0.6.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 (117) hide show
  1. geoai_py-0.6.0/.github/workflows/docker-image.yml +16 -0
  2. geoai_py-0.6.0/.github/workflows/docker-publish.yml +45 -0
  3. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/docs-build.yml +1 -1
  4. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/docs.yml +1 -1
  5. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/macos.yml +1 -1
  6. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/ubuntu.yml +1 -1
  7. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/windows.yml +1 -1
  8. geoai_py-0.6.0/Dockerfile +54 -0
  9. {geoai_py-0.5.6 → geoai_py-0.6.0}/PKG-INFO +2 -1
  10. geoai_py-0.6.0/docs/examples/samgeo.ipynb +190 -0
  11. geoai_py-0.6.0/docs/sam.md +3 -0
  12. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/__init__.py +1 -1
  13. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/classify.py +23 -24
  14. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/geoai.py +3 -3
  15. geoai_py-0.6.0/geoai/sam.py +832 -0
  16. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/utils.py +329 -0
  17. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/PKG-INFO +2 -1
  18. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/SOURCES.txt +6 -0
  19. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/requires.txt +1 -0
  20. {geoai_py-0.5.6 → geoai_py-0.6.0}/mkdocs.yml +3 -0
  21. {geoai_py-0.5.6 → geoai_py-0.6.0}/pyproject.toml +2 -2
  22. {geoai_py-0.5.6 → geoai_py-0.6.0}/requirements.txt +1 -0
  23. {geoai_py-0.5.6 → geoai_py-0.6.0}/.editorconfig +0 -0
  24. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/FUNDING.yml +0 -0
  25. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  26. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  27. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  28. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/dependabot.yml +0 -0
  29. {geoai_py-0.5.6 → geoai_py-0.6.0}/.github/workflows/pypi.yml +0 -0
  30. {geoai_py-0.5.6 → geoai_py-0.6.0}/.gitignore +0 -0
  31. {geoai_py-0.5.6 → geoai_py-0.6.0}/.pre-commit-config.yaml +0 -0
  32. {geoai_py-0.5.6 → geoai_py-0.6.0}/LICENSE +0 -0
  33. {geoai_py-0.5.6 → geoai_py-0.6.0}/MANIFEST.in +0 -0
  34. {geoai_py-0.5.6 → geoai_py-0.6.0}/README.md +0 -0
  35. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/CNAME +0 -0
  36. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/assets/logo.ico +0 -0
  37. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/assets/logo.png +0 -0
  38. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/assets/logo_rect.png +0 -0
  39. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/changelog.md +0 -0
  40. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/classify.md +0 -0
  41. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/contributing.md +0 -0
  42. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/download.md +0 -0
  43. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/_template.ipynb +0 -0
  44. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/building_footprints_africa.ipynb +0 -0
  45. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/building_footprints_china.ipynb +0 -0
  46. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/building_footprints_usa.ipynb +0 -0
  47. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/building_regularization.ipynb +0 -0
  48. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/car_detection.ipynb +0 -0
  49. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/create_vector.ipynb +0 -0
  50. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/data_visualization.ipynb +0 -0
  51. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
  52. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/dataviz/raster_viz.ipynb +0 -0
  53. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/dataviz/vector_viz.ipynb +0 -0
  54. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/download_data.ipynb +0 -0
  55. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/download_naip.ipynb +0 -0
  56. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/download_sentinel2.ipynb +0 -0
  57. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/edit_vector.ipynb +0 -0
  58. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/geometric_properties.ipynb +0 -0
  59. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/globe_projection.ipynb +0 -0
  60. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/image_chips.ipynb +0 -0
  61. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/jupytext.toml +0 -0
  62. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/parking_spot_detection.ipynb +0 -0
  63. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/planetary_computer.ipynb +0 -0
  64. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
  65. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/regularization.ipynb +0 -0
  66. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/arcgis.ipynb +0 -0
  67. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
  68. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
  69. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/box_prompts.ipynb +0 -0
  70. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/fast_sam.ipynb +0 -0
  71. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/input_prompts.ipynb +0 -0
  72. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
  73. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
  74. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
  75. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/satellite.ipynb +0 -0
  76. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
  77. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/text_prompts.ipynb +0 -0
  78. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
  79. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/ship_detection.ipynb +0 -0
  80. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/solar_panel_detection.ipynb +0 -0
  81. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/text_prompt_segmentation.ipynb +0 -0
  82. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_building_footprints_usa.ipynb +0 -0
  83. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_car_detection.ipynb +0 -0
  84. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_object_detection_model.ipynb +0 -0
  85. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_ship_detection.ipynb +0 -0
  86. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_solar_panel_detection.ipynb +0 -0
  87. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/train_water_detection.ipynb +0 -0
  88. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/view_metadata.ipynb +0 -0
  89. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/water_dynamics.ipynb +0 -0
  90. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/examples/wetland_mapping.ipynb +0 -0
  91. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/extract.md +0 -0
  92. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/faq.md +0 -0
  93. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/geoai.md +0 -0
  94. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/hf.md +0 -0
  95. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/index.md +0 -0
  96. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/installation.md +0 -0
  97. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/overrides/main.html +0 -0
  98. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/segment.md +0 -0
  99. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/segmentation.md +0 -0
  100. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/train.md +0 -0
  101. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/usage.md +0 -0
  102. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/utils.md +0 -0
  103. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/workshops/GeoAI_Workshop_2025.ipynb +0 -0
  104. {geoai_py-0.5.6 → geoai_py-0.6.0}/docs/workshops/jupytext.toml +0 -0
  105. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/download.py +0 -0
  106. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/extract.py +1 -1
  107. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/hf.py +0 -0
  108. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/segment.py +0 -0
  109. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/segmentation.py +0 -0
  110. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai/train.py +0 -0
  111. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/dependency_links.txt +0 -0
  112. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/entry_points.txt +0 -0
  113. {geoai_py-0.5.6 → geoai_py-0.6.0}/geoai_py.egg-info/top_level.txt +0 -0
  114. {geoai_py-0.5.6 → geoai_py-0.6.0}/requirements_docs.txt +0 -0
  115. {geoai_py-0.5.6 → geoai_py-0.6.0}/setup.cfg +0 -0
  116. {geoai_py-0.5.6 → geoai_py-0.6.0}/tests/__init__.py +0 -0
  117. {geoai_py-0.5.6 → geoai_py-0.6.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.6.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
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ # sam module
2
+
3
+ ::: geoai.sam
@@ -2,7 +2,7 @@
2
2
 
3
3
  __author__ = """Qiusheng Wu"""
4
4
  __email__ = "giswqs@gmail.com"
5
- __version__ = "0.5.6"
5
+ __version__ = "0.6.0"
6
6
 
7
7
 
8
8
  import os
@@ -1,6 +1,7 @@
1
1
  """The module for training semantic segmentation models for classifying remote sensing imagery."""
2
2
 
3
3
  import os
4
+
4
5
  import numpy as np
5
6
 
6
7
 
@@ -110,23 +111,24 @@ def train_classifier(
110
111
  Returns:
111
112
  object: Trained SemanticSegmentationTask model.
112
113
  """
114
+ import multiprocessing as mp
115
+ import timeit
116
+
117
+ import albumentations as A
113
118
  import lightning.pytorch as pl
119
+ import torch
120
+ from lightning.pytorch.callbacks import ModelCheckpoint
121
+ from lightning.pytorch.loggers import CSVLogger
114
122
  from torch.utils.data import DataLoader
115
- from torchgeo.datasets import stack_samples, RasterDataset
123
+ from torchgeo.datamodules import GeoDataModule
124
+ from torchgeo.datasets import RasterDataset, stack_samples
116
125
  from torchgeo.datasets.splits import random_bbox_assignment
117
126
  from torchgeo.samplers import (
118
- RandomGeoSampler,
119
- RandomBatchGeoSampler,
120
127
  GridGeoSampler,
128
+ RandomBatchGeoSampler,
129
+ RandomGeoSampler,
121
130
  )
122
- import torch
123
- import multiprocessing as mp
124
- import timeit
125
- import albumentations as A
126
- from torchgeo.datamodules import GeoDataModule
127
131
  from torchgeo.trainers import SemanticSegmentationTask
128
- from lightning.pytorch.callbacks import ModelCheckpoint
129
- from lightning.pytorch.loggers import CSVLogger
130
132
 
131
133
  # Create a wrapper class for albumentations to work with TorchGeo format
132
134
  class AlbumentationsWrapper:
@@ -376,21 +378,19 @@ def _classify_image(
376
378
  Returns:
377
379
  str: Path to the saved classified image.
378
380
  """
379
- import numpy as np
380
381
  import timeit
381
- from tqdm import tqdm
382
382
 
383
+ import numpy as np
384
+ import rasterio
383
385
  import torch
386
+ from rasterio.io import MemoryFile
387
+ from rasterio.merge import merge
388
+ from rasterio.transform import from_origin
384
389
  from torch.utils.data import DataLoader
385
-
386
390
  from torchgeo.datasets import RasterDataset, stack_samples
387
391
  from torchgeo.samplers import GridGeoSampler
388
392
  from torchgeo.trainers import SemanticSegmentationTask
389
-
390
- import rasterio
391
- from rasterio.transform import from_origin
392
- from rasterio.io import MemoryFile
393
- from rasterio.merge import merge
393
+ from tqdm import tqdm
394
394
 
395
395
  # Set default output path if not provided
396
396
  if output_path is None:
@@ -619,14 +619,12 @@ def classify_image(
619
619
  str: Path to the saved classified image.
620
620
  """
621
621
  import timeit
622
-
623
- import torch
624
- from torchgeo.trainers import SemanticSegmentationTask
622
+ import warnings
625
623
 
626
624
  import rasterio
627
-
628
- import warnings
625
+ import torch
629
626
  from rasterio.errors import NotGeoreferencedWarning
627
+ from torchgeo.trainers import SemanticSegmentationTask
630
628
 
631
629
  # Disable specific GDAL/rasterio warnings
632
630
  warnings.filterwarnings("ignore", category=UserWarning, module="rasterio._.*")
@@ -863,9 +861,10 @@ def classify_images(
863
861
  list: List of paths to the saved classified images.
864
862
  """
865
863
  # Import required libraries
866
- from tqdm import tqdm
867
864
  import glob
868
865
 
866
+ from tqdm import tqdm
867
+
869
868
  # Process directory input
870
869
  if isinstance(image_paths, str) and os.path.isdir(image_paths):
871
870
  # Set default output directory if not provided
@@ -7,21 +7,21 @@ logging.getLogger("maplibre").setLevel(logging.ERROR)
7
7
  import leafmap
8
8
  import leafmap.maplibregl as maplibregl
9
9
 
10
+ from .classify import classify_image, classify_images, train_classifier
10
11
  from .download import (
11
12
  download_naip,
12
13
  download_overture_buildings,
13
14
  download_pc_stac_item,
14
- get_overture_data,
15
15
  extract_building_stats,
16
+ get_overture_data,
16
17
  pc_collection_list,
17
18
  pc_item_asset_list,
18
- pc_stac_search,
19
19
  pc_stac_download,
20
+ pc_stac_search,
20
21
  read_pc_item_asset,
21
22
  view_pc_item,
22
23
  view_pc_items,
23
24
  )
24
- from .classify import train_classifier, classify_image, classify_images
25
25
  from .extract import *
26
26
  from .hf import *
27
27
  from .segment import *