Skip to content

Set of ML algorithms for cloud detection in stellite images trained using Sentinel-2 imagery.

Notifications You must be signed in to change notification settings

JoseCelis/cloud-I

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloud-I

Blog post explaining this project in more detail can be found HERE.

Description

Set of ML algorithms for cloud detection in satellite images trained using Sentinel-2 imagery.

In this project we download and preprocess image files from the data collection SENTINEL2_L2A using sentinelhub.

Prerequisites

Make sure you have the following software installed:

  • Python 3.11

To create a virtual environment of this project, open a terminal, go to the root path of this project and type this:

> pip install pipenv
> pipenv install --dev

Setting up enviromental variables

In the root folder, create a .env file with the following information:

# sentinelhub credentials
CLIENT_ID = <your client_id>
CLIENT_SECRET = <your client secret>

# dagshub ML_FLOW credentials
MLFLOW_TRACKING_URI=https://dagshub.com/<your dagshub username>/cloud-I.mlflow
MLFLOW_TRACKING_USERNAME=<your dagshub username>
MLFLOW_TRACKING_PASSWORD=<your mlflow tracking password>

To get the sentinelhub credentials:

To get the dagshub ML_FLOW credentials, follow this documentation.

Import images

You can use the script src/import_image.py .

This script downloads the images from remote repository using the sentinelhub python package. Be sure you already requested your CLIENT_ID and CLIENT_SECRET.

Preprocess

To preprocess the Sentinel-2 images, you can use the script src/preprocess.py .

This script improves the brightness and contrast of the images using two transformations. It also creates cloud masks using the cloud probability files downloaded.

Data augmentation is done by rotating the pictures 90, 180 and 270 degrees, as well as vertical and horizontal flips.

Modeling

You can use the script src/model.py .

Different models are implemeted: Random Forest, ANN, FCNN, UNET.

To train a specific model, write in your terminal (inside your environment): python src/model.py --model_name=<model name>, where

  • --model_name=rf trains a Random Forest.
  • --model_name=ann trains an ANN.
  • --model_name=unet trains a U-NET model.
  • --model_name=segnet trains a SegNet model.
  • --model_name=yolo trains YOLO.

If you want to make a prediction with an already trained model that is saved, use: python src/model.py --model_name=<model name> --train_model=False

FAQ

I have my own data. Where do I store it to run the models?

You need to create a folder called Dataset/ in the root path of the project. The structure of this folder is as follows:

├── Dataset                      
│   ├── images  
│       ├── train
│           ├── <train image name 1>.png
│           ├── ...
│       ├── val
│           ├── <validation image name 1>.png
│           ├── ...
│   ├── masks  
│       ├── train
│           ├── <train mask name 1>.png
│           ├── ...
│       ├── val
│           ├── <validation mask name 1>.png
│           ├── ...
│   ├── labels  
│       ├── train
│           ├── <train image name 1>.txt
│           ├── ...
│       ├── val
│           ├── <validation image name 1>.txt
│           ├── ...
│   ├── test
│       ├── <test image name>.png
│       ├── <test mask name>.png

IMPORTANT: The code is designed to test the models on a single image.

About

Set of ML algorithms for cloud detection in stellite images trained using Sentinel-2 imagery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages