Cape Hatteras Landsat8 RGB Images and Labels for Image Segmentation using the program, Segmentation Zoo
收藏资源简介:
# 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. This is version 5.0<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 5.0, created 7/20/23, and has been tested with Segmentation Gym using doodleverse-utils 0.0.33 https://pypi.org/project/doodleverse-utils/0.0.33/ ## 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 >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 > 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> "LOSS_WEIGHTS": false, #if true, apply per-class weights to loss function "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> | | ├──npz4gym 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.
# 哈特拉斯角陆地卫星8号RGB图像与标签数据集 —— 用于通过Segmentation Gym程序开展图像分割 ## 概述 本数据集为用于测试[Segmentation Gym(Segmentation Gym)](https://github.com/Doodleverse/segmentation_gym)图像分割程序的测试数据集与配套文件。 本数据集由Marda Science LLC的Daniel Buscombe制作,当前版本为5.0。 数据集包含美国地质调查局提供的哈特拉斯角国家海岸的陆地卫星8号(Landsat 8)时间序列影像。 影像时间跨度为2015年2月至2021年9月。 标签由Marda Science的Daniel Buscombe通过标注工具Doodler(Doodler)制作。请下载本数据集文件并解压至本地任意路径(请勿置于`segmentation_gym`文件夹内),随后可参考[Segmentation Gym维基页面](https://github.com/Doodleverse/segmentation_gym/wiki)的相关章节获取进一步说明。本数据集与配套模型由Marda Science LLC的Daniel Buscombe博士制作,用于演示Segmentation Gym的功能。标签均通过[Doodler(Doodler)](https://github.com/Doodleverse/dash_doodler/)生成。 历史版本: 1.0版本:https://zenodo.org/record/5895128#.Y1G5s3bMIuU,2021年10月发布,适配2021年10月版Segmentation Gym功能 2.0版本:https://zenodo.org/record/7036025#.Y1G57XbMIuU,2022年1月23日发布,适配2022年1月23日版Segmentation Gym功能 本版本为5.0,制作于2023年7月20日,已通过使用doodleverse-utils 0.0.33版本的Segmentation Gym测试(https://pypi.org/project/doodleverse-utils/0.0.33/) ## 文件结构 bash /Users/Someone/my_segmentation_zoo_datasets │ ├── config │ └── *.json ├── capehatteras_data │ ├── fromDoodler │ │ ├── images │ │ └── labels │ ├── npzForModel │ └── toPredict └── modelOut │ └── *.png └── weights └── *.h5 ## 配置文件 本数据集包含4个配置文件: 1. `/config/hatteras_l8_resunet.json` 2. `/config/hatteras_l8_vanilla_unet.json` 3. `/config/hatteras_l8_resunet_model2.json` 4. `/config/hatteras_l8_segformer.json` 其中前两个分别对应残差U-Net(res-unet)与普通U-Net(unet)模型。第三个配置文件与第一个的区别仅为卷积核尺寸的设置,用于演示如何通过单次修改一个超参数开展模型训练实验以寻求最优模型。最后一个配置文件基于最新的SegFormer(SegFormer)模型架构。所有配置文件均包含核心通用信息,差异如下所述: json { "TARGET_SIZE": [768, 768], # 模型训练所需的影像尺寸,该尺寸可能与原始影像尺寸不一致 "MODEL": "resunet", # 模型名称,可选值为"unet"或"segformer" "NCLASSES": 4, # 类别总数 "KERNEL": 9, # 卷积核的水平像素尺寸 "STRIDE": 2, # 卷积步长 "BATCH_SIZE": 7, # 每批次训练的图像-标签对数量 "FILTERS": 6, # 滤波器数量 "N_DATA_BANDS": 3, # 图像波段数 "DROPOUT": 0.1, # Dropout比例 "DROPOUT_CHANGE_PER_LAYER": 0.0, # 各层Dropout比例的增量 "DROPOUT_TYPE": "standard", # Dropout类型,可选值为"spatial" "USE_DROPOUT_ON_UPSAMPLING": false, # 若为true,则在上采样阶段同样应用Dropout "DO_TRAIN": false, # 若为false,程序将加载已有模型权重并在验证子集上测试模型;若为true,则将从头开始训练模型(警告:该操作将覆盖现有的h5格式权重文件) "LOSS": "dice", # 模型训练损失函数,可选值为"cat"(分类交叉熵) "PATIENCE": 10, # 模型性能无提升时,训练提前终止的轮次阈值 "MAX_EPOCHS": 100, # 最大训练轮次 "VALIDATION_SPLIT": 0.6, # 划分为验证集的数据比例 "RAMPUP_EPOCHS": 20, # [学习率调度器] 学习率升至最大值的轮数 "SUSTAIN_EPOCHS": 0.0, # [学习率调度器] 保持最大学习率的轮数 "EXP_DECAY": 0.9, # [学习率调度器] 学习率衰减率 "START_LR": 1e-7, # [学习率调度器] 初始学习率 "MIN_LR": 1e-7, # [学习率调度器] 最小学习率 "MAX_LR": 1e-4, # [学习率调度器] 最大学习率 "FILTER_VALUE": 0, # 若大于0,则对模型输出应用中值滤波(除非输出存在噪声,否则不推荐启用) "DOPLOT": true, # 是否生成可视化图表 "ROOT_STRING": "hatteras_l8_aug_768", # 数据文件(npz格式)的前缀字符串 "USEMASK": false, # 是否在标签文件名中使用"mask"而非推荐的"label" "AUG_ROT": 5, # [数据增强] 旋转角度范围(单位:度) "AUG_ZOOM": 0.05, # [数据增强] 缩放比例的波动范围 "AUG_WIDTHSHIFT": 0.05, # [数据增强] 水平随机偏移的比例 "AUG_HEIGHTSHIFT": 0.05, # [数据增强] 垂直随机偏移的比例 "AUG_HFLIP": true, # [数据增强] 是否启用随机水平翻转 "AUG_VFLIP": false, # [数据增强] 是否启用随机垂直翻转 "AUG_LOOPS": 10, # [数据增强] 数据拆分的份数(建议大于2以节省内存) "AUG_COPIES": 5, # [数据增强] 每张原始样本生成的增强样本数量 "SET_GPU": "0", # 使用的GPU编号,多GPU时以逗号分隔,例如"0,1,2";若使用CPU则设为"-1" "WRITE_MODELMETADATA": false, # 若为true,则`seg_images_in_folder.py`将为每个样本文件写入详细元数据 "LOSS_WEIGHTS": false, # 若为true,则为损失函数应用类别权重 "SET_PCI_BUS_ID": true, # 若为true,则使Keras识别PCI总线ID(适用于高级或非标准GPU使用场景) "TESTTIMEAUG": true, # 若为true,则在模型推理阶段应用测试时增强 "WRITE_MODELMETADATA": true, # 若为true,则在模型推理阶段为每张图像写入模型元数据 "OTSU_THRESHOLD": true # 若为true且类别数为2,则对每张图像使用Otsu阈值而非基于0.5的Softmax决策边界 } ## capehatteras_data文件夹 该文件夹包含所有模型输入数据,结构如下: bash │ ├── capehatteras_data: 存储所有模型输入数据的文件夹 │ │ ├── fromDoodler: 存储通过[该工具](https://github.com/dbuscombe-usgs/dash_doodler/blob/main/utils/gen_images_and_labels_4_zoo.py)从Doodler导出的图像与标签 │ │ │ ├── images: JPG格式的图像文件,与标签一一对应 │ │ │ └── labels: JPG格式的标签文件,与图像一一对应 │ │ ├── npzForModel: 存储通过遵循[该工作流](https://github.com/dbuscombe-usgs/segmentation_zoo/wiki/Create-a-model-ready-dataset),并使用[该工具](https://github.com/dbuscombe-usgs/segmentation_zoo/blob/main/make_nd_dataset.py)生成的、用于模型训练的npz格式文件 │ │ └── toPredict: 存储用于通过[该工具](https://github.com/dbuscombe-usgs/segmentation_zoo/blob/main/seg_images_in_folder.py)测试模型预测效果的图像文件夹 ## modelOut文件夹 该文件夹包含模型输出的PNG格式示例文件:其中文件名包含`_train_`的为训练子集的预测结果,包含`_val_`的为验证子集的预测结果,包含`trainhist`的为展示训练损失与准确率曲线的图像。本文件夹包含两类输出文件:文件名包含`resunet`的为使用Dice损失训练的残差U-Net模型结果,文件名包含`vanilla_unet`的为普通U-Net模型的结果。 ## weights文件夹 该文件夹包含与各配置文件对应的模型权重文件。



