Skip to content

Commit 3189d36

Browse files
authored
Merge branch 'main' into efficient
2 parents ec028ee + aa97a84 commit 3189d36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1612
-166
lines changed

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Build the Docker image
1616
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
contents: read
1414
steps:
1515
- name: Check out the repo
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717

1818
- name: Log in to Docker Hub
1919
uses: docker/login-action@v2

.github/workflows/docs-build.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ jobs:
77
deploy:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
with:
1212
fetch-depth: 0
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
1414
with:
15-
python-version: "3.10"
15+
python-version: "3.11"
1616
- name: Install GDAL
1717
run: |
1818
python -m pip install --upgrade pip
@@ -26,11 +26,6 @@ jobs:
2626
pip install --no-cache-dir Cython
2727
pip install -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt
2828
pip install .
29-
- name: Discover typos with codespell
30-
run: codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs,pres"
31-
# - name: PKG-TEST
32-
# run: |
33-
# python -m unittest discover tests/
3429
- run: mkdocs build
3530
- name: Deploy to Netlify
3631
uses: nwtgck/actions-netlify@v2.0

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
deploy:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-python@v4
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
1212
with:
13-
python-version: 3.9
13+
python-version: "3.11"
1414
- name: Install dependencies
1515
run: |
1616
python -m pip install --upgrade pip

.github/workflows/draft-pdf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
name: Paper Draft
77
steps:
88
- name: Checkout
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010
- name: Build draft PDF
1111
uses: openjournals/openjournals-draft-action@master
1212
with:

.github/workflows/macos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
config:
18-
- { os: macOS-latest, py: "3.10" }
18+
- { os: macOS-latest, py: "3.11" }
1919
env:
2020
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
2121
steps:
2222
- name: CHECKOUT CODE
23-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2424
- name: SETUP PYTHON
25-
uses: actions/setup-python@v4
25+
uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.config.py }}
2828
# - name: Install GDAL

.github/workflows/pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Set up Python
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: "3.x"
2020
- name: Install dependencies

.github/workflows/ubuntu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
2525
steps:
2626
- name: CHECKOUT CODE
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828
- name: SETUP PYTHON
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.config.py }}
3232
- name: Install GDAL

.github/workflows/windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
test-windows:
1212
runs-on: windows-latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Install miniconda
16-
uses: conda-incubator/setup-miniconda@v2
16+
uses: conda-incubator/setup-miniconda@v3
1717
with:
1818
auto-activate-base: true
1919
python-version: "3.10"

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-toml
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
types: [python]
9+
- id: trailing-whitespace
10+
- id: requirements-txt-fixer
11+
- id: check-added-large-files
12+
args: ["--maxkb=500"]
13+
14+
- repo: https://github.com/psf/black
15+
rev: 24.4.2
16+
hooks:
17+
- id: black-jupyter
18+
language_version: python3.11
19+
20+
- repo: https://github.com/codespell-project/codespell
21+
rev: v2.2.6
22+
hooks:
23+
- id: codespell
24+
args: [--toml, pyproject-codespell.precommit-toml]
25+
26+
- repo: https://github.com/kynan/nbstripout
27+
rev: 0.7.1
28+
hooks:
29+
- id: nbstripout

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LABEL repo="https://github.com/opengeos/segment-geospatial"
44

55
RUN mamba install -c conda-forge leafmap localtileserver segment-geospatial -y && \
66
pip install -U segment-geospatial jupyter-server-proxy && \
7-
jupyter serverextension enable --sys-prefix jupyter_server_proxy && \
7+
jupyter server extension enable --sys-prefix jupyter_server_proxy && \
88
fix-permissions "${CONDA_DIR}" && \
99
fix-permissions "/home/${NB_USER}"
1010

@@ -18,6 +18,5 @@ ARG LOCALTILESERVER_CLIENT_PREFIX='proxy/{port}'
1818
ENV LOCALTILESERVER_CLIENT_PREFIX=$LOCALTILESERVER_CLIENT_PREFIX
1919

