Metadata-Version: 2.1
Name: fastgs
Version: 0.0.27
Summary: Geospatial (Sentinel2 Multi-Spectral) support for fastai
Home-page: https://github.com/restlessronin/fastgs
Author: restlessronin
Author-email: 88921269+restlessronin@users.noreply.github.com
License: Apache Software License 2.0
Keywords: geospatial multi-spectral sentinel2 fastai nbdev jupyter notebook python
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastai (>=2.7.10)
Provides-Extra: dev
Requires-Dist: albumentations ; extra == 'dev'
Requires-Dist: ffmpeg ; extra == 'dev'

Welcome to fastgs
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Introduction

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

This library provides geospatial multi-spectral 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.

## Sample Notebooks

You can find demo usage of the library in these notebooks

1.  working with the kaggle [38-cloud/95-cloud landsat
    dataset](https://www.kaggle.com/code/restlessronin/cloud95-fastai-with-fastgs-multispectral-support).
2.  working on a segmentation problem with a [Sentinel 2
    dataset](https://www.kaggle.com/code/restlessronin/lila-sentinel-2-segmentation-with-fastai)

These are boths works in progress and optimized to display the features
of the library, rather than the best possible results. Even so, the
“cloud 95” notebook is providing results comparable to other hiqh
quality notebooks on the same dataset.

## Install

``` sh
pip install -Uqq fastgs
```

``` sh
conda install -c restlessronin 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`](https://restlessronin.github.io/fastgs/vision.core.html#tensorimagems)
subclass of `fastai` `TensorImage` which itself is a subclass of the
`pytorch` `Tensor`).

``` python
from fastgs.multispectral import *
```

The following code creates a class that can load 11 Sentinel 2 channels
into a
[`TensorImageMS`](https://restlessronin.github.io/fastgs/vision.core.html#tensorimagems).

``` python
from fastgs.test.io import * # defines read_multichan_files_as_tensor

sentinel2 = createSentinel2Descriptor()

snt_12 = MSData.from_all(
    sentinel2,
    ["B02","B03","B04","B05","B06","B07","B08","B8A","B11","B12","AOT"],
    [sentinel2.rgb_combo["natural_color"], ["B07","B06","B05"],["B12","B11","B8A"],["B08"]],
    get_channel_filenames,
    read_multichan_files
)
```

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

``` python
img_12 = snt_12.load_image(66)
img_12.show()
```

    [<AxesSubplot:>, <AxesSubplot:>, <AxesSubplot:>, <AxesSubplot:>]

![](index_files/figure-gfm/cell-4-output-2.png)

This lower level functionality is made available by higher level wrapper
APIs for creating data loaders, adding augmentations, displaying
batches, results and top losses.

## Acknowledgements

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

- Mauricio Cordeiro’s [multi-spectral segmentation fastai
  pipeline](https://www.kaggle.com/code/cordmaur/remotesensing-fastai2-multiband-augmentations/notebook)
- Nick Wright’s [multi-spectral classification
  notebook](https://dpird-dma.github.io/blog/Multispectral-image-classification-Transfer-Learning//)
