GeoSAM-Image-Encoder
This package is part of Geo-SAM and is used to encode image data into features recognized by Geo-SAM.
Installation
Installing GeoSAM-Image-Encoder directly will install the CPU version of PyTorch. Therefore, it is recommended to install the appropriate version of PyTorch before installing GeoSAM-Image-Encoder in your machine. You can install the corresponding version based on the official PyTorch website:
https://pytorch.org/get-started/locally/
After installing PyTorch, you can install GeoSAM-Image-Encoder via pip.
pip install GeoSAM-Image-Encoder
# or
pip install git+https://github.com/Fanchengyan/GeoSAM-Image-Encoder.git
Usage
You can call this script in Python or Terminal. We recommend using Python interface directly for processing, which will have greater flexibility.
Using Python
After install GeoSAM-Image-Encoder, you can import it using geosam
import geosam
from geosam import ImageEncoder
check the folder contains geosam and add it to environment if you want to run in terminal
geosam.folder
check if gpu available
geosam.gpu_available()
Run by specify parameters directly
checkpoint_path = '/content/sam_vit_l_0b3195.pth'
image_path = '/content/beiluhe_google_img_201211_clip.tif'
feature_dir = './'
## init ImageEncoder
img_encoder = ImageEncoder(checkpoint_path)
## encode image
img_encoder.encode_image(image_path,feature_dir)
Run by parameters from setting.json file
If you want to using settings.json file to provide the parameters
setting_file = "/content/setting.json"
feature_dir = './'
### parse settings from the setting,json file
settings = geosam.parse_settings_file(setting_file)
### setting file not contains feature_dir, you need add it
settings.update({"feature_dir":feature_dir})
### split settings into init_settings, encode_settings
init_settings, encode_settings = geosam.split_settings(settings)
print(f"settings: {settings}")
print(f"init_settings: {init_settings}")
print(f"encode_settings: {encode_settings}")
Then, you can run image encoding by parameters from setting.json file
img_encoder = ImageEncoder(**init_settings)
img_encoder.encode_image(**encode_settings)
Using Terminal
check the folder of geosam
print(geosam.folder)
add this folder into environment of your machine. Then run in terminal:
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
image_encoder.py -s /content/setting.json -f ./ --stride 256 --value_range "10,255"
check all available parameters:
image_encoder.py -h
Colob Example
You can click on the link below to experience GeoSAM-Image-Encoder in Colab:
Metadata
Release files for GeoSAM-Image-Encoder 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| GeoSAM-Image-Encoder-1.0.4.tar.gz | 28.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.5 kB
Release files / GeoSAM-Image-Encoder-1.0.4.tar.gz
| Download URL | GeoSAM-Image-Encoder-1.0.4.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8a1a23403dd997710b5f2a39fd4b1d39d93cba6faf1ef40d7b933a18c2488ce
|
|
BLAKE2b-256 checksum How to use checksums |
93126eb15876812ee1f12e76cea2afed0f0cb2dc72df6045027486c96d4212de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl
| Download URL | GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl |
|---|---|
| Size | 27.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba6412aaf610f2ec094f1e7252cd95b85fef0c67f67b7cc51992add4a2d592a7
|
|
BLAKE2b-256 checksum How to use checksums |
eeb2836036c454550860285a407207617c5209e3106bb15b19d9c527553de9c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|