2020
USER root
21-
RUN apt update; apt install -y libgl1
2221
RUN chown -R ${NB_UID} ${HOME}
2322
USER ${NB_USER}

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ The **segment-geospatial** package draws its inspiration from [segment-anything-
2121

2222
## Citations
2323

24-
- Wu, Q., & Osco, L. (2023). samgeo: A Python package for segmenting geospatial data with the Segment Anything Model (SAM). _Journal of Open Source Software_, 8(89), 5663, <https://doi.org/10.21105/joss.05663>
24+
- Wu, Q., & Osco, L. (2023). samgeo: A Python package for segmenting geospatial data with the Segment Anything Model (SAM). _Journal of Open Source Software_, 8(89), 5663. <https://doi.org/10.21105/joss.05663>
25+
- Osco, L. P., Wu, Q., de Lemos, E. L., Gonçalves, W. N., Ramos, A. P. M., Li, J., & Junior, J. M. (2023). The Segment Anything Model (SAM) for remote sensing applications: From zero to one shot. _International Journal of Applied Earth Observation and Geoinformation_, 124, 103540. <https://doi.org/10.1016/j.jag.2023.103540>
2526

2627
## Features
2728

@@ -56,16 +57,16 @@ conda install -c conda-forge mamba
5657
mamba install -c conda-forge segment-geospatial
5758
```
5859

59-
Samgeo-geospatial has some optional dependencies that are not included in the default conda environment. To install these dependencies, run the following command:
60+
If your system has a GPU, but the above commands do not install the GPU version of pytorch, you can force the installation of the GPU version of pytorch using the following command:
6061

6162
```bash
62-
mamba install -c conda-forge groundingdino-py segment-anything-fast
63+
mamba install -c conda-forge segment-geospatial "pytorch=*=cuda*"
6364
```
6465

65-
As of July 9th, 2023 Linux systems have also required that `libgl1` be installed for segment-geospatial to work. The following command will install that dependency
66+
Samgeo-geospatial has some optional dependencies that are not included in the default conda environment. To install these dependencies, run the following command:
6667

6768
```bash
68-
apt update; apt install -y libgl1
69+
mamba install -c conda-forge groundingdino-py segment-anything-fast
6970
```
7071

7172
## Examples

docs/examples/arcgis.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@
231231
{
232232
"cell_type": "code",
233233
"execution_count": null,
234-
"metadata": {
235-
"scrolled": false
236-
},
234+
"metadata": {},
237235
"outputs": [],
238236
"source": [
239237
"sam.show_anns(axis=\"off\", alpha=1, output=\"ag_annotations.tif\")"
@@ -431,7 +429,7 @@
431429
"metadata": {},
432430
"outputs": [],
433431
"source": [
434-
"sam.generate('agriculture.tif', output=\"ag_masks2.tif\", foreground=True)"
432+
"sam.generate(\"agriculture.tif\", output=\"ag_masks2.tif\", foreground=True)"
435433
]
436434
},
437435
{

docs/examples/automatic_mask_generator_hq.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@
3939
"source": [
4040
"import os\n",
4141
"import leafmap\n",
42-
"from samgeo.hq_sam import SamGeo, show_image, download_file, overlay_images, tms_to_geotiff"
42+
"from samgeo.hq_sam import (\n",
43+
" SamGeo,\n",
44+
" show_image,\n",
45+
" download_file,\n",
46+
" overlay_images,\n",
47+
" tms_to_geotiff,\n",
48+
")"
4349
]
4450
},
4551
{
@@ -147,7 +153,7 @@
147153
"outputs": [],
148154
"source": [
149155
"sam = SamGeo(\n",
150-
" model_type=\"vit_h\", # can be vit_h, vit_b, vit_l, vit_tiny\n",
156+
" model_type=\"vit_h\", # can be vit_h, vit_b, vit_l, vit_tiny\n",
151157
" sam_kwargs=None,\n",
152158
")"
153159
]
@@ -288,7 +294,7 @@
288294
},
289295
{
290296
"cell_type": "code",
291-
"execution_count": 17,
297+
"execution_count": null,
292298
"metadata": {},
293299
"outputs": [],
294300
"source": [

docs/examples/box_prompts.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
"metadata": {},
242242
"outputs": [],
243243
"source": [
244-
"m.add_raster('mask.tif', cmap='viridis', nodata=0, layer_name='Mask')\n",
244+
"m.add_raster(\"mask.tif\", cmap=\"viridis\", nodata=0, layer_name=\"Mask\")\n",
245245
"m"
246246
]
247247
},
@@ -260,7 +260,7 @@
260260
"metadata": {},
261261
"outputs": [],
262262
"source": [
263-
"url = 'https://opengeos.github.io/data/sam/tree_boxes.geojson'\n",
263+
"url = \"https://opengeos.github.io/data/sam/tree_boxes.geojson\"\n",
264264
"geojson = \"tree_boxes.geojson\"\n",
265265
"leafmap.download_file(url, geojson)"
266266
]
@@ -350,8 +350,7 @@
350350
"nbconvert_exporter": "python",
351351
"pygments_lexer": "ipython3",
352352
"version": "3.10.8"
353-
},
354-
"orig_nbformat": 4
353+
}
355354
},
356355
"nbformat": 4,
357356
"nbformat_minor": 2

docs/examples/fast_sam.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"outputs": [],
143143
"source": [
144144
"from samgeo.fast_sam import SamGeo\n",
145+
"\n",
145146
"sam = SamGeo(model=\"FastSAM-x.pt\")"
146147
]
147148
},
@@ -259,8 +260,7 @@
259260
"nbconvert_exporter": "python",
260261
"pygments_lexer": "ipython3",
261262
"version": "3.9.16"
262-
},
263-
"orig_nbformat": 4
263+
}
264264
},
265265
"nbformat": 4,
266266
"nbformat_minor": 2

docs/examples/input_prompts.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 1,
40+
"execution_count": null,
4141
"metadata": {},
4242
"outputs": [],
4343
"source": [
@@ -147,7 +147,7 @@
147147
},
148148
{
149149
"cell_type": "code",
150-
"execution_count": 3,
150+
"execution_count": null,
151151
"metadata": {},
152152
"outputs": [],
153153
"source": [
@@ -260,8 +260,7 @@
260260
"nbconvert_exporter": "python",
261261
"pygments_lexer": "ipython3",
262262
"version": "3.10.8"
263-
},
264-
"orig_nbformat": 4
263+
}
265264
},
266265
"nbformat": 4,
267266
"nbformat_minor": 2

docs/examples/input_prompts_hq.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@
258258
"nbconvert_exporter": "python",
259259
"pygments_lexer": "ipython3",
260260
"version": "3.9.16"
261-
},
262-
"orig_nbformat": 4
261+
}
263262
},
264263
"nbformat": 4,
265264
"nbformat_minor": 2

0 commit comments

Comments
 (0)