benlib 1.0.0
Utilities for BigEarthNet
License: MIT
Requires Python: >=3.6
Keywords: BigEarthNet

# BigEarthNet Lib (benlib)

This package contains tools for processing the BigEarthNet Benchmark Archive. For further details about the archive and its download, you can visit the website of the [BigEarthNet](http://bigearth.net/) project.

## Installation

The package is available in the PyPI package manager and can be installed with the following command.

```bash
pip install benlib
```

## List of Tools and How to Use Them
After downloading the raw images from https://www.bigearth.net, they can be prepared for your ML application. The following list provides a set of tools to prepare BigEarthNet. The set of tools will be extended over the time. 


### Create TFRecord Files for Train/Test/Validation Splits
The command `CreateTFRecordFiles` generates consumable data files (i.e., [TFRecord](https://www.tensorflow.org/tutorials/load_data/tfrecord)) for training, validation and test splits which are particularly efficient in the use with Tensorflow. The following command line arguments can be specified:

* `-i` or `--input_folder`: The root folder containing the image patches you have previously downloaded (BigEarthNet root folder).
* `-o` or `--output_folder`: The output folder where the resulting files will be created.
* `-m` or `--mission`: The mission for which you want to create TFRecord files (either `S1` or `S2`)
* `-s` or `--splits`: A CSV file which contains the patch names of a corresponding split. Can be defined multiple times for multiple splits
* `-l` or `--labels`: The type of labels encoded into the TFRecord files (`BigEarthNet` labels and/or `BigEarthNet19` labels). 

Example Command:
```bash
benlib CreateTFRecordFiles \
        -i=./BigEarthNet-Archive/ \
        -o=./some_output_folder/ \
        -m=S2 \
        -s=./train.csv -s=./test.csv -s=./val.csv \
        -l=BigEarthNet -l=BigEarthNet19
```

### Create combined TFRecord Files for S1 and S2 for Train/Test/Validation Splits
The command `CreateTFRecordFilesS1S2` generates combined TFRecord files for Sentinel-1 and Sentinel-2 patches for train, validation, and tests splits, which are particularly efficient in the use with Tensorflow. The following command line arguments can be specified:

* `-s1` or `--s1_input_folder`: The root folder containing the Sentinel-1 patches you have previously downloaded (BigEarthNet-S1 root folder).
* `-s2` or `--s2_input_folder`: The root folder containing the Sentinel-2 patches you have previously downloaded (BigEarthNet-S2 root folder).
* `-o` or `--output_folder`: The output folder where the resulting files will be created.
* `-s` or `--splits`: A CSV file which contains the patch names of a corresponding split. The CSV must list both the S2 patches (first column) and the corresponding S1 patches (second column). Can be defined multiple times for multiple splits.
* `-l` or `--labels`: The type of labels encoded into the TFRecord files (`BigEarthNet` labels and/or `BigEarthNet19` labels). 

Example Command:
```bash
benlib CreateTFRecordFilesS1S2 \
        -s1=./BigEarthNet-S1-Archive/ \
        -s2=./BigEarthNet-S2-Archive/ \
        -o=./some_output_folder/ \
        -s=./train.csv -s=./test.csv -s=./val.csv \
        -l=BigEarthNet -l=BigEarthNet19
```

### Create MLDB Files for Train/Test/Validation Splits
Coming soon.

# Authors
**Arne de Wall**
https://www.rsim.tu-berlin.de/menue/team/arne_dewall/

# License
The BigEarthNet Archive is licensed under the **Community Data License Agreement – Permissive, Version 1.0** ([Text](https://cdla.io/permissive-1-0/)).

The code in this repository to facilitate the use of the archive is licensed under the **MIT License**:

```
MIT License

Copyright (c) 2019 The BigEarthNet Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```