DOI: 10.5281/zenodo.7677961
title: Cape Hatteras Landsat8 RGB Images and Labels for Image Segmentation using the program, Segmentation Zoo

description: # Cape Hatteras Landsat8 RGB Images and Labels for Image Segmentation using the program, Segmentation Gym ## Overview<br> * Test datasets and files for testing the [segmentation gym](https://github.com/Doodleverse/segmentation_gym) program for image segmentation<br> * Data set made by Daniel Buscombe, Marda Science LLC.<br> * Dataset consists of a time-series of Landsat-8 images of Cape Hatteras National Seashore, courtesy of the U.S. Geological Survey.<br> * Imagery spans the period February 2015 to September 2021.<br> * Labels were created by Daniel Buscombe, Marda Science, using the labeling program [Doodler](https://github.com/Doodleverse/dash_doodler). Download this file and unzip to somewhere on your machine (although *not* inside the `segmentation_gym` folder), then see the relevant page on the [segmentation gym wiki](https://github.com/Doodleverse/segmentation_gym/wiki) for further explanation. This dataset and associated models were made by Dr Daniel Buscombe, Marda Science LLC, for the purposes of demonstrating the functionality of Segmentation Gym. The labels were created using [Doodler](https://github.com/Doodleverse/dash_doodler/). Previous versions: 1.0. https://zenodo.org/record/5895128#.Y1G5s3bMIuU original release, Oct 2021, conforming to Segmentation Gym functionality on Oct 2021 2.0 https://zenodo.org/record/7036025#.Y1G57XbMIuU, Jan 23 2022, conforming to Segmentation Gym functionality on Jan 23 2022 This is version 4.0, created 2/25/23, and has been tested with Segmentation Gym using doodleverse-utils 0.0.26 https://pypi.org/project/doodleverse-utils/0.0.26/ ## file structure ```{sh}<br> /Users/Someone/my_segmentation_zoo_datasets<br> │ ├── config<br> │ | └── *.json<br> │ ├── capehatteras_data<br> | | ├── fromDoodler<br> | | | ├──images<br> │ | | └──labels<br> | | ├──npzForModel<br> │ | └──toPredict<br> │ └── modelOut<br> │ └── *.png<br> │ └── weights<br> │ └── *.h5 ``` ## config<br> There are 4 config files:<br> 1. `/config/hatteras_l8_resunet.json`<br> 2. `/config/hatteras_l8_vanilla_unet.json`<br> 3. `/config/hatteras_l8_resunet_model2.json` 4. `/config/hatteras_l8_segformer.json`<br> The first two are for res-unet and unet models respectively. The third one differs from the first only with specification of kernel size. It is provided as an example of how to conduct model training experiments, modifying one hyperparameter at a time in the effort to create an optimal model. The last one is based on the new Segformer model architecture. They all contain the same essential information and differ as indicated below ```<br> {<br> "TARGET_SIZE": [768,768], # the size of the imagery you wish the model to train on. This may not be the original size<br> "MODEL": "resunet", # model name. Otherwise, "unet" or "segformer"<br> "NCLASSES": 4, # number of classes<br> "KERNEL":9, # horizontal size of convolution kernel in pixels<br> "STRIDE":2, # stride in convolution kernel<br> "BATCH_SIZE": 7, # number of images/labels per batch<br> "FILTERS":6, # number of filters<br> "N_DATA_BANDS": 3, # number of image bands<br> "DROPOUT":0.1, # amount of dropout<br> "DROPOUT_CHANGE_PER_LAYER":0.0, # change in dropout per layer<br> "DROPOUT_TYPE":"standard", # type of dropout. Otherwise "spatial"<br> "USE_DROPOUT_ON_UPSAMPLING":false, # if true, dropout is used on upsampling as well as downsampling<br> "DO_TRAIN": false, # if false, the model will not train, but you will select this config file, data directory, and the program will load the model weights and test the model on the validation subset<br> if true, the model will train from scratch (warning! this will overwrite the existing weights file in h5 format)<br> "LOSS":"dice", # model training loss function, otherwise "cat" for categorical cross-entropy<br> "PATIENCE": 10, # number of epochs of no model improvement before training is aborted<br> "MAX_EPOCHS": 100, # maximum number of training epochs<br> "VALIDATION_SPLIT": 0.6, #proportion to use for validation<br> "RAMPUP_EPOCHS": 20, # [LR-scheduler] rampup to maximim<br> "SUSTAIN_EPOCHS": 0.0, # [LR-scheduler] sustain at maximum<br> "EXP_DECAY": 0.9, # [LR-scheduler] decay rate<br> "START_LR": 1e-7, # [LR-scheduler] start lr<br> "MIN_LR": 1e-7, # [LR-scheduler] min lr<br> "MAX_LR": 1e-4, # [LR-scheduler] max lr<br> "FILTER_VALUE": 0, #if &gt;0, the size of a median filter to apply on outputs (not recommended unless you have noisy outputs)<br> "DOPLOT": true, #make plots<br> "ROOT_STRING": "hatteras_l8_aug_768", #data file (npz) prefix string<br> "USEMASK": false, # use the convention 'mask' in label image file names, instead of the preferred 'label'<br> "AUG_ROT": 5, # [augmentation] amount of rotation in degrees<br> "AUG_ZOOM": 0.05, # [augmentation] amount of zoom as a proportion<br> "AUG_WIDTHSHIFT": 0.05, # [augmentation] amount of random width shift as a proportion<br> "AUG_HEIGHTSHIFT": 0.05,# [augmentation] amount of random width shift as a proportion<br> "AUG_HFLIP": true, # [augmentation] if true, randomly apply horizontal flips<br> "AUG_VFLIP": false, # [augmentation] if true, randomly apply vertical flips<br> "AUG_LOOPS": 10, #[augmentation] number of portions to split the data into (recommended &gt; 2 to save memory)<br> "AUG_COPIES": 5 #[augmentation] number iof augmented copies to make<br> "SET_GPU": "0" #which GPU to use. If multiple, list separated by a comma, e.g. '0,1,2'. If CPU is requested, use "-1"<br> "WRITE_MODELMETADATA": false, #if true, the prompts `seg_images_in_folder.py` to write detailed metadata for each sample file<br> "DO_CRF": true #if true, apply CRF post-processing to outputs "LOSS_WEIGHTS": false, #if true, apply per-class weights to loss function "MODE": "all", #'all' means use both non-augmented and augmented files, "noaug" means use non-augmented only, "aug" uses augmented only "SET_PCI_BUS_ID": true, #if true, make keras aware of the PCI BUS ID (advanced or nonstandard GPU usage) "TESTTIMEAUG": true, #if true, apply test-time augmentation when model in inference mode "WRITE_MODELMETADATA": true,# if true, write model metadata per image when model in inference mode "OTSU_THRESHOLD": true# if true, and NCLASSES=2 only, use per-image Otsu threshold rather than decision boundary of 0.5 on softmax scores }<br> ``` ## capehatteras_data<br> Folder containing all the model input data ```{sh}<br> │ ├── capehatteras_data: folder containing all the model input data<br> | | ├── fromDoodler: folder containing images and labels exported from Doodler using [this program](https://github.com/dbuscombe-usgs/dash_doodler/blob/main/utils/gen_images_and_labels_4_zoo.py)<br> | | | ├──images: jpg format files, one per label image<br> │ | | └──labels: jpg format files, one per image<br> | | ├──npzForModel: npz format files for model training using [this program](https://github.com/dbuscombe-usgs/segmentation_zoo/blob/main/train_model.py) that have been created following the workflow [documented here](https://github.com/dbuscombe-usgs/segmentation_zoo/wiki/Create-a-model-ready-dataset) using [this program](https://github.com/dbuscombe-usgs/segmentation_zoo/blob/main/make_nd_dataset.py)<br> │ | └──toPredict: a folder of images to test model prediction using [this program](https://github.com/dbuscombe-usgs/segmentation_zoo/blob/main/seg_images_in_folder.py)<br> ``` ## modelOut<br> PNG format files containing example model outputs from the train ('_train_' in filename) and validation ('_val_' in filename) subsets as well as an image showing training loss and accuracy curves with `trainhist` in the filename. There are two sets of these files, those associated with the residual unet trained with dice loss contain `resunet` in their name, and those from the UNet are named with `vanilla_unet`. ## weights<br> There are model weights files associated with each config files.