This repository provides the implementation (tensorflow), pre-trained model and dataset corresponding to the paper:
Lake Ice Monitoring with Webcams and Crowd-Sourced Images (presented at the ISPRS Congress, 2020, virtual conference)
by Rajanie Prabha, Manu Tom, Mathias Rothermel, Emmanuel Baltsavias, Laura Leal-Taixe and Konrad Schindler
This work is part of the Lake Ice Project (Phase 2) funded by MeteoSwiss in the GCOS Switzerland framework. Here is the link to Phase 1 of the same project.
- Deeplab v3+ tensorflow model adopted from official tensorflow repository with some changes. (a). Code for calculating Individual class IoU. (b). Code for checking confusion matrix on tensorboard. (c). Updated xception_65 model with extra skips from encoder to decoder.
- Using labelme tool to create data annotations and code for converting json annotations to color-indexed masks.
- Some data cleaning scripts (only valid for our Photi-LakeIce dataset).
- Jupyter Notebook for visualizing data distribution for 5 classes : background, water, ice, snow, clutter.
- Jupyter Notebook for inference using a saved tensorflow checkpoint.
Data Folder structure:
├── datasets
├── lake
├── JPEGImages
├── SegmentationClassPNG
├── SegmentationClassRaw
├── Imagesets
├── train.txt
├── val.txt
├── abc.tfrecord
- Place the Images in JPEGImages and segmentation color masks in SegmentationClassPNG. Run remove_gt_colormap_lakeice.py to covert the RGB color codes to class number, i.e. 0 for Background, 1 for Water, 2 for Ice, and so on. Take care of paths label_dir (SegmentationClassPNG directory) and new_label_dir (SegmentationClassRaw directory).
- Create a folder Imagesets which contains the train.txt (training image sample names) and val.txt (testing image sample names) files. Refer sampletrain.txt in datasets folder to see how the txt files look.
- Update data_generator.py file. Specifically, update the numbers for train samples and val samples in _LAKEICE_INFORMATION.
- Now, Convert data into tensorflow record by running bash script download_and_convert_lakeice.sh (Take care of the directory paths in the script).
Voila, now you have the dataset to train your model.
By simply running the train_lakeice.sh, the training will start. For parameters: the specified values were used for all experiments.
- Setup up the tensorflow records in LAKEICE_DATASET parameter.
- --model_variant="xception_65" -> Change to "xception_65_skips" to use Deep-U-Lab --skips=0 -> Change to 1, if using "xception_65_skips" --atrous_rates=6 --atrous_rates=12 --atrous_rates=18 --output_stride=16 --decoder_output_stride=4 --train_crop_size="321,321" -> Used 512,512 for lake-detection and 321,321 for lake-ice segmentation --dataset="lake" --train_batch_size=8 -> Set according to GPU availability. This should be >=16 for tuning the batch norm layers --training_number_of_steps="${NUM_ITERATIONS}" --fine_tune_batch_norm=false -> Set to "true" if train_batch_size>=16 --train_logdir="${TRAIN_LOGDIR}" --base_learning_rate=0.0001 --learning_policy="poly" --tf_initial_checkpoint="/your_checkpoint_folder_name/model.ckpt" (You may update this!) --dataset_dir="${LAKEICE_DATASET}"
For evaluation and visualization, run the eval_lakeice.sh script.
--eval_split="val" -> Split should be "val", instead of "train" --model_variant="xception_65" -> Same rules as train script --skips=0 --eval_crop_size="325,1210" -> Full image eval_crop_size --max_number_of_evaluations=1 -> If set to 1, evaluation script will run once and exit. If >1, it will keep checking the train logdir for new checkpoints. Useful, when running both train and eval scripts simultaneously (alloting part of GPU to both).
Download the model pre-trained on Lake St. Moritz data (Cam0, winter 2016-17) from the Photi-LakeIce dataset. Approximate size: 146 MB
-
for no modules called nets. Get the 'slim' directory from https://github.com/tensorflow/models/tree/master/research and from the research folder, run
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
-
Iterator end of line error. Look for empty lines in the dataset/"your dataset"/List/"train or val".txt files.
-
Dataset split in train.py and eval.py, be careful to not use the default "trainval" split from original tensorflow deeplab repository.
Please cite our paper, if you use this repo:
@article{prabha_tom_2020:isprs,
author={Rajanie Prabha and Manu Tom and Mathias Rothermel and Emmanuel Baltsavias and Laura Leal-Taixe and Konrad Schindler},
title={Lake Ice Monitoring with Webcams and Crowd-Sourced Images},
booktitle={ISPRS Ann. Photogramm. Remote Sens. Spatial Inf. Sci.},
year={2020},
volume={V-2-2020},
pages={549–556},
}
- Photi-Lake Ice Dataset (Github repo)
- Multi-sensor lake ice monitoring with machine (deep) learning. Project github page.
- Lake ice detection from Sentinel-1 SAR with deep learning. Github repo (tensorflow code, pre-trained model). Paper
- Tom, M., Suetterlin, M., Bouffard, D., Rothermel, M., Wunderle, S., Baltsavias, E., 2019. Integrated monitoring of ice in selected Swiss lakes. Final Project Report
- Tom et al. 2020, Ice monitoring in Swiss lakes from optical satellites and webcams using machine learning, MDPI Remote Sensing, 12(21), 3555
- Deeplab v3+
MIT License
Copyright (c) 2020 ETH Zurich
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Author: Manu Tom