/agrivision-2022

Agriculture Vision Workshop 2022

Primary LanguagePythonApache License 2.0Apache-2.0

Agriculture Vision 2022

Code for Augmentation Invariance and Adaptive Sampling in Semantic Segmentation of Agricultural Aerial Images (CVPRW 2022)

Installation

pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9/index.html
pip install -e .

Bring me to the important bits

Well, there are mostly two contributions in this work: augmentation invariance, and adaptive sampling.

  1. The augmentation invariance regularization is computed in custom.py
  2. The adaptive sampling is part of the dataset, in sampling.py

Preparation

Before training, you will need to format the dataset so that the labels and the boundaries are merged into a single image. Follow the conversion script located inside tools to carry this out.

Training

Single GPU

 CUDA_VISIBLE_DEVICES=$DEVICES tools/train.py [CONFIG_FILE] [OPTIONS]

Multi GPU

 source scripts/dist_train.sh [GPUS, e.g. 0,1] [CONFIG_FILE] [OPTIONS]

Testing

Evaluation only:

 CUDA_VISIBLE_DEVICES=$DEVICES python tools/test.py [CONFIG] --eval mIoU

Evaluate generating images:

 # evaluate while plotting masks
 CUDA_VISIBLE_DEVICES=$DEVICES python tools/test.py [CONFIG] --eval mIoU --show --opacity=1
 # evaluate while plotting RGB images
 CUDA_VISIBLE_DEVICES=$DEVICES python tools/test.py [CONFIG] --eval mIoU --show --opacity=0
 # evaluate while plotting IRRG images
 CUDA_VISIBLE_DEVICES=$DEVICES python tools/test.py [CONFIG] --eval mIoU --show --opacity=0 --channels irrg