CNNvsTransformer: Comparing CNN- and Transformer-Based Deep Learning Models for Semantic Segmentation of Remote Sensing Images
Master Thesis at the Institute for Geoinformatics, University of Münster, Germany.
With the given code, results for the thesis mentioned above were created.
The thesis is available as pdf file in this repository at \thesis.
In the following some basic steps to use the code are described but might need some adaptations, based on the utilized infrastructure.
Further documentation will be added soon.
- Prepare data
- Download data, for example one of:
- Patchify data into appropriate sizes, e.g.
$512\times 512$ -
\helper\patchify.pymight be useful
-
- Split data into train and test data in the following folder structure, with
rgbfolders containing the corresponding images to the groundtruth labels in thelabelfolders:
|-- data
| |-- rgb
| |-- rgb_test
| |-- label
| |-- label_test
- If you use the PALMA cluster, just adapt and run one of
\PALMA\train_unet.shor\PALMA\train_segformer.shand you are done - Otherwise: Install requirements (see
\PALMA\requirements.txtand modules in\PALMA\train_unet.sh) - Look at possible parameters in
train.pyand run the following line with respective adjustments:
python3 train.py --data_path /your/path/to/folder/data --name ./weights
- Find your model in folder
./weights
By default a U-Net model will be trained for 20 epochs. Further default settings can be derived from the parameters of train.py.
The evaluation and visualization of the models was done with help of the notebooks in the respective ./Notebooks directory.
compare.ipynb: comparison of two models by visualizing predictions of both and calculating metrics on test datahomogeneity.ipynb: calculation of clustering evaluation measuresradarchart.ipynb: plot radar charts and bar charts for the calculated metricscount_classes.ipynb: count pixels per class and mean and standard deviation in an image dataset- OUTDATED:
Segformer_Run.ipynb,UNet_Run.ipynb,Segformer_visualize_attention.ipynb
A lot of the code was inspired by https://github.com/suryajayaraman/Semantic-Segmentation-using-Deep-Learning.