https://github.com/fanchengyan/geosam-image-encoder
A package for encoding satellite images into Geo-SAM features
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.5%) to scientific vocabulary
Repository
A package for encoding satellite images into Geo-SAM features
Basic Info
- Host: GitHub
- Owner: Fanchengyan
- License: gpl-3.0
- Language: Python
- Default Branch: main
- Size: 51.8 KB
Statistics
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
- Releases: 2
Metadata Files
README.md
GeoSAM-Image-Encoder
This package is part of the Geo-SAM project and is a standalone Python package that does not depend on QGIS. This package allows you to encode remote sensing images into features that can be recognized by Geo-SAM using a remote server, such as Colab, AWS, Azure or your own HPC.
Installation
You can install GeoSAM-Image-Encoder via pip.
``` BASH pip install GeoSAM-Image-Encoder
or
pip install git+https://github.com/Fanchengyan/GeoSAM-Image-Encoder.git ```
GPU Version
GeoSAM-Image-Encoder supports using GPU to accelerate the encoding process. If your PC has NVIDIA GPUs, you need to download and install the CUDA Toolkit first.
Then install the gpu-version pytorch using the following command (here CUDA 11.7 as an example):
BASH
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
Usage
There are two ways to use GeoSAM-Image-Encoder. You can call it in Python or Terminal. We recommend using Python interface directly which will have greater flexibility.
Using Python
After install GeoSAM-Image-Encoder, you can import it using geosam
python
import geosam
from geosam import ImageEncoder
check if gpu available
python
geosam.gpu_available()
Run by specify parameters directly
If you want to specify the parameters directly, you can run it like this:
```python checkpointpath = '/content/samvitl0b3195.pth' imagepath = '/content/beiluhegoogleimg201211clip.tif' featuredir = './'
init ImageEncoder
imgencoder = ImageEncoder(checkpointpath)
encode image
imgencoder.encodeimage(imagepath,featuredir) ```
Run by parameters from setting.json file
If you want to using settings.json file which exported from Geo-SAM plugin to provide parameters, you can run it like this:
```python settingfile = "/content/setting.json" featuredir = './'
parse settings from the setting,json file
settings = geosam.parsesettingsfile(setting_file)
setting file not contains feature_dir, you need add it
settings.update({"featuredir":featuredir})
split settings into initsettings, encodesettings
initsettings, encodesettings = geosam.split_settings(settings)
print(f"settings: {settings}") print(f"initsettings: {initsettings}") print(f"encodesettings: {encodesettings}") ```
Then, you can run image encoding by parameters from setting.json file
python
img_encoder = ImageEncoder(**init_settings)
img_encoder.encode_image(**encode_settings)
Using Terminal
check the folder of geosam
python
print(geosam.folder)
add this folder into environment of your machine. Then run in terminal:
bash
image_encoder.py -i /content/beiluhe_google_img_201211_clip.tif -c /content/sam_vit_l_0b3195.pth -f ./
You can overwrite the settings from file by specify the parameter values. For Example
bash
image_encoder.py -s /content/setting.json -f ./ --stride 256 --value_range "10,255"
check all available parameters:
bash
image_encoder.py -h
``` This script is for encoding image to SAM features.
=====
Usage
using settings.json:
image_encoder.py -s <settings.json> -f <feature_dir>
or directly using parameters:
image_encoder.py -i <image_path> -c <checkpoint_path> -f <feature_dir>
All Parameters:
-s, --settings: Path to the settings json file. -i, --imagepath: Path to the input image. -c, --checkpointpath: Path to the SAM checkpoint. -f, --featuredir: Path to the output feature directory. --modeltype: one of ["vith", "vitl", "vitb"] or [0, 1, 2] or None, optional The type of the SAM model. If None, the model type will be inferred from the checkpoint path. Default: None. --bands: list of int, optional . The bands to be used for encoding. Should not be more than three bands. If None, the first three bands (if available) will be used. Default: None. --stride: int, optional The stride of the sliding window. Default: 512. --extent: str, optional The extent of the image to be encoded. Should be in the format of "minx, miny, maxx, maxy, [crs]". If None, the extent of the input image will be used. Default: None. --valuerange: tuple of float, optional The value range of the input image. If None, the value range will be automatically calculated from the input image. Default: None. --resolution: float, optional The resolution of the output feature in the unit of raster crs. If None, the resolution of the input image will be used. Default: None. --batchsize: int, optional The batch size for encoding. Default: 1. --gpuid: int, optional The device id of the GPU to be used. Default: 0.
```
Colob Example
You can click on the link below to experience GeoSAM-Image-Encoder in Colab:
Owner
- Name: Fanchengyan
- Login: Fanchengyan
- Kind: user
- Repositories: 12
- Profile: https://github.com/Fanchengyan
GitHub Events
Total
- Watch event: 1
- Fork event: 1
Last Year
- Watch event: 1
- Fork event: 1
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| fanchengyan | f****4@l****n | 22 |
| Fanchengyan | 1****8@q****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 37 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
- Total maintainers: 1
pypi.org: geosam-image-encoder
A package for encoding satellite images into Geo-SAM features.
- Homepage: https://github.com/Fanchengyan/GeoSAM-Image-Encoder
- Documentation: https://geosam-image-encoder.readthedocs.io/
- License: MIT License
-
Latest release: 1.0.4
published over 2 years ago