Skip to main content

A package for encoding satellite images into Geo-SAM features.

Project description

GeoSAM-Image-Encoder

Downloads

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:

https://colab.research.google.com/github/coolzhao/Geo-SAM/blob/dev/GeoSAM-Image-Encoder/examples/geosam-image-encoder.ipynb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

GeoSAM-Image-Encoder-1.0.4.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file GeoSAM-Image-Encoder-1.0.4.tar.gz.

File metadata

  • Download URL: GeoSAM-Image-Encoder-1.0.4.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for GeoSAM-Image-Encoder-1.0.4.tar.gz
Algorithm Hash digest
SHA256 d8a1a23403dd997710b5f2a39fd4b1d39d93cba6faf1ef40d7b933a18c2488ce
MD5 1eff97bc103c56ad84c213e49f516027
BLAKE2b-256 93126eb15876812ee1f12e76cea2afed0f0cb2dc72df6045027486c96d4212de

See more details on using hashes here.

File details

Details for the file GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for GeoSAM_Image_Encoder-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ba6412aaf610f2ec094f1e7252cd95b85fef0c67f67b7cc51992add4a2d592a7
MD5 c448f745b3f4b3160b5e5a7750933bed
BLAKE2b-256 eeb2836036c454550860285a407207617c5209e3106bb15b19d9c527553de9c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page