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.
- geoai_py-0.7.0/.github/workflows/docker-image.yml +16 -0
- geoai_py-0.7.0/.github/workflows/docker-publish.yml +45 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/docs-build.yml +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/docs.yml +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/macos.yml +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/ubuntu.yml +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/windows.yml +1 -1
- geoai_py-0.7.0/Dockerfile +54 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/PKG-INFO +2 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/data_visualization.ipynb +3 -3
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_data.ipynb +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/edit_vector.ipynb +2 -2
- geoai_py-0.7.0/docs/examples/samgeo.ipynb +190 -0
- geoai_py-0.7.0/docs/examples/train_landcover_classification.ipynb +271 -0
- geoai_py-0.7.0/docs/examples/train_segmentation_model.ipynb +411 -0
- geoai_py-0.7.0/docs/sam.md +3 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/__init__.py +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/classify.py +23 -24
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/geoai.py +10 -4
- geoai_py-0.7.0/geoai/sam.py +832 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/train.py +1041 -9
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/utils.py +342 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/PKG-INFO +2 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/SOURCES.txt +8 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/requires.txt +1 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/mkdocs.yml +5 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/pyproject.toml +2 -2
- {geoai_py-0.5.6 → geoai_py-0.7.0}/requirements.txt +1 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.editorconfig +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/FUNDING.yml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/dependabot.yml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.github/workflows/pypi.yml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.gitignore +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/.pre-commit-config.yaml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/LICENSE +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/MANIFEST.in +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/README.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/CNAME +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo.ico +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo.png +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/assets/logo_rect.png +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/changelog.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/classify.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/contributing.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/download.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/_template.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_africa.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_china.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_footprints_usa.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/building_regularization.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/car_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/create_vector.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/raster_viz.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/dataviz/vector_viz.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_naip.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/download_sentinel2.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/geometric_properties.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/globe_projection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/image_chips.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/jupytext.toml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/parking_spot_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/planetary_computer.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/regularization.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/arcgis.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/box_prompts.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/fast_sam.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/input_prompts.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/satellite.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/text_prompts.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/ship_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/solar_panel_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/text_prompt_segmentation.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_building_footprints_usa.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_car_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_object_detection_model.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_ship_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_solar_panel_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/train_water_detection.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/view_metadata.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/water_dynamics.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/examples/wetland_mapping.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/extract.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/faq.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/geoai.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/hf.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/index.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/installation.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/overrides/main.html +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/segment.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/segmentation.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/train.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/usage.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/utils.md +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/workshops/GeoAI_Workshop_2025.ipynb +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/docs/workshops/jupytext.toml +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/download.py +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/extract.py +1 -1
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/hf.py +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/segment.py +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai/segmentation.py +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/dependency_links.txt +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/entry_points.txt +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/geoai_py.egg-info/top_level.txt +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/requirements_docs.txt +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/setup.cfg +0 -0
- {geoai_py-0.5.6 → geoai_py-0.7.0}/tests/__init__.py +0 -0
- {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 }}
|
|
@@ -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.
|
|
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
|
|
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=\"
|
|
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
|
|
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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"outputs": [],
|
|
52
52
|
"source": [
|
|
53
53
|
"m = geoai.MapLibre()\n",
|
|
54
|
-
"m.add_basemap(\"
|
|
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": "
|
|
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
|
+
"[](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
|
+
""
|
|
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
|
+
}
|