Skip to content

Semantic segmentation of marine anomalies using semi-supervised learning (FixMatch for semantic segmentation) on Sentinel-2 multispectral images.

License

Notifications You must be signed in to change notification settings

lucamarini22/marine-anomaly-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Report

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage

About the project

The marine-anomaly-detection project provides code to apply the state of the art of semi-supervised learning techniques to marine anomaly detection semantic segmentation problems on satellite imagery of marine regions. The considered anomalies are marine-litter (marine debris), ships, clouds, and algae/organic materials.

The code builds on and extends the following two repositories:

  • FixMatch-pytorch implementation based on PyTorch. Compared to the original repository, this repository adapts FixMatch to be used for semantic segmentation tasks and to work with multispectral images.
  • marine-debris.github.io, which provides the code to work with the MARIDA dataset.

Getting Started

Prerequisites

It is recommended to use conda to set-up the environment. conda will take care of all requirements for you. For a detailed list of required packages, please refer to the conda environment file.

Installation

  1. Get micromamba, or Miniconda, or similar. Micromamba is preferred to Miniconda for its greater speed in creating the virtual environment.
  2. Clone the repo.
    git clone https://github.com/lucamarini22/marine-anomaly-detection.git
  3. Setup and activate the environment. This will create a conda environment called marine-anomaly-detection.
    micromamba env create -f environment.yml
    micromamba activate marine-anomaly-detection
  4. [Optional] Install the local package.
    pip install -e .
    

Set up dataset

To launch the training on MARIDA, it is necessary to download the dataset. The dataset can be downloaded here and has the following structure:

  • patches: folder containing the patches (multispectral images).
  • splits: folder containing split files of the training, validation, and test sets.

The --patches_path and --splits_path arguments in marineanomalydetection/parse_args_train.py file shall be respectively point to the patches and splits folders.

Usage

Training

  1. Create a Weight and Biases account to keep track of the runs.
  2. Set the values of the hyperparameters in this config.yaml file.
  3. Enter the main folder.
    cd /marine-anomaly-detection/
  4. Create a Sweep to keep track of your training runs.
    wandb sweep --project <project-name> <config-file.yaml>
    
  5. Specify all the values of the arguments in marineanomalydetection/parse_args_train.py you did not specify in <config-file.yaml>.
  6. Start an agent and execute $NUM training runs.
    wandb agent --count $NUM <your-entity/sweep-demo-cli/sweepID>
    

Evaluation

  1. Evaluate a model.
    python evaluation.py --model_path=<path_to_model>
    
  2. Visualize the predictions of the last evaluated model by running the cells of the notebook Visualize Predictions.ipynb. Specify the variable tile_name to see the predictions for the patches of the specified tile.