Skip to main content

Welcome to fastgs

Introduction

This library is currently in alpha, neither the functionality nor the API is stable

This library provides geospatial multispectral image support for fastai. FastAI already has extensive support for RGB images in the pipeline. I try to achieve feature parity for multi-spectral images with this library, specifically in the context of Sentinel 2 geospatial imaging.

Install

pip install fastgs

How to use

The low-level functionality is wrapped into a class that loads sets of Sentinel 2 channels into a multi-spectral tensor (a TensorImageMS subclass of fastai TensorImage which itself is a subclass of the pytorch Tensor).

from fastgs.geospatial.sentinel import *

If we have the following functions to map an image index to an array of channel files

def get_input(stem: str) -> str:
    "Get full input path for stem"
    return "./images/" + stem

def tile_img_name(chn_id: str, tile_num: int) -> str:
    "File name from channel id and tile number"
    return f"Sentinel20m-{chn_id}-20200215-{tile_num:03d}.png"

def get_channel_filenames(chn_ids, tile_idx):
    "Get list of all channel filenames for one tile idx"
    return [get_input(tile_img_name(x, tile_idx)) for x in chn_ids]

then the following code creates a class that can load 11 Sentinel 2 channels into a TensorImageMS.

from fastgs.vision.io import * # defines read_multichan_files_as_tensor

snt_12 = Sentinel2(
    ["B02","B03","B04","B05","B06","B07","B08","B8A","B11","B12","AOT"],
    [Sentinel2.natural_color, ["B07","B06","B05"],["B12","B11","B8A"],["B08"]],
    get_channel_filenames,
    read_multichan_files_as_tensor
)

The second parameter is a list of 4 channel sets that are minimally required to visualize all the individual channels.

img_12 = snt_12.load_tensor(66)
img_12.show()
[<AxesSubplot:>, <AxesSubplot:>, <AxesSubplot:>, <AxesSubplot:>]

Acknowledgements

This library is inspired by the following notebooks (and related works by the authors)

Download files

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

Source Distribution

fastgs-0.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastgs-0.0.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file fastgs-0.0.2.tar.gz.

File metadata

  • Download URL: fastgs-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.6

File hashes

Hashes for fastgs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 084ef05eac3a8b79953c7bc779458e12e6c64a870912101aea7460058faef320
MD5 4553bfa53fb8414c491464bd498a2329
BLAKE2b-256 dde1df99d9aceb4fd7291fdd50f4c39810e8f6f2ff5c05796839a51e0fdd2294

See more details on using hashes here.

File details

Details for the file fastgs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fastgs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.6

File hashes

Hashes for fastgs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4eb628e79cc305e7fee9fed1b4e0ce360d978bc9efbe8c69c47dbc3d7f293a2a
MD5 c2e8a67a608c64365b81227f9cf5afc2
BLAKE2b-256 461aac8448598edc2dda5d63ff23b06fd7f9ea8c1fa8040ad324de3157507491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page