Skip to content

Commit 2fa4fe2

Browse files
authored
Merge branch 'main' into fastsam
2 parents c938d37 + d77bc91 commit 2fa4fe2

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ The Segment Anything Model is computationally intensive, and a powerful GPU is r
9292

9393
This repository and its content are provided for educational purposes only. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. Users who intend to download a large number of image tiles from any basemap are advised to contact the basemap provider to obtain permission before doing so. Unauthorized use of the basemap or any of its components may be a violation of copyright laws or other applicable laws and regulations.
9494

95+
## Contributing
96+
97+
Please refer to the [contributing guidelines](https://samgeo.gishub.org/contributing) for more information.
98+
9599
## Acknowledgements
96100

97101
This project is based upon work partially supported by the National Aeronautics and Space Administration (NASA) under Grant No. 80NSSC22K1742 issued through the [Open Source Tools, Frameworks, and Libraries 2020 Program](https://bit.ly/3RVBRcQ).

docs/contributing.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,27 @@ Ready to contribute? Here's how to set up segment-geospatial for local developme
9999
100100
Before you submit a pull request, check that it meets these guidelines:
101101
102-
1. The pull request should include tests.
102+
1. The pull request should include tests (see the section below - [Unit Testing](https://samgeo.gishub.org/contributing/#unit-testing)).
103103
2. If the pull request adds functionality, the docs should be updated.
104104
Put your new functionality into a function with a docstring, and add
105-
the feature to the list in README.rst.
105+
the feature to the list in README.md.
106106
3. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11. Check <https://github.com/giswqs/segment-geospatial/pull_requests> and make sure that the tests pass for all
107107
supported Python versions.
108+
109+
## Unit Testing
110+
111+
Unit tests are in the `tests` folder. If you add new functionality to the package, please add a unit test for it. You can either add the test to an existing test file or create a new one. For example, if you add a new function to `samgeo/samgeo.py`, you can add the unit test to `tests/test_samgeo.py`. If you add a new module to `samgeo/<MODULE-NAME>`, you can create a new test file in `tests/test_<MODULE-NAME>`. Please refer to `tests/test_samgeo.py` for examples. For more information about unit testing, please refer to this tutorial - [Getting Started With Testing in Python](https://realpython.com/python-testing/).
112+
113+
To run the unit tests, navigate to the root directory of the package and run the following command:
114+
115+
```bash
116+
python -m unittest discover tests/
117+
```
118+
119+
## Add new dependencies
120+
121+
If you PR involves adding new dependencies, please make sure that the new dependencies are available on both [PyPI](https://pypi.org/) and [conda-forge](https://conda-forge.org/). Search [here](https://conda-forge.org/feedstock-outputs/) to see if the package is available on conda-forge. If the package is not available on conda-forge, it can't be added as a required dependency in `requirements.txt`. Instead, it should be added as an optional dependency in `requirements_dev.txt`.
122+
123+
If the package is available on PyPI and conda-forge, but if it is challenging to install the package on some operating systems, we would recommend adding the package as an optional dependency in `requirements_dev.txt` rather than a required dependency in `requirements.txt`.
124+
125+
The dependencies required for building the documentation should be added to `requirements_docs.txt`. In most cases, contributors do not need to add new dependencies to `requirements_docs.txt` unless the documentation fails to build due to missing dependencies.

paper/paper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ bibliography: paper.bib
2727

2828
# Summary
2929

30-
Segment-Geospatial (samgeo) is an open-source Python package designed to simplify the process of segmenting geospatial data with the Segment Anything Model [@Kirillov2023]. The package leverages popular Python libraries, such as leafmap [@Wu2021], ipywidgets [@Grout2021], rasterio [@Gillies2013], geopandas [@Jordahl2021], and segment-anything-py [@Wu2023], to provide a straightforward interface for users to segment remote sensing imagery and export the results in various formats, including vector and raster data. The segmentation can be run automatically, interactively in a graphical user interface (GUI), or by text prompts built upon Grounding DINO [@liu2023]. It also provides functionality for downloading remote sensing imagery and visualizing segmentation results interactively in a Jupyter environment. Segment-Geospatial aims to fill the gap in the Python ecosystem by providing a user-friendly, efficient, and flexible geospatial segmentation tool without the need for training deep learning models.
30+
Segment-Geospatial (samgeo) is an open-source Python package designed to simplify the process of segmenting geospatial data with the Segment Anything Model [@Kirillov2023]. The package leverages popular Python libraries, such as leafmap [@Wu2021], ipywidgets [@Grout2021], rasterio [@Gillies2013], geopandas [@Jordahl2021], and segment-anything-py [@Wu2023], to provide a straightforward interface for users to segment remote sensing imagery and export the results in various formats, including vector and raster data. The segmentation can be run automatically, interactively in a graphical user interface (GUI), or by text prompts built upon Grounding DINO [@liu2023]. However, it's worth noting that the text prompt approach has its limitations, which may require parameter fine-tuning. Additionally, the package provides functionality for downloading remote sensing imagery and visualizing segmentation results interactively in a Jupyter environment. Segment-Geospatial aims to fill the gap in the Python ecosystem by providing a user-friendly, efficient, and flexible geospatial segmentation tool without the need for training deep learning models.
3131

3232
# Statement of need
3333

3434
Image segmentation is a critical task in geospatial analysis as it enables the identification and extraction of relevant features from satellite or aerial imagery. By segmenting an image into meaningful regions, it becomes possible to extract information about the spatial distribution and characteristics of various objects and land cover types. This information can then be used to support decision-making in a wide range of fields, from agriculture and forestry to environmental monitoring and national security.
3535

36-
Traditionally, image segmentation has been performed using manual or semi-automatic methods, which are time-consuming and labor-intensive. In recent years, deep learning models have been developed to automate the segmentation process. However, these models generally require large amounts of training data and are computationally expensive, making them impractical for many applications. The Segment Anything Model (SAM) [@Kirillov2023] recently released by Meta AI is a promptable segmentation system with zero-shot generalization to unfamiliar objects and images, without the need for additional training. The model was trained on 11 million images with over 1 billion masks. Users can segment any object in any image using existing model checkpoints without the need for additional training. Since its release in April 2023, there has been a plethora of applications of SAM in various fields [@Zhang2023; @Ji2023], such as medical imaging [@Ma2023]. Currently, there is no Python package available for segmenting images in the geospatial domain with SAM. Therefore, we developed the Segment-Geospatial Python package to fill this gap and provide a low-code and no-code solution for segmenting geospatial data with SAM.
36+
Traditionally, image segmentation has been performed using manual or semi-automatic methods, which are time-consuming and labor-intensive. In recent years, deep learning models have been developed to automate the segmentation process. However, these models generally require large amounts of training data and are computationally expensive, making them impractical for many applications. The Segment Anything Model (SAM) [@Kirillov2023] recently released by Meta AI is a promptable segmentation system with zero-shot generalization to unfamiliar objects and images, without the need for additional training. The model was trained on 11 million images with over 1 billion masks. Users can segment any object in any image using existing model checkpoints without the need for additional training. Since its release in April 2023, there has been a plethora of applications of SAM in various fields [@Zhang2023; @Ji2023], such as medical imaging [@Ma2023]. Currently, there are few Python packages available on PyPI and conda-forge for segmenting images in the geospatial domain with SAM. Therefore, we developed the Segment-Geospatial Python package to fill this gap and provide a low-code and no-code solution for segmenting geospatial data with SAM.
3737

3838
# Acknowledgements
3939

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
rio-cogeo
2-
segment-anything-fast
2+
segment-anything-fast

samgeo/hq_sam.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def generate(
199199
)
200200

201201
image = cv2.imread(source)
202+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
202203
elif isinstance(source, np.ndarray):
203204
image = source
204205
source = None

samgeo/samgeo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def generate(
196196
)
197197

198198
image = cv2.imread(source)
199+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
199200
elif isinstance(source, np.ndarray):
200201
image = source
201202
source = None

0 commit comments

Comments
 (0)