├── LICENSE ├── README.md ├── configs ├── gta5.yaml └── synthia.yaml ├── datasets ├── NTHU_list │ ├── Rio │ │ └── List │ │ │ ├── test.txt │ │ │ └── train.txt │ ├── Rome │ │ └── List │ │ │ ├── test.txt │ │ │ └── train.txt │ ├── Taipei │ │ └── List │ │ │ ├── test.txt │ │ │ └── train.txt │ └── Tokyo │ │ └── List │ │ ├── test.txt │ │ └── train.txt ├── __init__.py ├── city_dataset_test_ours.py ├── city_list │ ├── demoVideo.txt │ ├── test.txt │ ├── train.txt │ ├── trainval.txt │ └── val.txt ├── cityscapes ├── cityscapes_Dataset.py ├── gta5_Dataset.py ├── gta5_list │ ├── all.txt │ ├── test.txt │ ├── train.txt │ ├── trainval.txt │ └── val.txt ├── synscapes_list │ ├── all.txt │ ├── train.txt │ └── val.txt ├── synthia_Dataset.py └── synthia_list │ ├── train.txt │ └── val.txt ├── main.py ├── main_edge_enhance.py ├── models ├── __init__.py ├── deeplab_multi.py └── ema.py ├── perturbations ├── augmentations.py ├── cutmix.py └── fourier.py ├── requirements.txt ├── scripts ├── video-from-frames.sh └── video-visualization.ipynb ├── train.sh └── utils ├── __init__.py ├── __pycache__ ├── __init__.cpython-37.pyc ├── eval.cpython-37.pyc └── loss.cpython-37.pyc ├── eval.py ├── loss.py └── train_helper.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ljjcoder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EHTDI 2 | Official implementation of "Exploring High-quality Target Domain Information for Unsupervised Domain Adaptive Semantic Segmentation". [here](https://arxiv.org/abs/2208.06100) 3 | 4 | Accepted by ACM MM'22. 5 | 6 | #### Our method does not require the distillation technique and requires only 1*3090 GPU. 7 | #### News!!!!!!!!!!!! 8 | We released the code for edge enhancement loss 9 | 10 | ## Main Results 11 | 12 | ### GTA5-to-CityScapes and SYNTHIA-to-CityScapes 13 | | | GTA5-to-CityScapes| | SYNTHIA-to-CityScapes| | 14 | |----------------------|---------------------|---|------------------------|-| 15 | | |mIoU | |mIoU_13 (mIoU_16)| 16 | | Ours |58.8 | [Model](https://drive.google.com/file/d/1vNQHBitIDAiuY8IkmRDfVBShWX6qDiaC/view?usp=sharing)| 64.6 (57.8) |[Model](https://drive.google.com/file/d/1ICHI3mDpIQn82o5Q-VFOtPPEMLK-Ijf9/view?usp=sharing) | 17 | | Ours* |62.0| [Model](https://drive.google.com/file/d/1YmgnjG2bBIP7U1Egj2Yka4NCXGcF0ctd/view?usp=sharing) | 69.2 (61.3) |[Model](https://drive.google.com/file/d/1MLh61JU8JGfgdeBWnylFXMjhMh49lasa/view?usp=sharing) | 18 | 19 | *Indicates a new edge enhancement loss is added and still no distillation technology is required. 20 | 21 | #### Data Preparation 22 | To run on GTA5-to-Cityscapes and SYNTHIA-to-Cityscapes, you need to download the respective datasets. Once they are downloaded, you can either modify the config files directly, or organize/symlink the data in the `datasets/` directory as follows: 23 | ``` 24 | datasets 25 | ├── cityscapes 26 | │   ├── gtFine 27 | │   │   ├── train 28 | │   │   │   ├── aachen 29 | │   │   │   └── ... 30 | │   │   └── val 31 | │   └── leftImg8bit 32 | │   ├── train 33 | │   └── val 34 | ├── GTA5 35 | │   ├── images 36 | │   ├── labels 37 | │   └── list 38 | ├── SYNTHIA 39 | │   └── RAND_CITYSCAPES 40 | │   ├── Depth 41 | │   │   └── Depth 42 | │   ├── GT 43 | │   │   ├── COLOR 44 | │   │   └── LABELS 45 | │   ├── RGB 46 | │   └── synthia_mapped_to_cityscapes 47 | ├── city_list 48 | ├── gta5_list 49 | └── synthia_list 50 | ``` 51 | 52 | ### create symbolic link: 53 | ``` 54 | ln -s /data/lijj/pixmatch_output_61.5/ ./outputs 55 | ``` 56 | 57 | 58 | #### environment 59 | ``` 60 | requirement.txt 61 | ``` 62 | 63 | #### Initial Models 64 | * ImageNet pretrain: [Download](http://vllab.ucmerced.edu/ytsai/CVPR18/DeepLab_resnet_pretrained_init-f81d91e8.pth) 65 | * For GTA5-to-Cityscapes, we start with a model pretrained on the source (GTA5): [Download](https://drive.google.com/file/d/1lpMUoDKZHhoAtx-LRvgkNHdQ7Uq_I7u1/view?usp=sharing) 66 | * For SYNTHIA-to-Cityscapes, we start with a model pretrained on the source (SYNTHIA): [Download](https://drive.google.com/file/d/1Xuo0WAJosoJP37PAsvaPzczw6v64fVe3/view?usp=sharing) 67 | 68 | 69 | ### training 70 | ``` 71 | sh train.sh 72 | ``` 73 | 74 | ## Acknowledgments 75 | 76 | This code is based on the implementations of [**PixMatch: Unsupervised Domain Adaptation via Pixelwise Consistency Training**](https://github.com/lukemelas/pixmatch) and [**DACS: Domain Adaptation via Cross-domain Mixed Sampling**](https://github.com/vikolss/DACS). 77 | 78 | 79 | -------------------------------------------------------------------------------- /configs/gta5.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: debug 3 | root: /home/lijj/domain_seg/code/pixmatch-master/pixmatch-master 4 | data_leinao: /data/lijj 5 | pretrain_model_root: /data/lijj/pretrain_model/pixmatch/ 6 | train: True 7 | seed: 42 8 | wandb: False 9 | 10 | data: 11 | 12 | num_classes: 19 13 | 14 | source: 15 | dataset: 'gta5' 16 | kwargs: 17 | root: ${data_leinao}/GTA5 18 | list_path: ${root}/datasets/gta5_list 19 | base_size: [1280, 720] 20 | crop_size: [1280, 720] 21 | random_mirror: True 22 | random_crop: False 23 | resize: True 24 | gaussian_blur: True 25 | class_16: False 26 | 27 | target: 28 | dataset: 'cityscapes' 29 | kwargs: 30 | root: ${data_leinao}/Cityscapes 31 | list_path: ${root}/datasets/city_list 32 | base_size: [1280, 640] 33 | crop_size: [1280, 640] 34 | random_mirror: True 35 | random_crop: False 36 | resize: True 37 | gaussian_blur: True 38 | class_16: False 39 | class_13: False 40 | 41 | loader: 42 | kwargs: 43 | batch_size: 1 44 | num_workers: 4 45 | pin_memory: True 46 | target_loader: 47 | kwargs: 48 | batch_size: 2 49 | num_workers: 4 50 | pin_memory: True 51 | source_loader: 52 | kwargs: 53 | batch_size: 2 54 | num_workers: 4 55 | pin_memory: True 56 | 57 | source_val_iterations: 100 58 | 59 | model: 60 | backbone: deeplabv2_multi 61 | imagenet_pretrained: ${pretrain_model_root}/DeepLab_resnet_pretrained_init-f81d91e8.pth 62 | #checkpoint: "/data/lijj/pretrain_model/pixmatch/synthia_source.pth"# 63 | checkpoint: "${pretrain_model_root}/GTA5_source.pth"#"/data/lijj/pixmatch_output/2022-01-22/22-03-19/best.pth" 64 | resume_from_checkpoint: True 65 | resume_from_checkpoint_finetune: False 66 | 67 | opt: 68 | kind: "SGD" 69 | momentum: 0.9 70 | weight_decay: 5e-4 71 | lr: 2.5e-4 72 | iterations: 250000 73 | poly_power: 0.9 74 | 75 | # For auxiliary mode output 76 | aux: True 77 | lam_aux: 0.1 78 | 79 | # Exponential weighted average of model parameters 80 | ema_decay: 0.999 81 | 82 | # Perturbations 83 | pseudolabel_threshold: 0.0 84 | lam_aug: 0.0 85 | lam_fourier: 0.0 86 | lam_cutmix: 0.0 87 | NCE_weight: 0.01 88 | mix_weight: 0.1 89 | Tmax: 0.95 90 | 91 | # Fourier 92 | source_fourier: False 93 | fourier_beta: 0.01 94 | -------------------------------------------------------------------------------- /configs/synthia.yaml: -------------------------------------------------------------------------------- 1 | # @package _global_ 2 | defaults: 3 | - gta5 4 | - _self_ 5 | 6 | data: 7 | 8 | num_classes: 16 9 | 10 | source: 11 | dataset: 'synthia' 12 | kwargs: 13 | #root: ${root}/datasets/SYNTHIA/RAND_CITYSCAPES 14 | root: ${data_leinao}/synthia 15 | list_path: ${root}/datasets/synthia_list 16 | class_16: True 17 | 18 | target: 19 | kwargs: 20 | class_16: True 21 | 22 | model: 23 | backbone: deeplabv2_multi 24 | #checkpoint: null 25 | NCE_weight: 0.008 -------------------------------------------------------------------------------- /datasets/NTHU_list/Rio/List/test.txt: -------------------------------------------------------------------------------- 1 | pano_00002_2_180 2 | pano_00003_1_180 3 | pano_00004_1_180 4 | pano_00009_3_180 5 | pano_00010_3_0 6 | pano_00016_3_0 7 | pano_00019_0_180 8 | pano_00020_0_0 9 | pano_00021_5_180 10 | pano_00025_0_0 11 | pano_00031_1_180 12 | pano_00033_1_0 13 | pano_00045_6_180 14 | pano_00048_1_0 15 | pano_00048_3_180 16 | pano_00053_4_0 17 | pano_00056_3_180 18 | pano_00059_0_0 19 | pano_00061_4_0 20 | pano_00064_0_0 21 | pano_00068_0_0 22 | pano_00074_0_180 23 | pano_00083_0_180 24 | pano_00092_6_0 25 | pano_00094_2_180 26 | pano_00095_5_180 27 | pano_00096_0_180 28 | pano_00105_1_180 29 | pano_00109_2_0 30 | pano_00112_3_0 31 | pano_00116_0_0 32 | pano_00126_1_180 33 | pano_00128_0_0 34 | pano_00129_4_180 35 | pano_00139_1_180 36 | pano_00155_1_180 37 | pano_00160_0_180 38 | pano_00164_1_0 39 | pano_00166_1_0 40 | pano_00172_1_0 41 | pano_00176_1_180 42 | pano_00179_0_180 43 | pano_00183_0_180 44 | pano_00185_0_0 45 | pano_00188_1_180 46 | pano_00189_2_0 47 | pano_00197_3_0 48 | pano_00199_2_0 49 | pano_00202_1_0 50 | pano_00202_2_180 51 | pano_00204_0_180 52 | pano_00205_3_0 53 | pano_00205_3_180 54 | pano_00207_1_0 55 | pano_00207_1_180 56 | pano_00207_7_180 57 | pano_00217_2_0 58 | pano_00220_0_180 59 | pano_00221_3_0 60 | pano_00222_2_180 61 | pano_00226_0_0 62 | pano_00226_1_180 63 | pano_00232_2_180 64 | pano_00232_5_0 65 | pano_00235_5_180 66 | pano_00235_7_0 67 | pano_00236_3_180 68 | pano_00238_2_0 69 | pano_00238_5_180 70 | pano_00239_2_0 71 | pano_00358_5_180 72 | pano_00370_0_180 73 | pano_00373_0_180 74 | pano_00376_3_0 75 | pano_00379_1_180 76 | pano_00386_0_0 77 | pano_00396_1_180 78 | pano_00399_0_180 79 | pano_00401_1_180 80 | pano_00403_3_180 81 | pano_00427_0_0 82 | pano_00430_3_0 83 | pano_00443_0_180 84 | pano_00459_0_180 85 | pano_00460_6_0 86 | pano_00531_1_0 87 | pano_00541_0_180 88 | pano_00554_0_180 89 | pano_00558_1_0 90 | pano_00584_2_0 91 | pano_00587_1_0 92 | pano_00619_1_180 93 | pano_00631_0_0 94 | pano_03575_2_0 95 | pano_03584_0_0 96 | pano_03588_0_0 97 | pano_03602_0_0 98 | pano_03603_2_180 99 | pano_03608_1_0 100 | pano_05140_2_0 101 | -------------------------------------------------------------------------------- /datasets/NTHU_list/Rome/List/test.txt: -------------------------------------------------------------------------------- 1 | pano_00368_0_0 2 | pano_00368_0_180 3 | pano_00390_1_0 4 | pano_00412_0_0 5 | pano_00412_4_180 6 | pano_00431_1_0 7 | pano_00443_1_180 8 | pano_00474_0_0 9 | pano_00474_1_0 10 | pano_00494_0_0 11 | pano_00494_0_180 12 | pano_00498_0_0 13 | pano_00498_1_180 14 | pano_00500_0_180 15 | pano_00500_2_0 16 | pano_00507_2_180 17 | pano_00513_0_0 18 | pano_00513_1_180 19 | pano_00522_0_180 20 | pano_00537_0_180 21 | pano_00537_2_180 22 | pano_00544_1_180 23 | pano_00544_2_0 24 | pano_00545_0_0 25 | pano_00545_0_180 26 | pano_00561_0_0 27 | pano_00561_2_180 28 | pano_00562_0_0 29 | pano_00562_0_180 30 | pano_00563_0_0 31 | pano_00563_0_180 32 | pano_00564_0_0 33 | pano_00565_1_0 34 | pano_00565_3_180 35 | pano_00566_0_180 36 | pano_00566_2_0 37 | pano_00567_0_0 38 | pano_00567_2_180 39 | pano_00568_0_0 40 | pano_00568_2_180 41 | pano_00571_0_0 42 | pano_00571_2_180 43 | pano_00586_2_0 44 | pano_00586_2_180 45 | pano_00595_1_0 46 | pano_00606_1_180 47 | pano_00606_2_0 48 | pano_00608_1_0 49 | pano_00610_0_0 50 | pano_00610_2_180 51 | pano_00622_1_0 52 | pano_00651_0_0 53 | pano_00922_1_0 54 | pano_00922_1_180 55 | pano_00933_0_0 56 | pano_00937_0_0 57 | pano_00937_0_180 58 | pano_00959_0_0 59 | pano_00967_0_180 60 | pano_00967_4_0 61 | pano_00986_1_180 62 | pano_00996_0_180 63 | pano_00998_0_0 64 | pano_01001_0_0 65 | pano_01005_0_0 66 | pano_01006_4_180 67 | pano_01025_1_0 68 | pano_01027_2_180 69 | pano_01027_5_0 70 | pano_01034_0_0 71 | pano_01045_1_0 72 | pano_01052_5_0 73 | pano_01053_2_0 74 | pano_01057_0_180 75 | pano_01067_0_0 76 | pano_01113_1_0 77 | pano_01121_1_0 78 | pano_01125_2_180 79 | pano_01140_3_180 80 | pano_01195_0_180 81 | pano_01203_1_180 82 | pano_01205_0_0 83 | pano_01211_0_180 84 | pano_01223_1_0 85 | pano_01228_0_0 86 | pano_01228_3_180 87 | pano_01236_2_180 88 | pano_01260_1_0 89 | pano_01283_1_180 90 | pano_01295_0_0 91 | pano_01295_1_180 92 | pano_01311_2_0 93 | pano_01337_2_0 94 | pano_01361_1_0 95 | pano_01412_0_180 96 | pano_01444_1_0 97 | pano_01444_4_180 98 | pano_01470_1_180 99 | pano_01486_2_0 100 | pano_01507_1_0 101 | -------------------------------------------------------------------------------- /datasets/NTHU_list/Taipei/List/test.txt: -------------------------------------------------------------------------------- 1 | pano_00000_0_0 2 | pano_00001_0_0 3 | pano_00002_0_180 4 | pano_00010_0_0 5 | pano_00011_0_0 6 | pano_00012_0_0 7 | pano_00012_0_180 8 | pano_00024_0_0 9 | pano_00028_0_180 10 | pano_00035_0_0 11 | pano_00035_0_180 12 | pano_00037_0_180 13 | pano_00040_0_0 14 | pano_00043_0_0 15 | pano_00074_0_0 16 | pano_00108_0_0 17 | pano_00109_0_180 18 | pano_00110_0_0 19 | pano_00113_0_0 20 | pano_00114_0_0 21 | pano_00116_0_0 22 | pano_00142_0_0 23 | pano_00143_0_180 24 | pano_00173_0_0 25 | pano_00173_0_180 26 | pano_00174_0_180 27 | pano_00176_0_180 28 | pano_00183_0_180 29 | pano_00184_0_180 30 | pano_00203_0_180 31 | pano_00205_2_0 32 | pano_00212_0_180 33 | pano_00213_0_180 34 | pano_00215_2_0 35 | pano_00218_0_0 36 | pano_00221_0_180 37 | pano_00222_0_180 38 | pano_00223_0_0 39 | pano_00223_0_180 40 | pano_00224_0_180 41 | pano_00225_0_180 42 | pano_00229_0_0 43 | pano_00230_0_0 44 | pano_00230_0_180 45 | pano_00232_0_0 46 | pano_00233_0_0 47 | pano_00237_0_0 48 | pano_00238_0_0 49 | pano_00240_0_0 50 | pano_00245_0_0 51 | pano_00246_0_0 52 | pano_00247_0_180 53 | pano_00260_0_0 54 | pano_00260_0_180 55 | pano_00261_0_180 56 | pano_00267_0_0 57 | pano_00270_0_0 58 | pano_00271_0_0 59 | pano_00271_0_180 60 | pano_00272_0_0 61 | pano_00308_0_0 62 | pano_00310_0_0 63 | pano_00315_0_0 64 | pano_00315_0_180 65 | pano_00316_0_0 66 | pano_00317_0_0 67 | pano_00318_0_0 68 | pano_00323_0_0 69 | pano_00325_0_0 70 | pano_00325_0_180 71 | pano_00327_0_0 72 | pano_00327_0_180 73 | pano_00334_0_0 74 | pano_00334_0_180 75 | pano_00335_0_0 76 | pano_00337_0_180 77 | pano_00439_0_180 78 | pano_00450_0_0 79 | pano_00463_0_0 80 | pano_00466_0_180 81 | pano_00481_0_0 82 | pano_00487_0_0 83 | pano_00493_0_0 84 | pano_00493_0_180 85 | pano_00496_0_180 86 | pano_00498_0_0 87 | pano_00499_0_0 88 | pano_00500_0_0 89 | pano_00504_0_0 90 | pano_00506_0_0 91 | pano_00509_0_0 92 | pano_00509_0_180 93 | pano_00516_0_180 94 | pano_00525_0_180 95 | pano_01135_0_0 96 | pano_01718_0_0 97 | pano_01726_0_0 98 | pano_01726_0_180 99 | pano_01727_0_0 100 | pano_01728_0_180 101 | -------------------------------------------------------------------------------- /datasets/NTHU_list/Tokyo/List/test.txt: -------------------------------------------------------------------------------- 1 | pano_00002_2_0 2 | pano_00022_2_0 3 | pano_00027_0_0 4 | pano_00037_0_0 5 | pano_00042_1_180 6 | pano_00062_4_0 7 | pano_00068_1_180 8 | pano_00076_3_0 9 | pano_00087_0_0 10 | pano_00093_3_180 11 | pano_00111_0_180 12 | pano_00111_4_180 13 | pano_00117_3_180 14 | pano_00176_2_0 15 | pano_00188_1_0 16 | pano_00204_1_0 17 | pano_00236_2_0 18 | pano_00270_2_0 19 | pano_00272_0_180 20 | pano_00320_0_180 21 | pano_00328_2_180 22 | pano_00335_3_180 23 | pano_00340_2_0 24 | pano_00374_3_0 25 | pano_00391_4_0 26 | pano_00405_6_0 27 | pano_00566_3_0 28 | pano_00574_0_180 29 | pano_00585_2_180 30 | pano_00588_0_180 31 | pano_00590_1_0 32 | pano_00595_0_180 33 | pano_00601_1_180 34 | pano_00607_3_180 35 | pano_00623_1_0 36 | pano_00635_3_180 37 | pano_00645_3_0 38 | pano_00647_1_180 39 | pano_00650_3_180 40 | pano_00654_3_180 41 | pano_00665_3_0 42 | pano_00682_2_180 43 | pano_00683_0_180 44 | pano_00695_1_180 45 | pano_00709_1_0 46 | pano_00720_4_0 47 | pano_00723_2_180 48 | pano_00749_0_180 49 | pano_00750_6_180 50 | pano_00760_1_180 51 | pano_00760_4_0 52 | pano_00780_2_180 53 | pano_00792_1_180 54 | pano_00810_2_180 55 | pano_00821_1_0 56 | pano_00826_0_180 57 | pano_00870_3_0 58 | pano_00883_1_0 59 | pano_00894_1_180 60 | pano_00914_1_0 61 | pano_00915_2_180 62 | pano_00926_1_180 63 | pano_00940_2_0 64 | pano_00997_1_0 65 | pano_01022_3_0 66 | pano_01033_1_0 67 | pano_01048_2_0 68 | pano_01081_0_0 69 | pano_01098_3_180 70 | pano_01133_3_0 71 | pano_01143_1_0 72 | pano_01206_0_0 73 | pano_01208_3_180 74 | pano_01219_2_0 75 | pano_01222_2_0 76 | pano_01347_1_180 77 | pano_01349_1_0 78 | pano_01352_0_0 79 | pano_01360_0_180 80 | pano_01364_2_0 81 | pano_01375_0_180 82 | pano_01378_1_0 83 | pano_01379_0_180 84 | pano_01390_0_0 85 | pano_01404_3_0 86 | pano_01405_2_0 87 | pano_01410_0_0 88 | pano_01413_1_0 89 | pano_01418_4_180 90 | pano_01428_1_0 91 | pano_01433_1_180 92 | pano_01437_2_180 93 | pano_01446_2_0 94 | pano_01516_1_0 95 | pano_01520_1_0 96 | pano_01521_0_0 97 | pano_01528_0_180 98 | pano_01535_1_0 99 | pano_01536_3_0 100 | pano_01548_0_180 101 | -------------------------------------------------------------------------------- /datasets/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | path = os.path.dirname(os.path.abspath(__file__)) 5 | 6 | for py in [f[:-3] for f in os.listdir(path) if f.endswith('.py') and f != '__init__.py']: 7 | mod = __import__('.'.join([__name__, py]), fromlist=[py]) 8 | classes = [getattr(mod, x) 9 | for x in dir(mod) if isinstance(getattr(mod, x), type)] 10 | for cls in classes: 11 | setattr(sys.modules[__name__], cls.__name__, cls) 12 | -------------------------------------------------------------------------------- /datasets/city_dataset_test_ours.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import random 3 | from collections.abc import Iterable 4 | from PIL import Image, ImageOps, ImageFilter, ImageFile 5 | import numpy as np 6 | import os 7 | import torch 8 | import torch.utils.data as data 9 | 10 | 11 | ImageFile.LOAD_TRUNCATED_IMAGES = True 12 | 13 | IMG_MEAN = np.array((104.00698793, 116.66876762, 14 | 122.67891434), dtype=np.float32) 15 | NUM_CLASSES = 19 16 | 17 | # For visualization 18 | label_colours = list(map(tuple, [ 19 | [128, 64, 128], 20 | [244, 35, 232], 21 | [70, 70, 70], 22 | [102, 102, 156], 23 | [190, 153, 153], 24 | [153, 153, 153], 25 | [250, 170, 30], 26 | [220, 220, 0], 27 | [107, 142, 35], 28 | [152, 251, 152], 29 | [0, 130, 180], 30 | [220, 20, 60], 31 | [255, 0, 0], 32 | [0, 0, 142], 33 | [0, 0, 70], 34 | [0, 60, 100], 35 | [0, 80, 100], 36 | [0, 0, 230], 37 | [119, 11, 32], 38 | [0, 0, 0], # the color of ignored label 39 | ])) 40 | 41 | # Labels 42 | ignore_label = -1 43 | cityscapes_id_to_trainid = { 44 | -1: ignore_label, 45 | 0: ignore_label, 46 | 1: ignore_label, 47 | 2: ignore_label, 48 | 3: ignore_label, 49 | 4: ignore_label, 50 | 5: ignore_label, 51 | 6: ignore_label, 52 | 7: 0, 53 | 8: 1, 54 | 9: ignore_label, 55 | 10: ignore_label, 56 | 11: 2, 57 | 12: 3, 58 | 13: 4, 59 | 14: ignore_label, 60 | 15: ignore_label, 61 | 16: ignore_label, 62 | 17: 5, 63 | 18: ignore_label, 64 | 19: 6, 65 | 20: 7, 66 | 21: 8, 67 | 22: 9, 68 | 23: 10, 69 | 24: 11, 70 | 25: 12, 71 | 26: 13, 72 | 27: 14, 73 | 28: 15, 74 | 29: ignore_label, 75 | 30: ignore_label, 76 | 31: 16, 77 | 32: 17, 78 | 33: 18 79 | } 80 | 81 | # Names 82 | name_classes = [ 83 | 'road', 84 | 'sidewalk', 85 | 'building', 86 | 'wall', 87 | 'fence', 88 | 'pole', 89 | 'trafflight', 90 | 'traffsign', 91 | 'vegetation', 92 | 'terrain', 93 | 'sky', 94 | 'person', 95 | 'rider', 96 | 'car', 97 | 'truck', 98 | 'bus', 99 | 'train', 100 | 'motorcycle', 101 | 'bicycle', 102 | 'unlabeled' 103 | ] 104 | 105 | 106 | def to_tuple(x): 107 | return x if isinstance(x, Iterable) else (x, x) 108 | 109 | 110 | class City_Dataset(data.Dataset): 111 | def __init__( 112 | self, 113 | root, 114 | list_path, 115 | split='train', 116 | base_size=769, 117 | crop_size=769, 118 | training=True, 119 | random_mirror=False, 120 | random_crop=False, 121 | resize=False, 122 | gaussian_blur=False, 123 | class_16=False, 124 | class_13=False, 125 | ): 126 | self.data_path = root 127 | self.list_path = list_path 128 | self.split = split 129 | self.base_size = to_tuple(base_size) 130 | self.crop_size = to_tuple(crop_size) 131 | self.training = training 132 | 133 | # Augmentations 134 | self.random_mirror = random_mirror 135 | self.random_crop = random_crop 136 | self.resize = resize 137 | self.gaussian_blur = gaussian_blur 138 | 139 | # Files 140 | item_list_filepath = os.path.join(self.list_path, self.split + ".txt") 141 | #print(split) 142 | #exit() 143 | if not os.path.exists(item_list_filepath): 144 | raise Warning("split must be train/val/trainval") 145 | self.image_filepath = os.path.join(self.data_path, "leftImg8bit") 146 | if split=='train': 147 | for i in range(100): 148 | print(i) 149 | self.test_ours=False 150 | #print(self.test_ours) 151 | #exit() 152 | if split=='val': 153 | test_ours=True 154 | self.test_ours=test_ours 155 | if self.test_ours: 156 | self.image_filepath="/home/lijj/domain_seg/code/pixmatch-master/pixmatch-master/test_image/" 157 | for root, dirs, files in os.walk(self.image_filepath): 158 | #print(root) 159 | #print(dirs) 160 | self.files=files 161 | #exit() 162 | self.gt_filepath = os.path.join(self.data_path, "gtFine") 163 | self.items = [id.strip() for id in open(item_list_filepath)] 164 | self.id_to_trainid = cityscapes_id_to_trainid 165 | 166 | # In SYNTHIA-to-Cityscapes case, only consider 16 shared classes 167 | self.class_16 = class_16 168 | synthia_set_16 = [0, 1, 2, 3, 4, 5, 6, 169 | 7, 8, 10, 11, 12, 13, 15, 17, 18] 170 | self.trainid_to_16id = {id: i for i, id in enumerate(synthia_set_16)} 171 | 172 | # In Cityscapes-to-NTHU case, only consider 13 shared classes 173 | self.class_13 = class_13 174 | synthia_set_13 = [0, 1, 2, 6, 7, 8, 10, 11, 12, 13, 15, 17, 18] 175 | self.trainid_to_13id = {id: i for i, id in enumerate(synthia_set_13)} 176 | 177 | print("{} num images in Cityscapes {} set have been loaded.".format( 178 | len(self.items), self.split)) 179 | 180 | def id2trainId(self, label, reverse=False, ignore_label=-1): 181 | label_copy = ignore_label * np.ones(label.shape, dtype=np.float32) 182 | for k, v in self.id_to_trainid.items(): 183 | label_copy[label == k] = v 184 | if self.class_16: 185 | label_copy_16 = ignore_label * \ 186 | np.ones(label.shape, dtype=np.float32) 187 | for k, v in self.trainid_to_16id.items(): 188 | label_copy_16[label_copy == k] = v 189 | label_copy = label_copy_16 190 | if self.class_13: 191 | label_copy_13 = ignore_label * \ 192 | np.ones(label.shape, dtype=np.float32) 193 | for k, v in self.trainid_to_13id.items(): 194 | label_copy_13[label_copy == k] = v 195 | label_copy = label_copy_13 196 | return label_copy 197 | 198 | def __getitem__(self, item): 199 | id = self.items[item] 200 | filename = id.split("train_")[-1].split("val_")[-1].split("test_")[-1] 201 | image_filepath = os.path.join( 202 | self.image_filepath, id.split("_")[0], id.split("_")[1]) 203 | image_filename = filename + "_leftImg8bit.png" 204 | if self.test_ours: 205 | image_filename=self.files[item] 206 | image_path = os.path.join(self.image_filepath, image_filename) 207 | else: 208 | image_path = os.path.join(image_filepath, image_filename) 209 | image = Image.open(image_path).convert("RGB") 210 | 211 | gt_filepath = os.path.join( 212 | self.gt_filepath, id.split("_")[0], id.split("_")[1]) 213 | gt_filename = filename + "_gtFine_labelIds.png" 214 | gt_image_path = os.path.join(gt_filepath, gt_filename) 215 | gt_image = Image.open(gt_image_path) 216 | 217 | if (self.split == "train" or self.split == "trainval") and self.training: 218 | image, gt_image = self._train_sync_transform(image, gt_image) 219 | return image, gt_image, item 220 | else: 221 | image, gt_image = self._val_sync_transform(image, gt_image) 222 | return image, gt_image, image_filename 223 | 224 | def _train_sync_transform(self, img, mask): 225 | ''' 226 | :param image: PIL input image 227 | :param gt_image: PIL input gt_image 228 | :return: 229 | ''' 230 | if self.random_mirror: 231 | # random mirror 232 | if random.random() < 0.5: 233 | img = img.transpose(Image.FLIP_LEFT_RIGHT) 234 | if mask: 235 | mask = mask.transpose(Image.FLIP_LEFT_RIGHT) 236 | crop_w, crop_h = self.crop_size 237 | 238 | if self.random_crop: 239 | # random scale 240 | base_w, base_h = self.base_size 241 | w, h = img.size 242 | assert w >= h 243 | if (base_w / w) > (base_h / h): 244 | base_size = base_w 245 | short_size = random.randint( 246 | int(base_size * 0.5), int(base_size * 2.0)) 247 | ow = short_size 248 | oh = int(1.0 * h * ow / w) 249 | else: 250 | base_size = base_h 251 | short_size = random.randint( 252 | int(base_size * 0.5), int(base_size * 2.0)) 253 | oh = short_size 254 | ow = int(1.0 * w * oh / h) 255 | 256 | img = img.resize((ow, oh), Image.BICUBIC) 257 | if mask: 258 | mask = mask.resize((ow, oh), Image.NEAREST) 259 | # pad crop 260 | if ow < crop_w or oh < crop_h: 261 | padh = crop_h - oh if oh < crop_h else 0 262 | padw = crop_w - ow if ow < crop_w else 0 263 | img = ImageOps.expand(img, border=(0, 0, padw, padh), fill=0) 264 | if mask: 265 | mask = ImageOps.expand( 266 | mask, border=(0, 0, padw, padh), fill=0) 267 | # random crop crop_size 268 | w, h = img.size 269 | x1 = random.randint(0, w - crop_w) 270 | y1 = random.randint(0, h - crop_h) 271 | img = img.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 272 | if mask: 273 | mask = mask.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 274 | elif self.resize: 275 | img = img.resize(self.crop_size, Image.BICUBIC) 276 | if mask: 277 | mask = mask.resize(self.crop_size, Image.NEAREST) 278 | 279 | if self.gaussian_blur: 280 | # gaussian blur as in PSP 281 | if random.random() < 0.5: 282 | img = img.filter(ImageFilter.GaussianBlur( 283 | radius=random.random())) 284 | # final transform 285 | if mask: 286 | img, mask = self._img_transform(img), self._mask_transform(mask) 287 | return img, mask 288 | else: 289 | img = self._img_transform(img) 290 | return img 291 | 292 | def _val_sync_transform(self, img, mask): 293 | if self.random_crop: 294 | crop_w, crop_h = self.crop_size 295 | w, h = img.size 296 | if crop_w / w < crop_h / h: 297 | oh = crop_h 298 | ow = int(1.0 * w * oh / h) 299 | else: 300 | ow = crop_w 301 | oh = int(1.0 * h * ow / w) 302 | img = img.resize((ow, oh), Image.BICUBIC) 303 | mask = mask.resize((ow, oh), Image.NEAREST) 304 | # center crop 305 | w, h = img.size 306 | x1 = int(round((w - crop_w) / 2.)) 307 | y1 = int(round((h - crop_h) / 2.)) 308 | img = img.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 309 | mask = mask.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 310 | elif self.resize: 311 | img = img.resize(self.crop_size, Image.BICUBIC) 312 | mask = mask.resize(self.crop_size, Image.NEAREST) 313 | 314 | # final transform 315 | img, mask = self._img_transform(img), self._mask_transform(mask) 316 | return img, mask 317 | 318 | def _img_transform(self, image): 319 | # if self.args.numpy_transform: 320 | image = np.asarray(image, np.float32) 321 | image = image[:, :, ::-1] # change to BGR 322 | image -= IMG_MEAN 323 | image = image.transpose((2, 0, 1)).copy() # (C x H x W) 324 | new_image = torch.from_numpy(image) 325 | # else: 326 | # image_transforms = ttransforms.Compose([ 327 | # ttransforms.ToTensor(), 328 | # ttransforms.Normalize([.485, .456, .406], [.229, .224, .225]), 329 | # ]) 330 | # new_image = image_transforms(image) 331 | return new_image 332 | 333 | def _mask_transform(self, gt_image): 334 | target = np.asarray(gt_image, np.float32) 335 | target = self.id2trainId(target).copy() 336 | target = torch.from_numpy(target) 337 | 338 | return target 339 | 340 | def __len__(self): 341 | 342 | return len(self.items) 343 | 344 | 345 | def flip(x, dim): 346 | dim = x.dim() + dim if dim < 0 else dim 347 | inds = tuple(slice(None, None) if i != dim 348 | else x.new(torch.arange(x.size(i) - 1, -1, -1).tolist()).long() 349 | for i in range(x.dim())) 350 | return x[inds] 351 | 352 | 353 | def inv_preprocess(imgs, num_images=1, img_mean=IMG_MEAN, numpy_transform=False): 354 | """Inverse preprocessing of the batch of images. 355 | 356 | Args: 357 | imgs: batch of input images. 358 | num_images: number of images to apply the inverse transformations on. 359 | img_mean: vector of mean colour values. 360 | numpy_transform: whether change RGB to BGR during img_transform. 361 | 362 | Returns: 363 | The batch of the size num_images with the same spatial dimensions as the input. 364 | """ 365 | if numpy_transform: 366 | imgs = flip(imgs, 1) 367 | 368 | def norm_ip(img, min, max): 369 | img.clamp_(min=min, max=max) 370 | img.add_(-min).div_(max - min + 1e-5) 371 | norm_ip(imgs, float(imgs.min()), float(imgs.max())) 372 | return imgs 373 | 374 | 375 | def decode_labels(mask, num_images=1, num_classes=NUM_CLASSES): 376 | """Decode batch of segmentation masks. 377 | 378 | Args: 379 | mask: result of inference after taking argmax. 380 | num_images: number of images to decode from the batch. 381 | num_classes: number of classes to predict. 382 | 383 | Returns: 384 | A batch with num_images RGB images of the same size as the input. 385 | """ 386 | if isinstance(mask, torch.Tensor): 387 | mask = mask.data.cpu().numpy() 388 | n, h, w = mask.shape 389 | if n < num_images: 390 | num_images = n 391 | outputs = np.zeros((num_images, h, w, 3), dtype=np.uint8) 392 | for i in range(num_images): 393 | img = Image.new('RGB', (len(mask[i, 0]), len(mask[i]))) 394 | pixels = img.load() 395 | for j_, j in enumerate(mask[i, :, :]): 396 | for k_, k in enumerate(j): 397 | if k < num_classes: 398 | pixels[k_, j_] = label_colours[k] 399 | outputs[i] = np.array(img) 400 | return torch.from_numpy(outputs.transpose([0, 3, 1, 2]).astype('float32')).div_(255.0) 401 | 402 | 403 | def inspect_decode_labels(pred, num_images=1, num_classes=NUM_CLASSES, 404 | inspect_split=[0.9, 0.8, 0.7, 0.5, 0.0], inspect_ratio=[1.0, 0.8, 0.6, 0.3]): 405 | """Decode batch of segmentation masks accroding to the prediction probability. 406 | 407 | Args: 408 | pred: result of inference. 409 | num_images: number of images to decode from the batch. 410 | num_classes: number of classes to predict (including background). 411 | inspect_split: probability between different split has different brightness. 412 | 413 | Returns: 414 | A batch with num_images RGB images of the same size as the input. 415 | """ 416 | if isinstance(pred, torch.Tensor): 417 | pred = pred.data.cpu().numpy() 418 | n, c, h, w = pred.shape 419 | pred = pred.transpose([0, 2, 3, 1]) 420 | if n < num_images: 421 | num_images = n 422 | outputs = np.zeros((num_images, h, w, 3), dtype=np.uint8) 423 | for i in range(num_images): 424 | img = Image.new('RGB', (w, h)) 425 | pixels = img.load() 426 | for j_, j in enumerate(pred[i, :, :, :]): 427 | for k_, k in enumerate(j): 428 | assert k.shape[0] == num_classes 429 | k_value = np.max(softmax(k)) 430 | k_class = np.argmax(k) 431 | for it, iv in enumerate(inspect_split): 432 | if k_value > iv: 433 | break 434 | if iv > 0: 435 | pixels[k_, j_] = tuple( 436 | map(lambda x: int(inspect_ratio[it] * x), label_colours[k_class])) 437 | outputs[i] = np.array(img) 438 | return torch.from_numpy(outputs.transpose([0, 3, 1, 2]).astype('float32')).div_(255.0) 439 | 440 | 441 | class DemoVideo_City_Dataset(City_Dataset): 442 | def __init__(self, *args, **kwargs): 443 | super().__init__(*args, **kwargs) 444 | assert self.split == 'demoVideo' 445 | 446 | def __getitem__(self, item): 447 | id = self.items[item] 448 | folder = '_'.join(id.split('_')[:2]) 449 | filename = '_'.join(id.split('_')[2:]) 450 | image_filename = folder + '_' + filename + "_leftImg8bit.png" 451 | image_path = os.path.join(self.image_filepath, 'demoVideo', folder, image_filename) 452 | image = Image.open(image_path).convert("RGB") 453 | image, _ = self._val_sync_transform(image, image) 454 | return image, image_path, item 455 | -------------------------------------------------------------------------------- /datasets/city_list/test.txt: -------------------------------------------------------------------------------- 1 | test_berlin_000000_000019 2 | test_berlin_000001_000019 3 | test_berlin_000002_000019 4 | test_berlin_000003_000019 5 | test_berlin_000004_000019 6 | test_berlin_000005_000019 7 | test_berlin_000006_000019 8 | test_berlin_000007_000019 9 | test_berlin_000008_000019 10 | test_berlin_000009_000019 11 | test_berlin_000010_000019 12 | test_berlin_000011_000019 13 | test_berlin_000012_000019 14 | test_berlin_000013_000019 15 | test_berlin_000014_000019 16 | test_berlin_000015_000019 17 | test_berlin_000016_000019 18 | test_berlin_000017_000019 19 | test_berlin_000018_000019 20 | test_berlin_000019_000019 21 | test_berlin_000020_000019 22 | test_berlin_000021_000019 23 | test_berlin_000022_000019 24 | test_berlin_000023_000019 25 | test_berlin_000024_000019 26 | test_berlin_000025_000019 27 | test_berlin_000026_000019 28 | test_berlin_000027_000019 29 | test_berlin_000028_000019 30 | test_berlin_000029_000019 31 | test_berlin_000030_000019 32 | test_berlin_000031_000019 33 | test_berlin_000032_000019 34 | test_berlin_000033_000019 35 | test_berlin_000034_000019 36 | test_berlin_000035_000019 37 | test_berlin_000036_000019 38 | test_berlin_000037_000019 39 | test_berlin_000038_000019 40 | test_berlin_000039_000019 41 | test_berlin_000040_000019 42 | test_berlin_000041_000019 43 | test_berlin_000042_000019 44 | test_berlin_000043_000019 45 | test_berlin_000044_000019 46 | test_berlin_000045_000019 47 | test_berlin_000046_000019 48 | test_berlin_000047_000019 49 | test_berlin_000048_000019 50 | test_berlin_000049_000019 51 | test_berlin_000050_000019 52 | test_berlin_000051_000019 53 | test_berlin_000052_000019 54 | test_berlin_000053_000019 55 | test_berlin_000054_000019 56 | test_berlin_000055_000019 57 | test_berlin_000056_000019 58 | test_berlin_000057_000019 59 | test_berlin_000058_000019 60 | test_berlin_000059_000019 61 | test_berlin_000060_000019 62 | test_berlin_000061_000019 63 | test_berlin_000062_000019 64 | test_berlin_000063_000019 65 | test_berlin_000064_000019 66 | test_berlin_000065_000019 67 | test_berlin_000066_000019 68 | test_berlin_000067_000019 69 | test_berlin_000068_000019 70 | test_berlin_000069_000019 71 | test_berlin_000070_000019 72 | test_berlin_000071_000019 73 | test_berlin_000072_000019 74 | test_berlin_000073_000019 75 | test_berlin_000074_000019 76 | test_berlin_000075_000019 77 | test_berlin_000076_000019 78 | test_berlin_000077_000019 79 | test_berlin_000078_000019 80 | test_berlin_000079_000019 81 | test_berlin_000080_000019 82 | test_berlin_000081_000019 83 | test_berlin_000082_000019 84 | test_berlin_000083_000019 85 | test_berlin_000084_000019 86 | test_berlin_000085_000019 87 | test_berlin_000086_000019 88 | test_berlin_000087_000019 89 | test_berlin_000088_000019 90 | test_berlin_000089_000019 91 | test_berlin_000090_000019 92 | test_berlin_000091_000019 93 | test_berlin_000092_000019 94 | test_berlin_000093_000019 95 | test_berlin_000094_000019 96 | test_berlin_000095_000019 97 | test_berlin_000096_000019 98 | test_berlin_000097_000019 99 | test_berlin_000098_000019 100 | test_berlin_000099_000019 101 | test_berlin_000100_000019 102 | test_berlin_000101_000019 103 | test_berlin_000102_000019 104 | test_berlin_000103_000019 105 | test_berlin_000104_000019 106 | test_berlin_000105_000019 107 | test_berlin_000106_000019 108 | test_berlin_000107_000019 109 | test_berlin_000108_000019 110 | test_berlin_000109_000019 111 | test_berlin_000110_000019 112 | test_berlin_000111_000019 113 | test_berlin_000112_000019 114 | test_berlin_000113_000019 115 | test_berlin_000114_000019 116 | test_berlin_000115_000019 117 | test_berlin_000116_000019 118 | test_berlin_000117_000019 119 | test_berlin_000118_000019 120 | test_berlin_000119_000019 121 | test_berlin_000120_000019 122 | test_berlin_000121_000019 123 | test_berlin_000122_000019 124 | test_berlin_000123_000019 125 | test_berlin_000124_000019 126 | test_berlin_000125_000019 127 | test_berlin_000126_000019 128 | test_berlin_000127_000019 129 | test_berlin_000128_000019 130 | test_berlin_000129_000019 131 | test_berlin_000130_000019 132 | test_berlin_000131_000019 133 | test_berlin_000132_000019 134 | test_berlin_000133_000019 135 | test_berlin_000134_000019 136 | test_berlin_000135_000019 137 | test_berlin_000136_000019 138 | test_berlin_000137_000019 139 | test_berlin_000138_000019 140 | test_berlin_000139_000019 141 | test_berlin_000140_000019 142 | test_berlin_000141_000019 143 | test_berlin_000142_000019 144 | test_berlin_000143_000019 145 | test_berlin_000144_000019 146 | test_berlin_000145_000019 147 | test_berlin_000146_000019 148 | test_berlin_000147_000019 149 | test_berlin_000148_000019 150 | test_berlin_000149_000019 151 | test_berlin_000150_000019 152 | test_berlin_000151_000019 153 | test_berlin_000152_000019 154 | test_berlin_000153_000019 155 | test_berlin_000154_000019 156 | test_berlin_000155_000019 157 | test_berlin_000156_000019 158 | test_berlin_000157_000019 159 | test_berlin_000158_000019 160 | test_berlin_000159_000019 161 | test_berlin_000160_000019 162 | test_berlin_000161_000019 163 | test_berlin_000162_000019 164 | test_berlin_000163_000019 165 | test_berlin_000164_000019 166 | test_berlin_000165_000019 167 | test_berlin_000166_000019 168 | test_berlin_000167_000019 169 | test_berlin_000168_000019 170 | test_berlin_000169_000019 171 | test_berlin_000170_000019 172 | test_berlin_000171_000019 173 | test_berlin_000172_000019 174 | test_berlin_000173_000019 175 | test_berlin_000174_000019 176 | test_berlin_000175_000019 177 | test_berlin_000176_000019 178 | test_berlin_000177_000019 179 | test_berlin_000178_000019 180 | test_berlin_000179_000019 181 | test_berlin_000180_000019 182 | test_berlin_000181_000019 183 | test_berlin_000182_000019 184 | test_berlin_000183_000019 185 | test_berlin_000184_000019 186 | test_berlin_000185_000019 187 | test_berlin_000186_000019 188 | test_berlin_000187_000019 189 | test_berlin_000188_000019 190 | test_berlin_000189_000019 191 | test_berlin_000190_000019 192 | test_berlin_000191_000019 193 | test_berlin_000192_000019 194 | test_berlin_000193_000019 195 | test_berlin_000194_000019 196 | test_berlin_000195_000019 197 | test_berlin_000196_000019 198 | test_berlin_000197_000019 199 | test_berlin_000198_000019 200 | test_berlin_000199_000019 201 | test_berlin_000200_000019 202 | test_berlin_000201_000019 203 | test_berlin_000202_000019 204 | test_berlin_000203_000019 205 | test_berlin_000204_000019 206 | test_berlin_000205_000019 207 | test_berlin_000206_000019 208 | test_berlin_000207_000019 209 | test_berlin_000208_000019 210 | test_berlin_000209_000019 211 | test_berlin_000210_000019 212 | test_berlin_000211_000019 213 | test_berlin_000212_000019 214 | test_berlin_000213_000019 215 | test_berlin_000214_000019 216 | test_berlin_000215_000019 217 | test_berlin_000216_000019 218 | test_berlin_000217_000019 219 | test_berlin_000218_000019 220 | test_berlin_000219_000019 221 | test_berlin_000220_000019 222 | test_berlin_000221_000019 223 | test_berlin_000222_000019 224 | test_berlin_000223_000019 225 | test_berlin_000224_000019 226 | test_berlin_000225_000019 227 | test_berlin_000226_000019 228 | test_berlin_000227_000019 229 | test_berlin_000228_000019 230 | test_berlin_000229_000019 231 | test_berlin_000230_000019 232 | test_berlin_000231_000019 233 | test_berlin_000232_000019 234 | test_berlin_000233_000019 235 | test_berlin_000234_000019 236 | test_berlin_000235_000019 237 | test_berlin_000236_000019 238 | test_berlin_000237_000019 239 | test_berlin_000238_000019 240 | test_berlin_000239_000019 241 | test_berlin_000240_000019 242 | test_berlin_000241_000019 243 | test_berlin_000242_000019 244 | test_berlin_000243_000019 245 | test_berlin_000244_000019 246 | test_berlin_000245_000019 247 | test_berlin_000246_000019 248 | test_berlin_000247_000019 249 | test_berlin_000248_000019 250 | test_berlin_000249_000019 251 | test_berlin_000250_000019 252 | test_berlin_000251_000019 253 | test_berlin_000252_000019 254 | test_berlin_000253_000019 255 | test_berlin_000254_000019 256 | test_berlin_000255_000019 257 | test_berlin_000256_000019 258 | test_berlin_000257_000019 259 | test_berlin_000258_000019 260 | test_berlin_000259_000019 261 | test_berlin_000260_000019 262 | test_berlin_000261_000019 263 | test_berlin_000262_000019 264 | test_berlin_000263_000019 265 | test_berlin_000264_000019 266 | test_berlin_000265_000019 267 | test_berlin_000266_000019 268 | test_berlin_000267_000019 269 | test_berlin_000268_000019 270 | test_berlin_000269_000019 271 | test_berlin_000270_000019 272 | test_berlin_000271_000019 273 | test_berlin_000272_000019 274 | test_berlin_000273_000019 275 | test_berlin_000274_000019 276 | test_berlin_000275_000019 277 | test_berlin_000276_000019 278 | test_berlin_000277_000019 279 | test_berlin_000278_000019 280 | test_berlin_000279_000019 281 | test_berlin_000280_000019 282 | test_berlin_000281_000019 283 | test_berlin_000282_000019 284 | test_berlin_000283_000019 285 | test_berlin_000284_000019 286 | test_berlin_000285_000019 287 | test_berlin_000286_000019 288 | test_berlin_000287_000019 289 | test_berlin_000288_000019 290 | test_berlin_000289_000019 291 | test_berlin_000290_000019 292 | test_berlin_000291_000019 293 | test_berlin_000292_000019 294 | test_berlin_000293_000019 295 | test_berlin_000294_000019 296 | test_berlin_000295_000019 297 | test_berlin_000296_000019 298 | test_berlin_000297_000019 299 | test_berlin_000298_000019 300 | test_berlin_000299_000019 301 | test_berlin_000300_000019 302 | test_berlin_000301_000019 303 | test_berlin_000302_000019 304 | test_berlin_000303_000019 305 | test_berlin_000304_000019 306 | test_berlin_000305_000019 307 | test_berlin_000306_000019 308 | test_berlin_000307_000019 309 | test_berlin_000308_000019 310 | test_berlin_000309_000019 311 | test_berlin_000310_000019 312 | test_berlin_000311_000019 313 | test_berlin_000312_000019 314 | test_berlin_000313_000019 315 | test_berlin_000314_000019 316 | test_berlin_000315_000019 317 | test_berlin_000316_000019 318 | test_berlin_000317_000019 319 | test_berlin_000318_000019 320 | test_berlin_000319_000019 321 | test_berlin_000320_000019 322 | test_berlin_000321_000019 323 | test_berlin_000322_000019 324 | test_berlin_000323_000019 325 | test_berlin_000324_000019 326 | test_berlin_000325_000019 327 | test_berlin_000326_000019 328 | test_berlin_000327_000019 329 | test_berlin_000328_000019 330 | test_berlin_000329_000019 331 | test_berlin_000330_000019 332 | test_berlin_000331_000019 333 | test_berlin_000332_000019 334 | test_berlin_000333_000019 335 | test_berlin_000334_000019 336 | test_berlin_000335_000019 337 | test_berlin_000336_000019 338 | test_berlin_000337_000019 339 | test_berlin_000338_000019 340 | test_berlin_000339_000019 341 | test_berlin_000340_000019 342 | test_berlin_000341_000019 343 | test_berlin_000342_000019 344 | test_berlin_000343_000019 345 | test_berlin_000344_000019 346 | test_berlin_000345_000019 347 | test_berlin_000346_000019 348 | test_berlin_000347_000019 349 | test_berlin_000348_000019 350 | test_berlin_000349_000019 351 | test_berlin_000350_000019 352 | test_berlin_000351_000019 353 | test_berlin_000352_000019 354 | test_berlin_000353_000019 355 | test_berlin_000354_000019 356 | test_berlin_000355_000019 357 | test_berlin_000356_000019 358 | test_berlin_000357_000019 359 | test_berlin_000358_000019 360 | test_berlin_000359_000019 361 | test_berlin_000360_000019 362 | test_berlin_000361_000019 363 | test_berlin_000362_000019 364 | test_berlin_000363_000019 365 | test_berlin_000364_000019 366 | test_berlin_000365_000019 367 | test_berlin_000366_000019 368 | test_berlin_000367_000019 369 | test_berlin_000368_000019 370 | test_berlin_000369_000019 371 | test_berlin_000370_000019 372 | test_berlin_000371_000019 373 | test_berlin_000372_000019 374 | test_berlin_000373_000019 375 | test_berlin_000374_000019 376 | test_berlin_000375_000019 377 | test_berlin_000376_000019 378 | test_berlin_000377_000019 379 | test_berlin_000378_000019 380 | test_berlin_000379_000019 381 | test_berlin_000380_000019 382 | test_berlin_000381_000019 383 | test_berlin_000382_000019 384 | test_berlin_000383_000019 385 | test_berlin_000384_000019 386 | test_berlin_000385_000019 387 | test_berlin_000386_000019 388 | test_berlin_000387_000019 389 | test_berlin_000388_000019 390 | test_berlin_000389_000019 391 | test_berlin_000390_000019 392 | test_berlin_000391_000019 393 | test_berlin_000392_000019 394 | test_berlin_000393_000019 395 | test_berlin_000394_000019 396 | test_berlin_000395_000019 397 | test_berlin_000396_000019 398 | test_berlin_000397_000019 399 | test_berlin_000398_000019 400 | test_berlin_000399_000019 401 | test_berlin_000400_000019 402 | test_berlin_000401_000019 403 | test_berlin_000402_000019 404 | test_berlin_000403_000019 405 | test_berlin_000404_000019 406 | test_berlin_000405_000019 407 | test_berlin_000406_000019 408 | test_berlin_000407_000019 409 | test_berlin_000408_000019 410 | test_berlin_000409_000019 411 | test_berlin_000410_000019 412 | test_berlin_000411_000019 413 | test_berlin_000412_000019 414 | test_berlin_000413_000019 415 | test_berlin_000414_000019 416 | test_berlin_000415_000019 417 | test_berlin_000416_000019 418 | test_berlin_000417_000019 419 | test_berlin_000418_000019 420 | test_berlin_000419_000019 421 | test_berlin_000420_000019 422 | test_berlin_000421_000019 423 | test_berlin_000422_000019 424 | test_berlin_000423_000019 425 | test_berlin_000424_000019 426 | test_berlin_000425_000019 427 | test_berlin_000426_000019 428 | test_berlin_000427_000019 429 | test_berlin_000428_000019 430 | test_berlin_000429_000019 431 | test_berlin_000430_000019 432 | test_berlin_000431_000019 433 | test_berlin_000432_000019 434 | test_berlin_000433_000019 435 | test_berlin_000434_000019 436 | test_berlin_000435_000019 437 | test_berlin_000436_000019 438 | test_berlin_000437_000019 439 | test_berlin_000438_000019 440 | test_berlin_000439_000019 441 | test_berlin_000440_000019 442 | test_berlin_000441_000019 443 | test_berlin_000442_000019 444 | test_berlin_000443_000019 445 | test_berlin_000444_000019 446 | test_berlin_000445_000019 447 | test_berlin_000446_000019 448 | test_berlin_000447_000019 449 | test_berlin_000448_000019 450 | test_berlin_000449_000019 451 | test_berlin_000450_000019 452 | test_berlin_000451_000019 453 | test_berlin_000452_000019 454 | test_berlin_000453_000019 455 | test_berlin_000454_000019 456 | test_berlin_000455_000019 457 | test_berlin_000456_000019 458 | test_berlin_000457_000019 459 | test_berlin_000458_000019 460 | test_berlin_000459_000019 461 | test_berlin_000460_000019 462 | test_berlin_000461_000019 463 | test_berlin_000462_000019 464 | test_berlin_000463_000019 465 | test_berlin_000464_000019 466 | test_berlin_000465_000019 467 | test_berlin_000466_000019 468 | test_berlin_000467_000019 469 | test_berlin_000468_000019 470 | test_berlin_000469_000019 471 | test_berlin_000470_000019 472 | test_berlin_000471_000019 473 | test_berlin_000472_000019 474 | test_berlin_000473_000019 475 | test_berlin_000474_000019 476 | test_berlin_000475_000019 477 | test_berlin_000476_000019 478 | test_berlin_000477_000019 479 | test_berlin_000478_000019 480 | test_berlin_000479_000019 481 | test_berlin_000480_000019 482 | test_berlin_000481_000019 483 | test_berlin_000482_000019 484 | test_berlin_000483_000019 485 | test_berlin_000484_000019 486 | test_berlin_000485_000019 487 | test_berlin_000486_000019 488 | test_berlin_000487_000019 489 | test_berlin_000488_000019 490 | test_berlin_000489_000019 491 | test_berlin_000490_000019 492 | test_berlin_000491_000019 493 | test_berlin_000492_000019 494 | test_berlin_000493_000019 495 | test_berlin_000494_000019 496 | test_berlin_000495_000019 497 | test_berlin_000496_000019 498 | test_berlin_000497_000019 499 | test_berlin_000498_000019 500 | test_berlin_000499_000019 501 | test_berlin_000500_000019 502 | test_berlin_000501_000019 503 | test_berlin_000502_000019 504 | test_berlin_000503_000019 505 | test_berlin_000504_000019 506 | test_berlin_000505_000019 507 | test_berlin_000506_000019 508 | test_berlin_000507_000019 509 | test_berlin_000508_000019 510 | test_berlin_000509_000019 511 | test_berlin_000510_000019 512 | test_berlin_000511_000019 513 | test_berlin_000512_000019 514 | test_berlin_000513_000019 515 | test_berlin_000514_000019 516 | test_berlin_000515_000019 517 | test_berlin_000516_000019 518 | test_berlin_000517_000019 519 | test_berlin_000518_000019 520 | test_berlin_000519_000019 521 | test_berlin_000520_000019 522 | test_berlin_000521_000019 523 | test_berlin_000522_000019 524 | test_berlin_000523_000019 525 | test_berlin_000524_000019 526 | test_berlin_000525_000019 527 | test_berlin_000526_000019 528 | test_berlin_000527_000019 529 | test_berlin_000528_000019 530 | test_berlin_000529_000019 531 | test_berlin_000530_000019 532 | test_berlin_000531_000019 533 | test_berlin_000532_000019 534 | test_berlin_000533_000019 535 | test_berlin_000534_000019 536 | test_berlin_000535_000019 537 | test_berlin_000536_000019 538 | test_berlin_000537_000019 539 | test_berlin_000538_000019 540 | test_berlin_000539_000019 541 | test_berlin_000540_000019 542 | test_berlin_000541_000019 543 | test_berlin_000542_000019 544 | test_berlin_000543_000019 545 | test_bielefeld_000000_000321 546 | test_bielefeld_000000_000856 547 | test_bielefeld_000000_001011 548 | test_bielefeld_000000_001187 549 | test_bielefeld_000000_001505 550 | test_bielefeld_000000_001705 551 | test_bielefeld_000000_002308 552 | test_bielefeld_000000_002528 553 | test_bielefeld_000000_002735 554 | test_bielefeld_000000_003080 555 | test_bielefeld_000000_003406 556 | test_bielefeld_000000_003546 557 | test_bielefeld_000000_003731 558 | test_bielefeld_000000_004345 559 | test_bielefeld_000000_005068 560 | test_bielefeld_000000_005260 561 | test_bielefeld_000000_005372 562 | test_bielefeld_000000_005584 563 | test_bielefeld_000000_005741 564 | test_bielefeld_000000_005942 565 | test_bielefeld_000000_006239 566 | test_bielefeld_000000_006603 567 | test_bielefeld_000000_006802 568 | test_bielefeld_000000_007030 569 | test_bielefeld_000000_007186 570 | test_bielefeld_000000_007545 571 | test_bielefeld_000000_008279 572 | test_bielefeld_000000_008581 573 | test_bielefeld_000000_008800 574 | test_bielefeld_000000_009728 575 | test_bielefeld_000000_009928 576 | test_bielefeld_000000_010156 577 | test_bielefeld_000000_011367 578 | test_bielefeld_000000_011831 579 | test_bielefeld_000000_012080 580 | test_bielefeld_000000_012584 581 | test_bielefeld_000000_012788 582 | test_bielefeld_000000_013570 583 | test_bielefeld_000000_013665 584 | test_bielefeld_000000_013814 585 | test_bielefeld_000000_014068 586 | test_bielefeld_000000_015301 587 | test_bielefeld_000000_015411 588 | test_bielefeld_000000_015587 589 | test_bielefeld_000000_015867 590 | test_bielefeld_000000_015942 591 | test_bielefeld_000000_016019 592 | test_bielefeld_000000_016718 593 | test_bielefeld_000000_016924 594 | test_bielefeld_000000_017051 595 | test_bielefeld_000000_017279 596 | test_bielefeld_000000_017438 597 | test_bielefeld_000000_017774 598 | test_bielefeld_000000_018102 599 | test_bielefeld_000000_018345 600 | test_bielefeld_000000_018644 601 | test_bielefeld_000000_019416 602 | test_bielefeld_000000_020757 603 | test_bielefeld_000000_020900 604 | test_bielefeld_000000_021221 605 | test_bielefeld_000000_021341 606 | test_bielefeld_000000_021381 607 | test_bielefeld_000000_021625 608 | test_bielefeld_000000_021826 609 | test_bielefeld_000000_022261 610 | test_bielefeld_000000_022835 611 | test_bielefeld_000000_025061 612 | test_bielefeld_000000_025426 613 | test_bielefeld_000000_025748 614 | test_bielefeld_000000_026053 615 | test_bielefeld_000000_026296 616 | test_bielefeld_000000_026550 617 | test_bielefeld_000000_026660 618 | test_bielefeld_000000_026823 619 | test_bielefeld_000000_027221 620 | test_bielefeld_000000_027586 621 | test_bielefeld_000000_027928 622 | test_bielefeld_000000_028046 623 | test_bielefeld_000000_028148 624 | test_bielefeld_000000_028414 625 | test_bielefeld_000000_028550 626 | test_bielefeld_000000_028747 627 | test_bielefeld_000000_029148 628 | test_bielefeld_000000_030038 629 | test_bielefeld_000000_030366 630 | test_bielefeld_000000_030958 631 | test_bielefeld_000000_031244 632 | test_bielefeld_000000_031510 633 | test_bielefeld_000000_032388 634 | test_bielefeld_000000_032766 635 | test_bielefeld_000000_033675 636 | test_bielefeld_000000_033770 637 | test_bielefeld_000000_033979 638 | test_bielefeld_000000_034705 639 | test_bielefeld_000000_034929 640 | test_bielefeld_000000_035223 641 | test_bielefeld_000000_035537 642 | test_bielefeld_000000_035879 643 | test_bielefeld_000000_036362 644 | test_bielefeld_000000_036732 645 | test_bielefeld_000000_037016 646 | test_bielefeld_000000_037159 647 | test_bielefeld_000000_037422 648 | test_bielefeld_000000_038924 649 | test_bielefeld_000000_039082 650 | test_bielefeld_000000_039221 651 | test_bielefeld_000000_039596 652 | test_bielefeld_000000_040035 653 | test_bielefeld_000000_040472 654 | test_bielefeld_000000_041014 655 | test_bielefeld_000000_041142 656 | test_bielefeld_000000_041223 657 | test_bielefeld_000000_041444 658 | test_bielefeld_000000_042403 659 | test_bielefeld_000000_042571 660 | test_bielefeld_000000_042717 661 | test_bielefeld_000000_043100 662 | test_bielefeld_000000_043389 663 | test_bielefeld_000000_043610 664 | test_bielefeld_000000_044085 665 | test_bielefeld_000000_045117 666 | test_bielefeld_000000_045232 667 | test_bielefeld_000000_046023 668 | test_bielefeld_000000_046212 669 | test_bielefeld_000000_046495 670 | test_bielefeld_000000_047542 671 | test_bielefeld_000000_047918 672 | test_bielefeld_000000_048227 673 | test_bielefeld_000000_048518 674 | test_bielefeld_000000_048754 675 | test_bielefeld_000000_048864 676 | test_bielefeld_000000_049313 677 | test_bielefeld_000000_049446 678 | test_bielefeld_000000_050021 679 | test_bielefeld_000000_050426 680 | test_bielefeld_000000_050586 681 | test_bielefeld_000000_051102 682 | test_bielefeld_000000_051223 683 | test_bielefeld_000000_051894 684 | test_bielefeld_000000_052155 685 | test_bielefeld_000000_053028 686 | test_bielefeld_000000_053384 687 | test_bielefeld_000000_053583 688 | test_bielefeld_000000_053779 689 | test_bielefeld_000000_055003 690 | test_bielefeld_000000_055145 691 | test_bielefeld_000000_056175 692 | test_bielefeld_000000_056226 693 | test_bielefeld_000000_056310 694 | test_bielefeld_000000_056493 695 | test_bielefeld_000000_056603 696 | test_bielefeld_000000_056866 697 | test_bielefeld_000000_058374 698 | test_bielefeld_000000_058776 699 | test_bielefeld_000000_058934 700 | test_bielefeld_000000_059119 701 | test_bielefeld_000000_059303 702 | test_bielefeld_000000_059355 703 | test_bielefeld_000000_059501 704 | test_bielefeld_000000_059651 705 | test_bielefeld_000000_059729 706 | test_bielefeld_000000_059766 707 | test_bielefeld_000000_059842 708 | test_bielefeld_000000_060786 709 | test_bielefeld_000000_060861 710 | test_bielefeld_000000_061094 711 | test_bielefeld_000000_061341 712 | test_bielefeld_000000_061975 713 | test_bielefeld_000000_062121 714 | test_bielefeld_000000_063427 715 | test_bielefeld_000000_063623 716 | test_bielefeld_000000_063939 717 | test_bielefeld_000000_064271 718 | test_bielefeld_000000_064583 719 | test_bielefeld_000000_064805 720 | test_bielefeld_000000_064910 721 | test_bielefeld_000000_065023 722 | test_bielefeld_000000_065154 723 | test_bielefeld_000000_066195 724 | test_bielefeld_000000_066405 725 | test_bielefeld_000000_066495 726 | test_bonn_000000_000019 727 | test_bonn_000001_000019 728 | test_bonn_000002_000019 729 | test_bonn_000003_000019 730 | test_bonn_000004_000019 731 | test_bonn_000005_000019 732 | test_bonn_000006_000019 733 | test_bonn_000007_000019 734 | test_bonn_000008_000019 735 | test_bonn_000009_000019 736 | test_bonn_000010_000019 737 | test_bonn_000011_000019 738 | test_bonn_000012_000019 739 | test_bonn_000013_000019 740 | test_bonn_000014_000019 741 | test_bonn_000015_000019 742 | test_bonn_000016_000019 743 | test_bonn_000017_000019 744 | test_bonn_000018_000019 745 | test_bonn_000019_000019 746 | test_bonn_000020_000019 747 | test_bonn_000021_000019 748 | test_bonn_000022_000019 749 | test_bonn_000023_000019 750 | test_bonn_000024_000019 751 | test_bonn_000025_000019 752 | test_bonn_000026_000019 753 | test_bonn_000027_000019 754 | test_bonn_000028_000019 755 | test_bonn_000029_000019 756 | test_bonn_000030_000019 757 | test_bonn_000031_000019 758 | test_bonn_000032_000019 759 | test_bonn_000033_000019 760 | test_bonn_000034_000019 761 | test_bonn_000035_000019 762 | test_bonn_000036_000019 763 | test_bonn_000037_000019 764 | test_bonn_000038_000019 765 | test_bonn_000039_000019 766 | test_bonn_000040_000019 767 | test_bonn_000041_000019 768 | test_bonn_000042_000019 769 | test_bonn_000043_000019 770 | test_bonn_000044_000019 771 | test_bonn_000045_000019 772 | test_leverkusen_000000_000019 773 | test_leverkusen_000001_000019 774 | test_leverkusen_000002_000019 775 | test_leverkusen_000003_000019 776 | test_leverkusen_000004_000019 777 | test_leverkusen_000005_000019 778 | test_leverkusen_000006_000019 779 | test_leverkusen_000007_000019 780 | test_leverkusen_000008_000019 781 | test_leverkusen_000009_000019 782 | test_leverkusen_000010_000019 783 | test_leverkusen_000011_000019 784 | test_leverkusen_000012_000019 785 | test_leverkusen_000013_000019 786 | test_leverkusen_000014_000019 787 | test_leverkusen_000015_000019 788 | test_leverkusen_000016_000019 789 | test_leverkusen_000017_000019 790 | test_leverkusen_000018_000019 791 | test_leverkusen_000019_000019 792 | test_leverkusen_000020_000019 793 | test_leverkusen_000021_000019 794 | test_leverkusen_000022_000019 795 | test_leverkusen_000023_000019 796 | test_leverkusen_000024_000019 797 | test_leverkusen_000025_000019 798 | test_leverkusen_000026_000019 799 | test_leverkusen_000027_000019 800 | test_leverkusen_000028_000019 801 | test_leverkusen_000029_000019 802 | test_leverkusen_000030_000019 803 | test_leverkusen_000031_000019 804 | test_leverkusen_000032_000019 805 | test_leverkusen_000033_000019 806 | test_leverkusen_000034_000019 807 | test_leverkusen_000035_000019 808 | test_leverkusen_000036_000019 809 | test_leverkusen_000037_000019 810 | test_leverkusen_000038_000019 811 | test_leverkusen_000039_000019 812 | test_leverkusen_000040_000019 813 | test_leverkusen_000041_000019 814 | test_leverkusen_000042_000019 815 | test_leverkusen_000043_000019 816 | test_leverkusen_000044_000019 817 | test_leverkusen_000045_000019 818 | test_leverkusen_000046_000019 819 | test_leverkusen_000047_000019 820 | test_leverkusen_000048_000019 821 | test_leverkusen_000049_000019 822 | test_leverkusen_000050_000019 823 | test_leverkusen_000051_000019 824 | test_leverkusen_000052_000019 825 | test_leverkusen_000053_000019 826 | test_leverkusen_000054_000019 827 | test_leverkusen_000055_000019 828 | test_leverkusen_000056_000019 829 | test_leverkusen_000057_000019 830 | test_mainz_000000_000093 831 | test_mainz_000000_000293 832 | test_mainz_000000_001003 833 | test_mainz_000000_001068 834 | test_mainz_000000_001265 835 | test_mainz_000000_001410 836 | test_mainz_000000_001601 837 | test_mainz_000000_001857 838 | test_mainz_000000_002212 839 | test_mainz_000000_002353 840 | test_mainz_000000_003049 841 | test_mainz_000000_003250 842 | test_mainz_000000_003506 843 | test_mainz_000000_003619 844 | test_mainz_000000_004000 845 | test_mainz_000000_004237 846 | test_mainz_000000_004542 847 | test_mainz_000000_004740 848 | test_mainz_000000_005403 849 | test_mainz_000000_005549 850 | test_mainz_000000_005817 851 | test_mainz_000000_006141 852 | test_mainz_000000_006263 853 | test_mainz_000000_006368 854 | test_mainz_000000_006649 855 | test_mainz_000000_007415 856 | test_mainz_000000_007813 857 | test_mainz_000000_008001 858 | test_mainz_000000_008165 859 | test_mainz_000000_008509 860 | test_mainz_000000_008645 861 | test_mainz_000000_008871 862 | test_mainz_000000_009751 863 | test_mainz_000000_009985 864 | test_mainz_000000_010171 865 | test_mainz_000000_010417 866 | test_mainz_000000_010550 867 | test_mainz_000000_011339 868 | test_mainz_000000_011879 869 | test_mainz_000000_011965 870 | test_mainz_000000_012392 871 | test_mainz_000000_012737 872 | test_mainz_000000_013095 873 | test_mainz_000000_013437 874 | test_mainz_000000_013671 875 | test_mainz_000000_013960 876 | test_mainz_000000_014193 877 | test_mainz_000000_014742 878 | test_mainz_000000_015052 879 | test_mainz_000000_015170 880 | test_mainz_000000_015760 881 | test_mainz_000000_016083 882 | test_mainz_000000_016281 883 | test_mainz_000000_016612 884 | test_mainz_000000_016651 885 | test_mainz_000000_016915 886 | test_mainz_000000_017927 887 | test_mainz_000000_018249 888 | test_mainz_000000_018883 889 | test_mainz_000000_019043 890 | test_mainz_000000_019227 891 | test_mainz_000000_019439 892 | test_mainz_000000_019686 893 | test_mainz_000000_019847 894 | test_mainz_000000_020139 895 | test_mainz_000000_020415 896 | test_mainz_000000_021457 897 | test_mainz_000000_021524 898 | test_mainz_000000_021735 899 | test_mainz_000000_021833 900 | test_mainz_000000_022091 901 | test_mainz_000000_022417 902 | test_mainz_000001_000120 903 | test_mainz_000001_000428 904 | test_mainz_000001_001509 905 | test_mainz_000001_002033 906 | test_mainz_000001_002543 907 | test_mainz_000001_002884 908 | test_mainz_000001_003012 909 | test_mainz_000001_003624 910 | test_mainz_000001_003702 911 | test_mainz_000001_003907 912 | test_mainz_000001_004132 913 | test_mainz_000001_004219 914 | test_mainz_000001_004823 915 | test_mainz_000001_005016 916 | test_mainz_000001_005163 917 | test_mainz_000001_005366 918 | test_mainz_000001_005665 919 | test_mainz_000001_005815 920 | test_mainz_000001_005911 921 | test_mainz_000001_006194 922 | test_mainz_000001_006768 923 | test_mainz_000001_007171 924 | test_mainz_000001_007460 925 | test_mainz_000001_007595 926 | test_mainz_000001_007956 927 | test_mainz_000001_008056 928 | test_mainz_000001_008264 929 | test_mainz_000001_008540 930 | test_mainz_000001_008638 931 | test_mainz_000001_008771 932 | test_mainz_000001_009152 933 | test_mainz_000001_009328 934 | test_mainz_000001_009811 935 | test_mainz_000001_009867 936 | test_mainz_000001_009996 937 | test_mainz_000001_010853 938 | test_mainz_000001_011333 939 | test_mainz_000001_011736 940 | test_mainz_000001_011785 941 | test_mainz_000001_012186 942 | test_mainz_000001_012470 943 | test_mainz_000001_012541 944 | test_mainz_000001_012644 945 | test_mainz_000001_012950 946 | test_mainz_000001_013313 947 | test_mainz_000001_014073 948 | test_mainz_000001_014469 949 | test_mainz_000001_014626 950 | test_mainz_000001_015117 951 | test_mainz_000001_015235 952 | test_mainz_000001_015508 953 | test_mainz_000001_015724 954 | test_mainz_000001_016011 955 | test_mainz_000001_016391 956 | test_mainz_000001_016931 957 | test_mainz_000001_017618 958 | test_mainz_000001_017992 959 | test_mainz_000001_018145 960 | test_mainz_000001_018329 961 | test_mainz_000001_018670 962 | test_mainz_000001_018817 963 | test_mainz_000001_019061 964 | test_mainz_000001_019286 965 | test_mainz_000001_019593 966 | test_mainz_000001_020068 967 | test_mainz_000001_020193 968 | test_mainz_000001_020484 969 | test_mainz_000001_020829 970 | test_mainz_000001_021042 971 | test_mainz_000001_021547 972 | test_mainz_000001_021892 973 | test_mainz_000001_021946 974 | test_mainz_000001_022125 975 | test_mainz_000001_022630 976 | test_mainz_000001_023439 977 | test_mainz_000001_023604 978 | test_mainz_000001_024439 979 | test_mainz_000001_024489 980 | test_mainz_000001_024718 981 | test_mainz_000001_025161 982 | test_mainz_000001_025390 983 | test_mainz_000001_025623 984 | test_mainz_000001_026209 985 | test_mainz_000001_026837 986 | test_mainz_000001_026963 987 | test_mainz_000001_027053 988 | test_mainz_000001_027124 989 | test_mainz_000001_027377 990 | test_mainz_000001_027675 991 | test_mainz_000001_027751 992 | test_mainz_000001_028111 993 | test_mainz_000001_028326 994 | test_mainz_000001_028566 995 | test_mainz_000001_028847 996 | test_mainz_000001_029293 997 | test_mainz_000001_029521 998 | test_mainz_000001_029755 999 | test_mainz_000001_029950 1000 | test_mainz_000001_030417 1001 | test_mainz_000001_030630 1002 | test_mainz_000001_031026 1003 | test_mainz_000001_031350 1004 | test_mainz_000001_031697 1005 | test_mainz_000001_031946 1006 | test_mainz_000001_032294 1007 | test_mainz_000001_032401 1008 | test_mainz_000001_032567 1009 | test_mainz_000001_032691 1010 | test_mainz_000001_032767 1011 | test_mainz_000001_032911 1012 | test_mainz_000001_033096 1013 | test_mainz_000001_033329 1014 | test_mainz_000001_033437 1015 | test_mainz_000001_033603 1016 | test_mainz_000001_033756 1017 | test_mainz_000001_034033 1018 | test_mainz_000001_034209 1019 | test_mainz_000001_034394 1020 | test_mainz_000001_034508 1021 | test_mainz_000001_034681 1022 | test_mainz_000001_035293 1023 | test_mainz_000001_035585 1024 | test_mainz_000001_035963 1025 | test_mainz_000001_036115 1026 | test_mainz_000001_036240 1027 | test_mainz_000001_036412 1028 | test_mainz_000001_037170 1029 | test_mainz_000001_037411 1030 | test_mainz_000001_037532 1031 | test_mainz_000001_037736 1032 | test_mainz_000001_037905 1033 | test_mainz_000001_038026 1034 | test_mainz_000001_038191 1035 | test_mainz_000001_038347 1036 | test_mainz_000001_038768 1037 | test_mainz_000001_038955 1038 | test_mainz_000001_039075 1039 | test_mainz_000001_039470 1040 | test_mainz_000001_039943 1041 | test_mainz_000001_040195 1042 | test_mainz_000001_040367 1043 | test_mainz_000001_040839 1044 | test_mainz_000001_041172 1045 | test_mainz_000001_041284 1046 | test_mainz_000001_041647 1047 | test_mainz_000001_041797 1048 | test_mainz_000001_041887 1049 | test_mainz_000001_041923 1050 | test_mainz_000001_042121 1051 | test_mainz_000001_042400 1052 | test_mainz_000001_042851 1053 | test_mainz_000001_043656 1054 | test_mainz_000001_043886 1055 | test_mainz_000001_044366 1056 | test_mainz_000001_044619 1057 | test_mainz_000001_045197 1058 | test_mainz_000001_045385 1059 | test_mainz_000001_045651 1060 | test_mainz_000001_045782 1061 | test_mainz_000001_046381 1062 | test_mainz_000001_046981 1063 | test_mainz_000001_047546 1064 | test_mainz_000001_047611 1065 | test_mainz_000001_047888 1066 | test_mainz_000001_048725 1067 | test_mainz_000002_000061 1068 | test_mainz_000002_000181 1069 | test_mainz_000002_000381 1070 | test_mainz_000002_000912 1071 | test_mainz_000002_001747 1072 | test_mainz_000002_001871 1073 | test_mainz_000002_002279 1074 | test_mainz_000003_000043 1075 | test_mainz_000003_000968 1076 | test_mainz_000003_001465 1077 | test_mainz_000003_001694 1078 | test_mainz_000003_001899 1079 | test_mainz_000003_003042 1080 | test_mainz_000003_003455 1081 | test_mainz_000003_003558 1082 | test_mainz_000003_003711 1083 | test_mainz_000003_003791 1084 | test_mainz_000003_003942 1085 | test_mainz_000003_004144 1086 | test_mainz_000003_004228 1087 | test_mainz_000003_004576 1088 | test_mainz_000003_004774 1089 | test_mainz_000003_004883 1090 | test_mainz_000003_005029 1091 | test_mainz_000003_005088 1092 | test_mainz_000003_005162 1093 | test_mainz_000003_006478 1094 | test_mainz_000003_006863 1095 | test_mainz_000003_007024 1096 | test_mainz_000003_007144 1097 | test_mainz_000003_007255 1098 | test_mainz_000003_007701 1099 | test_mainz_000003_008258 1100 | test_mainz_000003_008690 1101 | test_mainz_000003_008876 1102 | test_mainz_000003_009819 1103 | test_mainz_000003_010019 1104 | test_mainz_000003_010772 1105 | test_mainz_000003_010880 1106 | test_mainz_000003_010924 1107 | test_mainz_000003_011182 1108 | test_mainz_000003_011352 1109 | test_mainz_000003_011949 1110 | test_mainz_000003_012168 1111 | test_mainz_000003_012341 1112 | test_mainz_000003_012995 1113 | test_mainz_000003_013348 1114 | test_mainz_000003_013983 1115 | test_mainz_000003_014083 1116 | test_mainz_000003_014319 1117 | test_mainz_000003_014457 1118 | test_mainz_000003_014537 1119 | test_mainz_000003_014959 1120 | test_mainz_000003_015411 1121 | test_mainz_000003_015649 1122 | test_mainz_000003_015917 1123 | test_mainz_000003_016360 1124 | test_mainz_000003_016542 1125 | test_mainz_000003_016708 1126 | test_mainz_000003_016877 1127 | test_mainz_000003_017171 1128 | test_munich_000000_000019 1129 | test_munich_000001_000019 1130 | test_munich_000002_000019 1131 | test_munich_000003_000019 1132 | test_munich_000004_000019 1133 | test_munich_000005_000019 1134 | test_munich_000006_000019 1135 | test_munich_000007_000019 1136 | test_munich_000008_000019 1137 | test_munich_000009_000019 1138 | test_munich_000010_000019 1139 | test_munich_000011_000019 1140 | test_munich_000012_000019 1141 | test_munich_000013_000019 1142 | test_munich_000014_000019 1143 | test_munich_000015_000019 1144 | test_munich_000016_000019 1145 | test_munich_000017_000019 1146 | test_munich_000018_000019 1147 | test_munich_000019_000019 1148 | test_munich_000020_000019 1149 | test_munich_000021_000019 1150 | test_munich_000022_000019 1151 | test_munich_000023_000019 1152 | test_munich_000024_000019 1153 | test_munich_000025_000019 1154 | test_munich_000026_000019 1155 | test_munich_000027_000019 1156 | test_munich_000028_000019 1157 | test_munich_000029_000019 1158 | test_munich_000030_000019 1159 | test_munich_000031_000019 1160 | test_munich_000032_000019 1161 | test_munich_000033_000019 1162 | test_munich_000034_000019 1163 | test_munich_000035_000019 1164 | test_munich_000036_000019 1165 | test_munich_000037_000019 1166 | test_munich_000038_000019 1167 | test_munich_000039_000019 1168 | test_munich_000040_000019 1169 | test_munich_000041_000019 1170 | test_munich_000042_000019 1171 | test_munich_000043_000019 1172 | test_munich_000044_000019 1173 | test_munich_000045_000019 1174 | test_munich_000046_000019 1175 | test_munich_000047_000019 1176 | test_munich_000048_000019 1177 | test_munich_000049_000019 1178 | test_munich_000050_000019 1179 | test_munich_000051_000019 1180 | test_munich_000052_000019 1181 | test_munich_000053_000019 1182 | test_munich_000054_000019 1183 | test_munich_000055_000019 1184 | test_munich_000056_000019 1185 | test_munich_000057_000019 1186 | test_munich_000058_000019 1187 | test_munich_000059_000019 1188 | test_munich_000060_000019 1189 | test_munich_000061_000019 1190 | test_munich_000062_000019 1191 | test_munich_000063_000019 1192 | test_munich_000064_000019 1193 | test_munich_000065_000019 1194 | test_munich_000066_000019 1195 | test_munich_000067_000019 1196 | test_munich_000068_000019 1197 | test_munich_000069_000019 1198 | test_munich_000070_000019 1199 | test_munich_000071_000019 1200 | test_munich_000072_000019 1201 | test_munich_000073_000019 1202 | test_munich_000074_000019 1203 | test_munich_000075_000019 1204 | test_munich_000076_000019 1205 | test_munich_000077_000019 1206 | test_munich_000078_000019 1207 | test_munich_000079_000019 1208 | test_munich_000080_000019 1209 | test_munich_000081_000019 1210 | test_munich_000082_000019 1211 | test_munich_000083_000019 1212 | test_munich_000084_000019 1213 | test_munich_000085_000019 1214 | test_munich_000086_000019 1215 | test_munich_000087_000019 1216 | test_munich_000088_000019 1217 | test_munich_000089_000019 1218 | test_munich_000090_000019 1219 | test_munich_000091_000019 1220 | test_munich_000092_000019 1221 | test_munich_000093_000019 1222 | test_munich_000094_000019 1223 | test_munich_000095_000019 1224 | test_munich_000096_000019 1225 | test_munich_000097_000019 1226 | test_munich_000098_000019 1227 | test_munich_000099_000019 1228 | test_munich_000100_000019 1229 | test_munich_000101_000019 1230 | test_munich_000102_000019 1231 | test_munich_000103_000019 1232 | test_munich_000104_000019 1233 | test_munich_000105_000019 1234 | test_munich_000106_000019 1235 | test_munich_000107_000019 1236 | test_munich_000108_000019 1237 | test_munich_000109_000019 1238 | test_munich_000110_000019 1239 | test_munich_000111_000019 1240 | test_munich_000112_000019 1241 | test_munich_000113_000019 1242 | test_munich_000114_000019 1243 | test_munich_000115_000019 1244 | test_munich_000116_000019 1245 | test_munich_000117_000019 1246 | test_munich_000118_000019 1247 | test_munich_000119_000019 1248 | test_munich_000120_000019 1249 | test_munich_000121_000019 1250 | test_munich_000122_000019 1251 | test_munich_000123_000019 1252 | test_munich_000124_000019 1253 | test_munich_000125_000019 1254 | test_munich_000126_000019 1255 | test_munich_000127_000019 1256 | test_munich_000128_000019 1257 | test_munich_000129_000019 1258 | test_munich_000130_000019 1259 | test_munich_000131_000019 1260 | test_munich_000132_000019 1261 | test_munich_000133_000019 1262 | test_munich_000134_000019 1263 | test_munich_000135_000019 1264 | test_munich_000136_000019 1265 | test_munich_000137_000019 1266 | test_munich_000138_000019 1267 | test_munich_000139_000019 1268 | test_munich_000140_000019 1269 | test_munich_000141_000019 1270 | test_munich_000142_000019 1271 | test_munich_000143_000019 1272 | test_munich_000144_000019 1273 | test_munich_000145_000019 1274 | test_munich_000146_000019 1275 | test_munich_000147_000019 1276 | test_munich_000148_000019 1277 | test_munich_000149_000019 1278 | test_munich_000150_000019 1279 | test_munich_000151_000019 1280 | test_munich_000152_000019 1281 | test_munich_000153_000019 1282 | test_munich_000154_000019 1283 | test_munich_000155_000019 1284 | test_munich_000156_000019 1285 | test_munich_000157_000019 1286 | test_munich_000158_000019 1287 | test_munich_000159_000019 1288 | test_munich_000160_000019 1289 | test_munich_000161_000019 1290 | test_munich_000162_000019 1291 | test_munich_000163_000019 1292 | test_munich_000164_000019 1293 | test_munich_000165_000019 1294 | test_munich_000166_000019 1295 | test_munich_000167_000019 1296 | test_munich_000168_000019 1297 | test_munich_000169_000019 1298 | test_munich_000170_000019 1299 | test_munich_000171_000019 1300 | test_munich_000172_000019 1301 | test_munich_000173_000019 1302 | test_munich_000174_000019 1303 | test_munich_000175_000019 1304 | test_munich_000176_000019 1305 | test_munich_000177_000019 1306 | test_munich_000178_000019 1307 | test_munich_000179_000019 1308 | test_munich_000180_000019 1309 | test_munich_000181_000019 1310 | test_munich_000182_000019 1311 | test_munich_000183_000019 1312 | test_munich_000184_000019 1313 | test_munich_000185_000019 1314 | test_munich_000186_000019 1315 | test_munich_000187_000019 1316 | test_munich_000188_000019 1317 | test_munich_000189_000019 1318 | test_munich_000190_000019 1319 | test_munich_000191_000019 1320 | test_munich_000192_000019 1321 | test_munich_000193_000019 1322 | test_munich_000194_000019 1323 | test_munich_000195_000019 1324 | test_munich_000196_000019 1325 | test_munich_000197_000019 1326 | test_munich_000198_000019 1327 | test_munich_000199_000019 1328 | test_munich_000200_000019 1329 | test_munich_000201_000019 1330 | test_munich_000202_000019 1331 | test_munich_000203_000019 1332 | test_munich_000204_000019 1333 | test_munich_000205_000019 1334 | test_munich_000206_000019 1335 | test_munich_000207_000019 1336 | test_munich_000208_000019 1337 | test_munich_000209_000019 1338 | test_munich_000210_000019 1339 | test_munich_000211_000019 1340 | test_munich_000212_000019 1341 | test_munich_000213_000019 1342 | test_munich_000214_000019 1343 | test_munich_000215_000019 1344 | test_munich_000216_000019 1345 | test_munich_000217_000019 1346 | test_munich_000218_000019 1347 | test_munich_000219_000019 1348 | test_munich_000220_000019 1349 | test_munich_000221_000019 1350 | test_munich_000222_000019 1351 | test_munich_000223_000019 1352 | test_munich_000224_000019 1353 | test_munich_000225_000019 1354 | test_munich_000226_000019 1355 | test_munich_000227_000019 1356 | test_munich_000228_000019 1357 | test_munich_000229_000019 1358 | test_munich_000230_000019 1359 | test_munich_000231_000019 1360 | test_munich_000232_000019 1361 | test_munich_000233_000019 1362 | test_munich_000234_000019 1363 | test_munich_000235_000019 1364 | test_munich_000236_000019 1365 | test_munich_000237_000019 1366 | test_munich_000238_000019 1367 | test_munich_000239_000019 1368 | test_munich_000240_000019 1369 | test_munich_000241_000019 1370 | test_munich_000242_000019 1371 | test_munich_000243_000019 1372 | test_munich_000244_000019 1373 | test_munich_000245_000019 1374 | test_munich_000246_000019 1375 | test_munich_000247_000019 1376 | test_munich_000248_000019 1377 | test_munich_000249_000019 1378 | test_munich_000250_000019 1379 | test_munich_000251_000019 1380 | test_munich_000252_000019 1381 | test_munich_000253_000019 1382 | test_munich_000254_000019 1383 | test_munich_000255_000019 1384 | test_munich_000256_000019 1385 | test_munich_000257_000019 1386 | test_munich_000258_000019 1387 | test_munich_000259_000019 1388 | test_munich_000260_000019 1389 | test_munich_000261_000019 1390 | test_munich_000262_000019 1391 | test_munich_000263_000019 1392 | test_munich_000264_000019 1393 | test_munich_000265_000019 1394 | test_munich_000266_000019 1395 | test_munich_000267_000019 1396 | test_munich_000268_000019 1397 | test_munich_000269_000019 1398 | test_munich_000270_000019 1399 | test_munich_000271_000019 1400 | test_munich_000272_000019 1401 | test_munich_000273_000019 1402 | test_munich_000274_000019 1403 | test_munich_000275_000019 1404 | test_munich_000276_000019 1405 | test_munich_000277_000019 1406 | test_munich_000278_000019 1407 | test_munich_000279_000019 1408 | test_munich_000280_000019 1409 | test_munich_000281_000019 1410 | test_munich_000282_000019 1411 | test_munich_000283_000019 1412 | test_munich_000284_000019 1413 | test_munich_000285_000019 1414 | test_munich_000286_000019 1415 | test_munich_000287_000019 1416 | test_munich_000288_000019 1417 | test_munich_000289_000019 1418 | test_munich_000290_000019 1419 | test_munich_000291_000019 1420 | test_munich_000292_000019 1421 | test_munich_000293_000019 1422 | test_munich_000294_000019 1423 | test_munich_000295_000019 1424 | test_munich_000296_000019 1425 | test_munich_000297_000019 1426 | test_munich_000298_000019 1427 | test_munich_000299_000019 1428 | test_munich_000300_000019 1429 | test_munich_000301_000019 1430 | test_munich_000302_000019 1431 | test_munich_000303_000019 1432 | test_munich_000304_000019 1433 | test_munich_000305_000019 1434 | test_munich_000306_000019 1435 | test_munich_000307_000019 1436 | test_munich_000308_000019 1437 | test_munich_000309_000019 1438 | test_munich_000310_000019 1439 | test_munich_000311_000019 1440 | test_munich_000312_000019 1441 | test_munich_000313_000019 1442 | test_munich_000314_000019 1443 | test_munich_000315_000019 1444 | test_munich_000316_000019 1445 | test_munich_000317_000019 1446 | test_munich_000318_000019 1447 | test_munich_000319_000019 1448 | test_munich_000320_000019 1449 | test_munich_000321_000019 1450 | test_munich_000322_000019 1451 | test_munich_000323_000019 1452 | test_munich_000324_000019 1453 | test_munich_000325_000019 1454 | test_munich_000326_000019 1455 | test_munich_000327_000019 1456 | test_munich_000328_000019 1457 | test_munich_000329_000019 1458 | test_munich_000330_000019 1459 | test_munich_000331_000019 1460 | test_munich_000332_000019 1461 | test_munich_000333_000019 1462 | test_munich_000334_000019 1463 | test_munich_000335_000019 1464 | test_munich_000336_000019 1465 | test_munich_000337_000019 1466 | test_munich_000338_000019 1467 | test_munich_000339_000019 1468 | test_munich_000340_000019 1469 | test_munich_000341_000019 1470 | test_munich_000342_000019 1471 | test_munich_000343_000019 1472 | test_munich_000344_000019 1473 | test_munich_000345_000019 1474 | test_munich_000346_000019 1475 | test_munich_000347_000019 1476 | test_munich_000348_000019 1477 | test_munich_000349_000019 1478 | test_munich_000350_000019 1479 | test_munich_000351_000019 1480 | test_munich_000352_000019 1481 | test_munich_000353_000019 1482 | test_munich_000354_000019 1483 | test_munich_000355_000019 1484 | test_munich_000356_000019 1485 | test_munich_000357_000019 1486 | test_munich_000358_000019 1487 | test_munich_000359_000019 1488 | test_munich_000360_000019 1489 | test_munich_000361_000019 1490 | test_munich_000362_000019 1491 | test_munich_000363_000019 1492 | test_munich_000364_000019 1493 | test_munich_000365_000019 1494 | test_munich_000366_000019 1495 | test_munich_000367_000019 1496 | test_munich_000368_000019 1497 | test_munich_000369_000019 1498 | test_munich_000370_000019 1499 | test_munich_000371_000019 1500 | test_munich_000372_000019 1501 | test_munich_000373_000019 1502 | test_munich_000374_000019 1503 | test_munich_000375_000019 1504 | test_munich_000376_000019 1505 | test_munich_000377_000019 1506 | test_munich_000378_000019 1507 | test_munich_000379_000019 1508 | test_munich_000380_000019 1509 | test_munich_000381_000019 1510 | test_munich_000382_000019 1511 | test_munich_000383_000019 1512 | test_munich_000384_000019 1513 | test_munich_000385_000019 1514 | test_munich_000386_000019 1515 | test_munich_000387_000019 1516 | test_munich_000388_000019 1517 | test_munich_000389_000019 1518 | test_munich_000390_000019 1519 | test_munich_000391_000019 1520 | test_munich_000392_000019 1521 | test_munich_000393_000019 1522 | test_munich_000394_000019 1523 | test_munich_000395_000019 1524 | test_munich_000396_000019 1525 | test_munich_000397_000019 1526 | -------------------------------------------------------------------------------- /datasets/city_list/val.txt: -------------------------------------------------------------------------------- 1 | val_frankfurt_000000_000294 2 | val_frankfurt_000000_000576 3 | val_frankfurt_000000_001016 4 | val_frankfurt_000000_001236 5 | val_frankfurt_000000_001751 6 | val_frankfurt_000000_002196 7 | val_frankfurt_000000_002963 8 | val_frankfurt_000000_003025 9 | val_frankfurt_000000_003357 10 | val_frankfurt_000000_003920 11 | val_frankfurt_000000_004617 12 | val_frankfurt_000000_005543 13 | val_frankfurt_000000_005898 14 | val_frankfurt_000000_006589 15 | val_frankfurt_000000_007365 16 | val_frankfurt_000000_008206 17 | val_frankfurt_000000_008451 18 | val_frankfurt_000000_009291 19 | val_frankfurt_000000_009561 20 | val_frankfurt_000000_009688 21 | val_frankfurt_000000_009969 22 | val_frankfurt_000000_010351 23 | val_frankfurt_000000_010763 24 | val_frankfurt_000000_011007 25 | val_frankfurt_000000_011074 26 | val_frankfurt_000000_011461 27 | val_frankfurt_000000_011810 28 | val_frankfurt_000000_012009 29 | val_frankfurt_000000_012121 30 | val_frankfurt_000000_012868 31 | val_frankfurt_000000_013067 32 | val_frankfurt_000000_013240 33 | val_frankfurt_000000_013382 34 | val_frankfurt_000000_013942 35 | val_frankfurt_000000_014480 36 | val_frankfurt_000000_015389 37 | val_frankfurt_000000_015676 38 | val_frankfurt_000000_016005 39 | val_frankfurt_000000_016286 40 | val_frankfurt_000000_017228 41 | val_frankfurt_000000_017476 42 | val_frankfurt_000000_018797 43 | val_frankfurt_000000_019607 44 | val_frankfurt_000000_020215 45 | val_frankfurt_000000_020321 46 | val_frankfurt_000000_020880 47 | val_frankfurt_000000_021667 48 | val_frankfurt_000000_021879 49 | val_frankfurt_000000_022254 50 | val_frankfurt_000000_022797 51 | val_frankfurt_000001_000538 52 | val_frankfurt_000001_001464 53 | val_frankfurt_000001_002512 54 | val_frankfurt_000001_002646 55 | val_frankfurt_000001_002759 56 | val_frankfurt_000001_003056 57 | val_frankfurt_000001_003588 58 | val_frankfurt_000001_004327 59 | val_frankfurt_000001_004736 60 | val_frankfurt_000001_004859 61 | val_frankfurt_000001_005184 62 | val_frankfurt_000001_005410 63 | val_frankfurt_000001_005703 64 | val_frankfurt_000001_005898 65 | val_frankfurt_000001_007285 66 | val_frankfurt_000001_007407 67 | val_frankfurt_000001_007622 68 | val_frankfurt_000001_007857 69 | val_frankfurt_000001_007973 70 | val_frankfurt_000001_008200 71 | val_frankfurt_000001_008688 72 | val_frankfurt_000001_009058 73 | val_frankfurt_000001_009504 74 | val_frankfurt_000001_009854 75 | val_frankfurt_000001_010156 76 | val_frankfurt_000001_010444 77 | val_frankfurt_000001_010600 78 | val_frankfurt_000001_010830 79 | val_frankfurt_000001_011162 80 | val_frankfurt_000001_011715 81 | val_frankfurt_000001_011835 82 | val_frankfurt_000001_012038 83 | val_frankfurt_000001_012519 84 | val_frankfurt_000001_012699 85 | val_frankfurt_000001_012738 86 | val_frankfurt_000001_012870 87 | val_frankfurt_000001_013016 88 | val_frankfurt_000001_013496 89 | val_frankfurt_000001_013710 90 | val_frankfurt_000001_014221 91 | val_frankfurt_000001_014406 92 | val_frankfurt_000001_014565 93 | val_frankfurt_000001_014741 94 | val_frankfurt_000001_015091 95 | val_frankfurt_000001_015328 96 | val_frankfurt_000001_015768 97 | val_frankfurt_000001_016029 98 | val_frankfurt_000001_016273 99 | val_frankfurt_000001_016462 100 | val_frankfurt_000001_017101 101 | val_frankfurt_000001_017459 102 | val_frankfurt_000001_017842 103 | val_frankfurt_000001_018113 104 | val_frankfurt_000001_019698 105 | val_frankfurt_000001_019854 106 | val_frankfurt_000001_019969 107 | val_frankfurt_000001_020046 108 | val_frankfurt_000001_020287 109 | val_frankfurt_000001_020693 110 | val_frankfurt_000001_021406 111 | val_frankfurt_000001_021825 112 | val_frankfurt_000001_023235 113 | val_frankfurt_000001_023369 114 | val_frankfurt_000001_023769 115 | val_frankfurt_000001_024927 116 | val_frankfurt_000001_025512 117 | val_frankfurt_000001_025713 118 | val_frankfurt_000001_025921 119 | val_frankfurt_000001_027325 120 | val_frankfurt_000001_028232 121 | val_frankfurt_000001_028335 122 | val_frankfurt_000001_028590 123 | val_frankfurt_000001_028854 124 | val_frankfurt_000001_029086 125 | val_frankfurt_000001_029236 126 | val_frankfurt_000001_029600 127 | val_frankfurt_000001_030067 128 | val_frankfurt_000001_030310 129 | val_frankfurt_000001_030669 130 | val_frankfurt_000001_031266 131 | val_frankfurt_000001_031416 132 | val_frankfurt_000001_032018 133 | val_frankfurt_000001_032556 134 | val_frankfurt_000001_032711 135 | val_frankfurt_000001_032942 136 | val_frankfurt_000001_033655 137 | val_frankfurt_000001_034047 138 | val_frankfurt_000001_034816 139 | val_frankfurt_000001_035144 140 | val_frankfurt_000001_035864 141 | val_frankfurt_000001_037705 142 | val_frankfurt_000001_038245 143 | val_frankfurt_000001_038418 144 | val_frankfurt_000001_038645 145 | val_frankfurt_000001_038844 146 | val_frankfurt_000001_039895 147 | val_frankfurt_000001_040575 148 | val_frankfurt_000001_040732 149 | val_frankfurt_000001_041074 150 | val_frankfurt_000001_041354 151 | val_frankfurt_000001_041517 152 | val_frankfurt_000001_041664 153 | val_frankfurt_000001_042098 154 | val_frankfurt_000001_042384 155 | val_frankfurt_000001_042733 156 | val_frankfurt_000001_043395 157 | val_frankfurt_000001_043564 158 | val_frankfurt_000001_044227 159 | val_frankfurt_000001_044413 160 | val_frankfurt_000001_044525 161 | val_frankfurt_000001_044658 162 | val_frankfurt_000001_044787 163 | val_frankfurt_000001_046126 164 | val_frankfurt_000001_046272 165 | val_frankfurt_000001_046504 166 | val_frankfurt_000001_046779 167 | val_frankfurt_000001_047178 168 | val_frankfurt_000001_047552 169 | val_frankfurt_000001_048196 170 | val_frankfurt_000001_048355 171 | val_frankfurt_000001_048654 172 | val_frankfurt_000001_049078 173 | val_frankfurt_000001_049209 174 | val_frankfurt_000001_049298 175 | val_frankfurt_000001_049698 176 | val_frankfurt_000001_049770 177 | val_frankfurt_000001_050149 178 | val_frankfurt_000001_050686 179 | val_frankfurt_000001_051516 180 | val_frankfurt_000001_051737 181 | val_frankfurt_000001_051807 182 | val_frankfurt_000001_052120 183 | val_frankfurt_000001_052594 184 | val_frankfurt_000001_053102 185 | val_frankfurt_000001_054077 186 | val_frankfurt_000001_054219 187 | val_frankfurt_000001_054415 188 | val_frankfurt_000001_054640 189 | val_frankfurt_000001_054884 190 | val_frankfurt_000001_055062 191 | val_frankfurt_000001_055172 192 | val_frankfurt_000001_055306 193 | val_frankfurt_000001_055387 194 | val_frankfurt_000001_055538 195 | val_frankfurt_000001_055603 196 | val_frankfurt_000001_055709 197 | val_frankfurt_000001_056580 198 | val_frankfurt_000001_057181 199 | val_frankfurt_000001_057478 200 | val_frankfurt_000001_057954 201 | val_frankfurt_000001_058057 202 | val_frankfurt_000001_058176 203 | val_frankfurt_000001_058504 204 | val_frankfurt_000001_058914 205 | val_frankfurt_000001_059119 206 | val_frankfurt_000001_059642 207 | val_frankfurt_000001_059789 208 | val_frankfurt_000001_060135 209 | val_frankfurt_000001_060422 210 | val_frankfurt_000001_060545 211 | val_frankfurt_000001_060906 212 | val_frankfurt_000001_061682 213 | val_frankfurt_000001_061763 214 | val_frankfurt_000001_062016 215 | val_frankfurt_000001_062250 216 | val_frankfurt_000001_062396 217 | val_frankfurt_000001_062509 218 | val_frankfurt_000001_062653 219 | val_frankfurt_000001_062793 220 | val_frankfurt_000001_063045 221 | val_frankfurt_000001_064130 222 | val_frankfurt_000001_064305 223 | val_frankfurt_000001_064651 224 | val_frankfurt_000001_064798 225 | val_frankfurt_000001_064925 226 | val_frankfurt_000001_065160 227 | val_frankfurt_000001_065617 228 | val_frankfurt_000001_065850 229 | val_frankfurt_000001_066092 230 | val_frankfurt_000001_066438 231 | val_frankfurt_000001_066574 232 | val_frankfurt_000001_066832 233 | val_frankfurt_000001_067092 234 | val_frankfurt_000001_067178 235 | val_frankfurt_000001_067295 236 | val_frankfurt_000001_067474 237 | val_frankfurt_000001_067735 238 | val_frankfurt_000001_068063 239 | val_frankfurt_000001_068208 240 | val_frankfurt_000001_068682 241 | val_frankfurt_000001_068772 242 | val_frankfurt_000001_069633 243 | val_frankfurt_000001_070099 244 | val_frankfurt_000001_071288 245 | val_frankfurt_000001_071781 246 | val_frankfurt_000001_072155 247 | val_frankfurt_000001_072295 248 | val_frankfurt_000001_073088 249 | val_frankfurt_000001_073243 250 | val_frankfurt_000001_073464 251 | val_frankfurt_000001_073911 252 | val_frankfurt_000001_075296 253 | val_frankfurt_000001_075984 254 | val_frankfurt_000001_076502 255 | val_frankfurt_000001_077092 256 | val_frankfurt_000001_077233 257 | val_frankfurt_000001_077434 258 | val_frankfurt_000001_078803 259 | val_frankfurt_000001_079206 260 | val_frankfurt_000001_080091 261 | val_frankfurt_000001_080391 262 | val_frankfurt_000001_080830 263 | val_frankfurt_000001_082087 264 | val_frankfurt_000001_082466 265 | val_frankfurt_000001_083029 266 | val_frankfurt_000001_083199 267 | val_frankfurt_000001_083852 268 | val_lindau_000000_000019 269 | val_lindau_000001_000019 270 | val_lindau_000002_000019 271 | val_lindau_000003_000019 272 | val_lindau_000004_000019 273 | val_lindau_000005_000019 274 | val_lindau_000006_000019 275 | val_lindau_000007_000019 276 | val_lindau_000008_000019 277 | val_lindau_000009_000019 278 | val_lindau_000010_000019 279 | val_lindau_000011_000019 280 | val_lindau_000012_000019 281 | val_lindau_000013_000019 282 | val_lindau_000014_000019 283 | val_lindau_000015_000019 284 | val_lindau_000016_000019 285 | val_lindau_000017_000019 286 | val_lindau_000018_000019 287 | val_lindau_000019_000019 288 | val_lindau_000020_000019 289 | val_lindau_000021_000019 290 | val_lindau_000022_000019 291 | val_lindau_000023_000019 292 | val_lindau_000024_000019 293 | val_lindau_000025_000019 294 | val_lindau_000026_000019 295 | val_lindau_000027_000019 296 | val_lindau_000028_000019 297 | val_lindau_000029_000019 298 | val_lindau_000030_000019 299 | val_lindau_000031_000019 300 | val_lindau_000032_000019 301 | val_lindau_000033_000019 302 | val_lindau_000034_000019 303 | val_lindau_000035_000019 304 | val_lindau_000036_000019 305 | val_lindau_000037_000019 306 | val_lindau_000038_000019 307 | val_lindau_000039_000019 308 | val_lindau_000040_000019 309 | val_lindau_000041_000019 310 | val_lindau_000042_000019 311 | val_lindau_000043_000019 312 | val_lindau_000044_000019 313 | val_lindau_000045_000019 314 | val_lindau_000046_000019 315 | val_lindau_000047_000019 316 | val_lindau_000048_000019 317 | val_lindau_000049_000019 318 | val_lindau_000050_000019 319 | val_lindau_000051_000019 320 | val_lindau_000052_000019 321 | val_lindau_000053_000019 322 | val_lindau_000054_000019 323 | val_lindau_000055_000019 324 | val_lindau_000056_000019 325 | val_lindau_000057_000019 326 | val_lindau_000058_000019 327 | val_munster_000000_000019 328 | val_munster_000001_000019 329 | val_munster_000002_000019 330 | val_munster_000003_000019 331 | val_munster_000004_000019 332 | val_munster_000005_000019 333 | val_munster_000006_000019 334 | val_munster_000007_000019 335 | val_munster_000008_000019 336 | val_munster_000009_000019 337 | val_munster_000010_000019 338 | val_munster_000011_000019 339 | val_munster_000012_000019 340 | val_munster_000013_000019 341 | val_munster_000014_000019 342 | val_munster_000015_000019 343 | val_munster_000016_000019 344 | val_munster_000017_000019 345 | val_munster_000018_000019 346 | val_munster_000019_000019 347 | val_munster_000020_000019 348 | val_munster_000021_000019 349 | val_munster_000022_000019 350 | val_munster_000023_000019 351 | val_munster_000024_000019 352 | val_munster_000025_000019 353 | val_munster_000026_000019 354 | val_munster_000027_000019 355 | val_munster_000028_000019 356 | val_munster_000029_000019 357 | val_munster_000030_000019 358 | val_munster_000031_000019 359 | val_munster_000032_000019 360 | val_munster_000033_000019 361 | val_munster_000034_000019 362 | val_munster_000035_000019 363 | val_munster_000036_000019 364 | val_munster_000037_000019 365 | val_munster_000038_000019 366 | val_munster_000039_000019 367 | val_munster_000040_000019 368 | val_munster_000041_000019 369 | val_munster_000042_000019 370 | val_munster_000043_000019 371 | val_munster_000044_000019 372 | val_munster_000045_000019 373 | val_munster_000046_000019 374 | val_munster_000047_000019 375 | val_munster_000048_000019 376 | val_munster_000049_000019 377 | val_munster_000050_000019 378 | val_munster_000051_000019 379 | val_munster_000052_000019 380 | val_munster_000053_000019 381 | val_munster_000054_000019 382 | val_munster_000055_000019 383 | val_munster_000056_000019 384 | val_munster_000057_000019 385 | val_munster_000058_000019 386 | val_munster_000059_000019 387 | val_munster_000060_000019 388 | val_munster_000061_000019 389 | val_munster_000062_000019 390 | val_munster_000063_000019 391 | val_munster_000064_000019 392 | val_munster_000065_000019 393 | val_munster_000066_000019 394 | val_munster_000067_000019 395 | val_munster_000068_000019 396 | val_munster_000069_000019 397 | val_munster_000070_000019 398 | val_munster_000071_000019 399 | val_munster_000072_000019 400 | val_munster_000073_000019 401 | val_munster_000074_000019 402 | val_munster_000075_000019 403 | val_munster_000076_000019 404 | val_munster_000077_000019 405 | val_munster_000078_000019 406 | val_munster_000079_000019 407 | val_munster_000080_000019 408 | val_munster_000081_000019 409 | val_munster_000082_000019 410 | val_munster_000083_000019 411 | val_munster_000084_000019 412 | val_munster_000085_000019 413 | val_munster_000086_000019 414 | val_munster_000087_000019 415 | val_munster_000088_000019 416 | val_munster_000089_000019 417 | val_munster_000090_000019 418 | val_munster_000091_000019 419 | val_munster_000092_000019 420 | val_munster_000093_000019 421 | val_munster_000094_000019 422 | val_munster_000095_000019 423 | val_munster_000096_000019 424 | val_munster_000097_000019 425 | val_munster_000098_000019 426 | val_munster_000099_000019 427 | val_munster_000100_000019 428 | val_munster_000101_000019 429 | val_munster_000102_000019 430 | val_munster_000103_000019 431 | val_munster_000104_000019 432 | val_munster_000105_000019 433 | val_munster_000106_000019 434 | val_munster_000107_000019 435 | val_munster_000108_000019 436 | val_munster_000109_000019 437 | val_munster_000110_000019 438 | val_munster_000111_000019 439 | val_munster_000112_000019 440 | val_munster_000113_000019 441 | val_munster_000114_000019 442 | val_munster_000115_000019 443 | val_munster_000116_000019 444 | val_munster_000117_000019 445 | val_munster_000118_000019 446 | val_munster_000119_000019 447 | val_munster_000120_000019 448 | val_munster_000121_000019 449 | val_munster_000122_000019 450 | val_munster_000123_000019 451 | val_munster_000124_000019 452 | val_munster_000125_000019 453 | val_munster_000126_000019 454 | val_munster_000127_000019 455 | val_munster_000128_000019 456 | val_munster_000129_000019 457 | val_munster_000130_000019 458 | val_munster_000131_000019 459 | val_munster_000132_000019 460 | val_munster_000133_000019 461 | val_munster_000134_000019 462 | val_munster_000135_000019 463 | val_munster_000136_000019 464 | val_munster_000137_000019 465 | val_munster_000138_000019 466 | val_munster_000139_000019 467 | val_munster_000140_000019 468 | val_munster_000141_000019 469 | val_munster_000142_000019 470 | val_munster_000143_000019 471 | val_munster_000144_000019 472 | val_munster_000145_000019 473 | val_munster_000146_000019 474 | val_munster_000147_000019 475 | val_munster_000148_000019 476 | val_munster_000149_000019 477 | val_munster_000150_000019 478 | val_munster_000151_000019 479 | val_munster_000152_000019 480 | val_munster_000153_000019 481 | val_munster_000154_000019 482 | val_munster_000155_000019 483 | val_munster_000156_000019 484 | val_munster_000157_000019 485 | val_munster_000158_000019 486 | val_munster_000159_000019 487 | val_munster_000160_000019 488 | val_munster_000161_000019 489 | val_munster_000162_000019 490 | val_munster_000163_000019 491 | val_munster_000164_000019 492 | val_munster_000165_000019 493 | val_munster_000166_000019 494 | val_munster_000167_000019 495 | val_munster_000168_000019 496 | val_munster_000169_000019 497 | val_munster_000170_000019 498 | val_munster_000171_000019 499 | val_munster_000172_000019 500 | val_munster_000173_000019 501 | -------------------------------------------------------------------------------- /datasets/cityscapes: -------------------------------------------------------------------------------- 1 | /home/luke/machine-learning-datasets/semantic-segmentation/cityscapes -------------------------------------------------------------------------------- /datasets/cityscapes_Dataset.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import random 3 | from collections.abc import Iterable 4 | from PIL import Image, ImageOps, ImageFilter, ImageFile 5 | import numpy as np 6 | import os 7 | import torch 8 | import torch.utils.data as data 9 | 10 | 11 | ImageFile.LOAD_TRUNCATED_IMAGES = True 12 | 13 | IMG_MEAN = np.array((104.00698793, 116.66876762, 14 | 122.67891434), dtype=np.float32) 15 | NUM_CLASSES = 19 16 | 17 | # For visualization 18 | label_colours = list(map(tuple, [ 19 | [128, 64, 128], 20 | [244, 35, 232], 21 | [70, 70, 70], 22 | [102, 102, 156], 23 | [190, 153, 153], 24 | [153, 153, 153], 25 | [250, 170, 30], 26 | [220, 220, 0], 27 | [107, 142, 35], 28 | [152, 251, 152], 29 | [0, 130, 180], 30 | [220, 20, 60], 31 | [255, 0, 0], 32 | [0, 0, 142], 33 | [0, 0, 70], 34 | [0, 60, 100], 35 | [0, 80, 100], 36 | [0, 0, 230], 37 | [119, 11, 32], 38 | [0, 0, 0], # the color of ignored label 39 | ])) 40 | 41 | # Labels 42 | ignore_label = -1 43 | cityscapes_id_to_trainid = { 44 | -1: ignore_label, 45 | 0: ignore_label, 46 | 1: ignore_label, 47 | 2: ignore_label, 48 | 3: ignore_label, 49 | 4: ignore_label, 50 | 5: ignore_label, 51 | 6: ignore_label, 52 | 7: 0, 53 | 8: 1, 54 | 9: ignore_label, 55 | 10: ignore_label, 56 | 11: 2, 57 | 12: 3, 58 | 13: 4, 59 | 14: ignore_label, 60 | 15: ignore_label, 61 | 16: ignore_label, 62 | 17: 5, 63 | 18: ignore_label, 64 | 19: 6, 65 | 20: 7, 66 | 21: 8, 67 | 22: 9, 68 | 23: 10, 69 | 24: 11, 70 | 25: 12, 71 | 26: 13, 72 | 27: 14, 73 | 28: 15, 74 | 29: ignore_label, 75 | 30: ignore_label, 76 | 31: 16, 77 | 32: 17, 78 | 33: 18 79 | } 80 | 81 | # Names 82 | name_classes = [ 83 | 'road', 84 | 'sidewalk', 85 | 'building', 86 | 'wall', 87 | 'fence', 88 | 'pole', 89 | 'trafflight', 90 | 'traffsign', 91 | 'vegetation', 92 | 'terrain', 93 | 'sky', 94 | 'person', 95 | 'rider', 96 | 'car', 97 | 'truck', 98 | 'bus', 99 | 'train', 100 | 'motorcycle', 101 | 'bicycle', 102 | 'unlabeled' 103 | ] 104 | 105 | 106 | def to_tuple(x): 107 | return x if isinstance(x, Iterable) else (x, x) 108 | 109 | 110 | class City_Dataset(data.Dataset): 111 | def __init__( 112 | self, 113 | root, 114 | list_path, 115 | split='train', 116 | base_size=769, 117 | crop_size=769, 118 | training=True, 119 | random_mirror=False, 120 | random_crop=False, 121 | resize=False, 122 | gaussian_blur=False, 123 | class_16=False, 124 | class_13=False, 125 | ): 126 | self.data_path = root 127 | self.list_path = list_path 128 | self.split = split 129 | self.base_size = to_tuple(base_size) 130 | self.crop_size = to_tuple(crop_size) 131 | self.training = training 132 | 133 | # Augmentations 134 | self.random_mirror = random_mirror 135 | self.random_crop = random_crop 136 | self.resize = resize 137 | self.gaussian_blur = gaussian_blur 138 | 139 | # Files 140 | item_list_filepath = os.path.join(self.list_path, self.split + ".txt") 141 | if not os.path.exists(item_list_filepath): 142 | raise Warning("split must be train/val/trainval") 143 | self.image_filepath = os.path.join(self.data_path, "leftImg8bit") 144 | self.gt_filepath = os.path.join(self.data_path, "gtFine") 145 | self.items = [id.strip() for id in open(item_list_filepath)] 146 | self.id_to_trainid = cityscapes_id_to_trainid 147 | 148 | # In SYNTHIA-to-Cityscapes case, only consider 16 shared classes 149 | self.class_16 = class_16 150 | synthia_set_16 = [0, 1, 2, 3, 4, 5, 6, 151 | 7, 8, 10, 11, 12, 13, 15, 17, 18] 152 | self.trainid_to_16id = {id: i for i, id in enumerate(synthia_set_16)} 153 | 154 | # In Cityscapes-to-NTHU case, only consider 13 shared classes 155 | self.class_13 = class_13 156 | synthia_set_13 = [0, 1, 2, 6, 7, 8, 10, 11, 12, 13, 15, 17, 18] 157 | self.trainid_to_13id = {id: i for i, id in enumerate(synthia_set_13)} 158 | 159 | print("{} num images in Cityscapes {} set have been loaded.".format( 160 | len(self.items), self.split)) 161 | 162 | def id2trainId(self, label, reverse=False, ignore_label=-1): 163 | label_copy = ignore_label * np.ones(label.shape, dtype=np.float32) 164 | for k, v in self.id_to_trainid.items(): 165 | label_copy[label == k] = v 166 | if self.class_16: 167 | label_copy_16 = ignore_label * \ 168 | np.ones(label.shape, dtype=np.float32) 169 | for k, v in self.trainid_to_16id.items(): 170 | label_copy_16[label_copy == k] = v 171 | label_copy = label_copy_16 172 | if self.class_13: 173 | label_copy_13 = ignore_label * \ 174 | np.ones(label.shape, dtype=np.float32) 175 | for k, v in self.trainid_to_13id.items(): 176 | label_copy_13[label_copy == k] = v 177 | label_copy = label_copy_13 178 | return label_copy 179 | 180 | def __getitem__(self, item): 181 | id = self.items[item] 182 | filename = id.split("train_")[-1].split("val_")[-1].split("test_")[-1] 183 | image_filepath = os.path.join( 184 | self.image_filepath, id.split("_")[0], id.split("_")[1]) 185 | image_filename = filename + "_leftImg8bit.png" 186 | image_path = os.path.join(image_filepath, image_filename) 187 | image = Image.open(image_path).convert("RGB") 188 | 189 | gt_filepath = os.path.join( 190 | self.gt_filepath, id.split("_")[0], id.split("_")[1]) 191 | gt_filename = filename + "_gtFine_labelIds.png" 192 | gt_image_path = os.path.join(gt_filepath, gt_filename) 193 | gt_image = Image.open(gt_image_path) 194 | 195 | if (self.split == "train" or self.split == "trainval") and self.training: 196 | image, gt_image = self._train_sync_transform(image, gt_image) 197 | return image, gt_image, item 198 | else: 199 | image, gt_image = self._val_sync_transform(image, gt_image) 200 | return image, gt_image, image_path 201 | 202 | def _train_sync_transform(self, img, mask): 203 | ''' 204 | :param image: PIL input image 205 | :param gt_image: PIL input gt_image 206 | :return: 207 | ''' 208 | if self.random_mirror: 209 | # random mirror 210 | if random.random() < 0.5: 211 | img = img.transpose(Image.FLIP_LEFT_RIGHT) 212 | if mask: 213 | mask = mask.transpose(Image.FLIP_LEFT_RIGHT) 214 | crop_w, crop_h = self.crop_size 215 | 216 | if self.random_crop: 217 | # random scale 218 | base_w, base_h = self.base_size 219 | w, h = img.size 220 | assert w >= h 221 | if (base_w / w) > (base_h / h): 222 | base_size = base_w 223 | short_size = random.randint( 224 | int(base_size * 0.5), int(base_size * 2.0)) 225 | ow = short_size 226 | oh = int(1.0 * h * ow / w) 227 | else: 228 | base_size = base_h 229 | short_size = random.randint( 230 | int(base_size * 0.5), int(base_size * 2.0)) 231 | oh = short_size 232 | ow = int(1.0 * w * oh / h) 233 | 234 | img = img.resize((ow, oh), Image.BICUBIC) 235 | if mask: 236 | mask = mask.resize((ow, oh), Image.NEAREST) 237 | # pad crop 238 | if ow < crop_w or oh < crop_h: 239 | padh = crop_h - oh if oh < crop_h else 0 240 | padw = crop_w - ow if ow < crop_w else 0 241 | img = ImageOps.expand(img, border=(0, 0, padw, padh), fill=0) 242 | if mask: 243 | mask = ImageOps.expand( 244 | mask, border=(0, 0, padw, padh), fill=0) 245 | # random crop crop_size 246 | w, h = img.size 247 | x1 = random.randint(0, w - crop_w) 248 | y1 = random.randint(0, h - crop_h) 249 | img = img.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 250 | if mask: 251 | mask = mask.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 252 | elif self.resize: 253 | img = img.resize(self.crop_size, Image.BICUBIC) 254 | if mask: 255 | mask = mask.resize(self.crop_size, Image.NEAREST) 256 | 257 | if self.gaussian_blur: 258 | # gaussian blur as in PSP 259 | if random.random() < 0.5: 260 | img = img.filter(ImageFilter.GaussianBlur( 261 | radius=random.random())) 262 | # final transform 263 | if mask: 264 | img, mask = self._img_transform(img), self._mask_transform(mask) 265 | return img, mask 266 | else: 267 | img = self._img_transform(img) 268 | return img 269 | 270 | def _val_sync_transform(self, img, mask): 271 | if self.random_crop: 272 | crop_w, crop_h = self.crop_size 273 | w, h = img.size 274 | if crop_w / w < crop_h / h: 275 | oh = crop_h 276 | ow = int(1.0 * w * oh / h) 277 | else: 278 | ow = crop_w 279 | oh = int(1.0 * h * ow / w) 280 | img = img.resize((ow, oh), Image.BICUBIC) 281 | mask = mask.resize((ow, oh), Image.NEAREST) 282 | # center crop 283 | w, h = img.size 284 | x1 = int(round((w - crop_w) / 2.)) 285 | y1 = int(round((h - crop_h) / 2.)) 286 | img = img.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 287 | mask = mask.crop((x1, y1, x1 + crop_w, y1 + crop_h)) 288 | elif self.resize: 289 | img = img.resize(self.crop_size, Image.BICUBIC) 290 | mask = mask.resize(self.crop_size, Image.NEAREST) 291 | 292 | # final transform 293 | img, mask = self._img_transform(img), self._mask_transform(mask) 294 | return img, mask 295 | 296 | def _img_transform(self, image): 297 | # if self.args.numpy_transform: 298 | image = np.asarray(image, np.float32) 299 | image = image[:, :, ::-1] # change to BGR 300 | image -= IMG_MEAN 301 | image = image.transpose((2, 0, 1)).copy() # (C x H x W) 302 | new_image = torch.from_numpy(image) 303 | # else: 304 | # image_transforms = ttransforms.Compose([ 305 | # ttransforms.ToTensor(), 306 | # ttransforms.Normalize([.485, .456, .406], [.229, .224, .225]), 307 | # ]) 308 | # new_image = image_transforms(image) 309 | return new_image 310 | 311 | def _mask_transform(self, gt_image): 312 | target = np.asarray(gt_image, np.float32) 313 | target = self.id2trainId(target).copy() 314 | target = torch.from_numpy(target) 315 | 316 | return target 317 | 318 | def __len__(self): 319 | return len(self.items) 320 | 321 | 322 | def flip(x, dim): 323 | dim = x.dim() + dim if dim < 0 else dim 324 | inds = tuple(slice(None, None) if i != dim 325 | else x.new(torch.arange(x.size(i) - 1, -1, -1).tolist()).long() 326 | for i in range(x.dim())) 327 | return x[inds] 328 | 329 | 330 | def inv_preprocess(imgs, num_images=1, img_mean=IMG_MEAN, numpy_transform=False): 331 | """Inverse preprocessing of the batch of images. 332 | 333 | Args: 334 | imgs: batch of input images. 335 | num_images: number of images to apply the inverse transformations on. 336 | img_mean: vector of mean colour values. 337 | numpy_transform: whether change RGB to BGR during img_transform. 338 | 339 | Returns: 340 | The batch of the size num_images with the same spatial dimensions as the input. 341 | """ 342 | if numpy_transform: 343 | imgs = flip(imgs, 1) 344 | 345 | def norm_ip(img, min, max): 346 | img.clamp_(min=min, max=max) 347 | img.add_(-min).div_(max - min + 1e-5) 348 | norm_ip(imgs, float(imgs.min()), float(imgs.max())) 349 | return imgs 350 | 351 | 352 | def decode_labels(mask, num_images=1, num_classes=NUM_CLASSES): 353 | """Decode batch of segmentation masks. 354 | 355 | Args: 356 | mask: result of inference after taking argmax. 357 | num_images: number of images to decode from the batch. 358 | num_classes: number of classes to predict. 359 | 360 | Returns: 361 | A batch with num_images RGB images of the same size as the input. 362 | """ 363 | if isinstance(mask, torch.Tensor): 364 | mask = mask.data.cpu().numpy() 365 | n, h, w = mask.shape 366 | if n < num_images: 367 | num_images = n 368 | outputs = np.zeros((num_images, h, w, 3), dtype=np.uint8) 369 | for i in range(num_images): 370 | img = Image.new('RGB', (len(mask[i, 0]), len(mask[i]))) 371 | pixels = img.load() 372 | for j_, j in enumerate(mask[i, :, :]): 373 | for k_, k in enumerate(j): 374 | if k < num_classes: 375 | pixels[k_, j_] = label_colours[k] 376 | outputs[i] = np.array(img) 377 | return torch.from_numpy(outputs.transpose([0, 3, 1, 2]).astype('float32')).div_(255.0) 378 | 379 | 380 | def inspect_decode_labels(pred, num_images=1, num_classes=NUM_CLASSES, 381 | inspect_split=[0.9, 0.8, 0.7, 0.5, 0.0], inspect_ratio=[1.0, 0.8, 0.6, 0.3]): 382 | """Decode batch of segmentation masks accroding to the prediction probability. 383 | 384 | Args: 385 | pred: result of inference. 386 | num_images: number of images to decode from the batch. 387 | num_classes: number of classes to predict (including background). 388 | inspect_split: probability between different split has different brightness. 389 | 390 | Returns: 391 | A batch with num_images RGB images of the same size as the input. 392 | """ 393 | if isinstance(pred, torch.Tensor): 394 | pred = pred.data.cpu().numpy() 395 | n, c, h, w = pred.shape 396 | pred = pred.transpose([0, 2, 3, 1]) 397 | if n < num_images: 398 | num_images = n 399 | outputs = np.zeros((num_images, h, w, 3), dtype=np.uint8) 400 | for i in range(num_images): 401 | img = Image.new('RGB', (w, h)) 402 | pixels = img.load() 403 | for j_, j in enumerate(pred[i, :, :, :]): 404 | for k_, k in enumerate(j): 405 | assert k.shape[0] == num_classes 406 | k_value = np.max(softmax(k)) 407 | k_class = np.argmax(k) 408 | for it, iv in enumerate(inspect_split): 409 | if k_value > iv: 410 | break 411 | if iv > 0: 412 | pixels[k_, j_] = tuple( 413 | map(lambda x: int(inspect_ratio[it] * x), label_colours[k_class])) 414 | outputs[i] = np.array(img) 415 | return torch.from_numpy(outputs.transpose([0, 3, 1, 2]).astype('float32')).div_(255.0) 416 | 417 | 418 | class DemoVideo_City_Dataset(City_Dataset): 419 | def __init__(self, *args, **kwargs): 420 | super().__init__(*args, **kwargs) 421 | assert self.split == 'demoVideo' 422 | 423 | def __getitem__(self, item): 424 | id = self.items[item] 425 | folder = '_'.join(id.split('_')[:2]) 426 | filename = '_'.join(id.split('_')[2:]) 427 | image_filename = folder + '_' + filename + "_leftImg8bit.png" 428 | image_path = os.path.join(self.image_filepath, 'demoVideo', folder, image_filename) 429 | image = Image.open(image_path).convert("RGB") 430 | image, _ = self._val_sync_transform(image, image) 431 | return image, image_path, item 432 | -------------------------------------------------------------------------------- /datasets/gta5_Dataset.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from PIL import Image, ImageFile 3 | import os 4 | import torch 5 | from datasets.cityscapes_Dataset import City_Dataset, to_tuple 6 | 7 | ImageFile.LOAD_TRUNCATED_IMAGES = True 8 | 9 | 10 | class GTA5_Dataset(City_Dataset): 11 | def __init__( 12 | self, 13 | root='./datasets/GTA5', 14 | list_path='./datasets/GTA5/list', 15 | split='train', 16 | base_size=769, 17 | crop_size=769, 18 | training=True, 19 | random_mirror=False, 20 | random_crop=False, 21 | resize=False, 22 | gaussian_blur=False, 23 | class_16=False 24 | ): 25 | 26 | # Args 27 | self.data_path = root 28 | self.list_path = list_path 29 | self.split = split 30 | self.base_size = to_tuple(base_size) 31 | self.crop_size = to_tuple(crop_size) 32 | self.training = training 33 | self.class_16 = False 34 | self.class_13 = False 35 | assert class_16 == False 36 | 37 | # Augmentation 38 | self.random_mirror = random_mirror 39 | self.random_crop = random_crop 40 | self.resize = resize 41 | self.gaussian_blur = gaussian_blur 42 | 43 | # Files 44 | item_list_filepath = os.path.join(self.list_path, self.split + ".txt") 45 | if not os.path.exists(item_list_filepath): 46 | raise Warning("split must be train/val/trainval/test/all") 47 | self.image_filepath = os.path.join(self.data_path, "images") 48 | self.gt_filepath = os.path.join(self.data_path, "labels") 49 | self.items = [id.strip() for id in open(item_list_filepath)] 50 | 51 | # Label map 52 | self.id_to_trainid = { 53 | 7: 0, 8: 1, 11: 2, 12: 3, 13: 4, 17: 5, 19: 6, 20: 7, 21: 8, 54 | 22: 9, 23: 10, 24: 11, 25: 12, 26: 13, 27: 14, 28: 15, 31: 16, 32: 17, 33: 18 55 | } 56 | 57 | # Print 58 | print("{} num images in GTA5 {} set have been loaded.".format( 59 | len(self.items), self.split)) 60 | 61 | def __getitem__(self, item): 62 | id = int(self.items[item]) 63 | name = f"{id:0>5d}.png" 64 | 65 | # Open image and label 66 | image_path = os.path.join(self.image_filepath, name) 67 | gt_image_path = os.path.join(self.gt_filepath, name) 68 | image = Image.open(image_path).convert("RGB") 69 | gt_image = Image.open(gt_image_path) 70 | 71 | # Augmentation 72 | if (self.split == "train" or self.split == "trainval" or self.split == "all") and self.training: 73 | image, gt_image = self._train_sync_transform(image, gt_image) 74 | else: 75 | image, gt_image = self._val_sync_transform(image, gt_image) 76 | return image, gt_image, item 77 | -------------------------------------------------------------------------------- /datasets/synscapes_list/val.txt: -------------------------------------------------------------------------------- 1 | 625.png 2 | 24402.png 3 | 22354.png 4 | 22877.png 5 | 24144.png 6 | 10669.png 7 | 14719.png 8 | 942.png 9 | 19945.png 10 | 19143.png 11 | 2212.png 12 | 20783.png 13 | 23564.png 14 | 23656.png 15 | 9258.png 16 | 2655.png 17 | 308.png 18 | 23057.png 19 | 11591.png 20 | 22758.png 21 | 15199.png 22 | 2542.png 23 | 20730.png 24 | 14787.png 25 | 1785.png 26 | 13959.png 27 | 21657.png 28 | 2857.png 29 | 20440.png 30 | 530.png 31 | 12440.png 32 | 5795.png 33 | 9212.png 34 | 94.png 35 | 8420.png 36 | 14982.png 37 | 10138.png 38 | 1916.png 39 | 14642.png 40 | 6806.png 41 | 24236.png 42 | 3897.png 43 | 9483.png 44 | 18623.png 45 | 23393.png 46 | 9554.png 47 | 1792.png 48 | 10804.png 49 | 18716.png 50 | 14638.png 51 | 7810.png 52 | 17576.png 53 | 5745.png 54 | 499.png 55 | 6872.png 56 | 23604.png 57 | 17271.png 58 | 19884.png 59 | 8768.png 60 | 7248.png 61 | 24910.png 62 | 6722.png 63 | 237.png 64 | 4848.png 65 | 674.png 66 | 5407.png 67 | 20805.png 68 | 16634.png 69 | 2601.png 70 | 12787.png 71 | 23329.png 72 | 7174.png 73 | 5204.png 74 | 16341.png 75 | 7040.png 76 | 11728.png 77 | 10888.png 78 | 6069.png 79 | 12248.png 80 | 16487.png 81 | 888.png 82 | 1583.png 83 | 16366.png 84 | 8832.png 85 | 731.png 86 | 14720.png 87 | 3907.png 88 | 23593.png 89 | 3819.png 90 | 15208.png 91 | 19876.png 92 | 15658.png 93 | 12926.png 94 | 7744.png 95 | 17802.png 96 | 23754.png 97 | 14831.png 98 | 24086.png 99 | 1733.png 100 | 10943.png 101 | 23998.png 102 | 623.png 103 | 21675.png 104 | 23972.png 105 | 18415.png 106 | 719.png 107 | 4674.png 108 | 7572.png 109 | 16620.png 110 | 5810.png 111 | 1156.png 112 | 21803.png 113 | 13681.png 114 | 24386.png 115 | 21148.png 116 | 14939.png 117 | 23759.png 118 | 1745.png 119 | 14190.png 120 | 16973.png 121 | 538.png 122 | 18555.png 123 | 14611.png 124 | 20297.png 125 | 15763.png 126 | 2109.png 127 | 14841.png 128 | 14550.png 129 | 6592.png 130 | 10345.png 131 | 21164.png 132 | 22404.png 133 | 18318.png 134 | 11625.png 135 | 19101.png 136 | 6887.png 137 | 22469.png 138 | 4665.png 139 | 21303.png 140 | 24657.png 141 | 11579.png 142 | 12138.png 143 | 13175.png 144 | 6388.png 145 | 4222.png 146 | 9322.png 147 | 15209.png 148 | 19774.png 149 | 21158.png 150 | 23279.png 151 | 11150.png 152 | 10382.png 153 | 17033.png 154 | 14310.png 155 | 1848.png 156 | 9238.png 157 | 19958.png 158 | 24582.png 159 | 10182.png 160 | 14956.png 161 | 10891.png 162 | 23144.png 163 | 18803.png 164 | 2621.png 165 | 18805.png 166 | 16307.png 167 | 18185.png 168 | 20715.png 169 | 14015.png 170 | 21513.png 171 | 14028.png 172 | 14464.png 173 | 13970.png 174 | 22046.png 175 | 801.png 176 | 5099.png 177 | 20293.png 178 | 16177.png 179 | 6821.png 180 | 7511.png 181 | 7513.png 182 | 5528.png 183 | 24197.png 184 | 19427.png 185 | 22409.png 186 | 23227.png 187 | 673.png 188 | 19451.png 189 | 21652.png 190 | 8647.png 191 | 16291.png 192 | 5832.png 193 | 5071.png 194 | 22390.png 195 | 17061.png 196 | 1548.png 197 | 686.png 198 | 13918.png 199 | 292.png 200 | 14390.png 201 | 2610.png 202 | 24176.png 203 | 3657.png 204 | 21356.png 205 | 23674.png 206 | 6794.png 207 | 8466.png 208 | 7373.png 209 | 23263.png 210 | 21837.png 211 | 14855.png 212 | 18767.png 213 | 4876.png 214 | 24873.png 215 | 24958.png 216 | 17182.png 217 | 17953.png 218 | 13638.png 219 | 16844.png 220 | 12683.png 221 | 22099.png 222 | 11507.png 223 | 24349.png 224 | 9676.png 225 | 1703.png 226 | 18769.png 227 | 14633.png 228 | 8703.png 229 | 18316.png 230 | 6844.png 231 | 1395.png 232 | 16530.png 233 | 4767.png 234 | 6491.png 235 | 3620.png 236 | 891.png 237 | 7546.png 238 | 24671.png 239 | 20779.png 240 | 5224.png 241 | 22903.png 242 | 5250.png 243 | 8684.png 244 | 8856.png 245 | 15989.png 246 | 23024.png 247 | 19152.png 248 | 17355.png 249 | 5653.png 250 | 19128.png 251 | 6265.png 252 | 8974.png 253 | 3545.png 254 | 5374.png 255 | 16191.png 256 | 2335.png 257 | 2475.png 258 | 6990.png 259 | 3516.png 260 | 6340.png 261 | 22926.png 262 | 9444.png 263 | 15898.png 264 | 11871.png 265 | 3812.png 266 | 23223.png 267 | 6676.png 268 | 24132.png 269 | 6198.png 270 | 9107.png 271 | 652.png 272 | 21946.png 273 | 17673.png 274 | 22624.png 275 | 24694.png 276 | 5380.png 277 | 2498.png 278 | 20378.png 279 | 4530.png 280 | 5221.png 281 | 16496.png 282 | 14296.png 283 | 19458.png 284 | 21634.png 285 | 12834.png 286 | 14628.png 287 | 2441.png 288 | 4758.png 289 | 11865.png 290 | 79.png 291 | 23265.png 292 | 21599.png 293 | 6815.png 294 | 17566.png 295 | 1723.png 296 | 12819.png 297 | 8836.png 298 | 11198.png 299 | 5725.png 300 | 16853.png 301 | 24734.png 302 | 3104.png 303 | 16438.png 304 | 17047.png 305 | 16087.png 306 | 24688.png 307 | 378.png 308 | 27.png 309 | 4605.png 310 | 5531.png 311 | 13957.png 312 | 4746.png 313 | 5173.png 314 | 24746.png 315 | 21455.png 316 | 20539.png 317 | 21802.png 318 | 24166.png 319 | 17808.png 320 | 14312.png 321 | 24904.png 322 | 21081.png 323 | 5827.png 324 | 204.png 325 | 10632.png 326 | 8781.png 327 | 21889.png 328 | 8310.png 329 | 16872.png 330 | 23033.png 331 | 11192.png 332 | 5505.png 333 | 21545.png 334 | 4231.png 335 | 15113.png 336 | 17602.png 337 | 17595.png 338 | 21870.png 339 | 17023.png 340 | 19539.png 341 | 20266.png 342 | 22568.png 343 | 13436.png 344 | 5036.png 345 | 20073.png 346 | 606.png 347 | 21099.png 348 | 1359.png 349 | 20099.png 350 | 9664.png 351 | 23297.png 352 | 23130.png 353 | 810.png 354 | 905.png 355 | 14600.png 356 | 14398.png 357 | 21575.png 358 | 17809.png 359 | 20524.png 360 | 18017.png 361 | 4131.png 362 | 21249.png 363 | 24901.png 364 | 11226.png 365 | 568.png 366 | 12563.png 367 | 16384.png 368 | 24803.png 369 | 24816.png 370 | 24854.png 371 | 19318.png 372 | 22019.png 373 | 37.png 374 | 20206.png 375 | 7944.png 376 | 16828.png 377 | 3213.png 378 | 22213.png 379 | 23136.png 380 | 16675.png 381 | 3451.png 382 | 20507.png 383 | 22163.png 384 | 17922.png 385 | 13245.png 386 | 23847.png 387 | 21785.png 388 | 7419.png 389 | 14090.png 390 | 622.png 391 | 8300.png 392 | 1382.png 393 | 21681.png 394 | 23479.png 395 | 18150.png 396 | 19567.png 397 | 8529.png 398 | 15741.png 399 | 13464.png 400 | 10494.png 401 | 16395.png 402 | 20201.png 403 | 1429.png 404 | 20806.png 405 | 22323.png 406 | 6292.png 407 | 12179.png 408 | 13935.png 409 | 1804.png 410 | 21869.png 411 | 15428.png 412 | 17191.png 413 | 3510.png 414 | 9435.png 415 | 9519.png 416 | 10630.png 417 | 17519.png 418 | 16873.png 419 | 17717.png 420 | 412.png 421 | 23345.png 422 | 7943.png 423 | 3390.png 424 | 7033.png 425 | 6432.png 426 | 1826.png 427 | 15927.png 428 | 6369.png 429 | 3913.png 430 | 12416.png 431 | 18539.png 432 | 12960.png 433 | 4079.png 434 | 5226.png 435 | 10636.png 436 | 629.png 437 | 21733.png 438 | 24697.png 439 | 24130.png 440 | 9937.png 441 | 14330.png 442 | 12143.png 443 | 12715.png 444 | 21076.png 445 | 14187.png 446 | 11658.png 447 | 15508.png 448 | 24925.png 449 | 12817.png 450 | 15405.png 451 | 15492.png 452 | 10757.png 453 | 16971.png 454 | 22140.png 455 | 4729.png 456 | 5963.png 457 | 8644.png 458 | 14942.png 459 | 20004.png 460 | 6627.png 461 | 6169.png 462 | 11950.png 463 | 7195.png 464 | 11531.png 465 | 6127.png 466 | 24237.png 467 | 2175.png 468 | 13747.png 469 | 18774.png 470 | 12513.png 471 | 9431.png 472 | 24001.png 473 | 20794.png 474 | 21379.png 475 | 20704.png 476 | 19744.png 477 | 7678.png 478 | 1318.png 479 | 18771.png 480 | 20612.png 481 | 13769.png 482 | 5006.png 483 | 8938.png 484 | 5088.png 485 | 21185.png 486 | 23129.png 487 | 9505.png 488 | 21324.png 489 | 14758.png 490 | 834.png 491 | 17087.png 492 | 11436.png 493 | 23413.png 494 | 2090.png 495 | 8689.png 496 | 24540.png 497 | 857.png 498 | 13678.png 499 | 24228.png 500 | 17526.png 501 | 13605.png 502 | 2834.png 503 | 21353.png 504 | 12623.png 505 | 2520.png 506 | 14101.png 507 | 15795.png 508 | 17283.png 509 | 6570.png 510 | 5976.png 511 | 4589.png 512 | 13035.png 513 | 3874.png 514 | 1553.png 515 | 4027.png 516 | 17007.png 517 | 15344.png 518 | 11671.png 519 | 14711.png 520 | 10715.png 521 | 2608.png 522 | 14109.png 523 | 18314.png 524 | 8475.png 525 | 14675.png 526 | 6723.png 527 | 24716.png 528 | 15184.png 529 | 17396.png 530 | 17250.png 531 | 24385.png 532 | 8147.png 533 | 20963.png 534 | 24497.png 535 | 12881.png 536 | 5179.png 537 | 15464.png 538 | 23139.png 539 | 16070.png 540 | 5252.png 541 | 5526.png 542 | 5552.png 543 | 1446.png 544 | 7093.png 545 | 11551.png 546 | 20828.png 547 | 13000.png 548 | 23712.png 549 | 13527.png 550 | 12157.png 551 | 1015.png 552 | 15641.png 553 | 22153.png 554 | 869.png 555 | 22299.png 556 | 19268.png 557 | 24878.png 558 | 3379.png 559 | 808.png 560 | 9613.png 561 | 14386.png 562 | 1161.png 563 | 5774.png 564 | 5098.png 565 | 20684.png 566 | 22173.png 567 | 15381.png 568 | 16437.png 569 | 5729.png 570 | 13945.png 571 | 22534.png 572 | 24331.png 573 | 7247.png 574 | 13340.png 575 | 13223.png 576 | 16656.png 577 | 24255.png 578 | 20353.png 579 | 19302.png 580 | 20233.png 581 | 16577.png 582 | 8697.png 583 | 13020.png 584 | 4236.png 585 | 23017.png 586 | 19502.png 587 | 404.png 588 | 17457.png 589 | 22720.png 590 | 5955.png 591 | 4207.png 592 | 8291.png 593 | 2123.png 594 | 4492.png 595 | 5358.png 596 | 6768.png 597 | 5700.png 598 | 14715.png 599 | 20457.png 600 | 13555.png 601 | 18723.png 602 | 20363.png 603 | 2895.png 604 | 4774.png 605 | 13179.png 606 | 1760.png 607 | 23911.png 608 | 11722.png 609 | 19815.png 610 | 21457.png 611 | 12209.png 612 | 6444.png 613 | 11001.png 614 | 24085.png 615 | 7885.png 616 | 24163.png 617 | 22762.png 618 | 11753.png 619 | 4469.png 620 | 13142.png 621 | 18001.png 622 | 4602.png 623 | 11077.png 624 | 6822.png 625 | 9141.png 626 | 10089.png 627 | 22590.png 628 | 4524.png 629 | 3980.png 630 | 23932.png 631 | 1775.png 632 | 11387.png 633 | 676.png 634 | 1299.png 635 | 287.png 636 | 23552.png 637 | 14347.png 638 | 4025.png 639 | 3281.png 640 | 10846.png 641 | 18567.png 642 | 183.png 643 | 20485.png 644 | 9926.png 645 | 6470.png 646 | 6626.png 647 | 18589.png 648 | 24809.png 649 | 9412.png 650 | 8584.png 651 | 11211.png 652 | 12958.png 653 | 8577.png 654 | 9501.png 655 | 1072.png 656 | 24011.png 657 | 4888.png 658 | 13009.png 659 | 23942.png 660 | 5961.png 661 | 3500.png 662 | 487.png 663 | 22921.png 664 | 23857.png 665 | 10523.png 666 | 17456.png 667 | 7252.png 668 | 6091.png 669 | 24512.png 670 | 19507.png 671 | 9547.png 672 | 14624.png 673 | 20844.png 674 | 19346.png 675 | 3542.png 676 | 19472.png 677 | 22245.png 678 | 17217.png 679 | 13616.png 680 | 21420.png 681 | 4509.png 682 | 22931.png 683 | 15755.png 684 | 20027.png 685 | 16932.png 686 | 13653.png 687 | 18904.png 688 | 17874.png 689 | 13928.png 690 | 4209.png 691 | 1830.png 692 | 1667.png 693 | 24341.png 694 | 15717.png 695 | 19586.png 696 | 24635.png 697 | 19315.png 698 | 17725.png 699 | 18006.png 700 | 19440.png 701 | 2101.png 702 | 22104.png 703 | 6793.png 704 | 7382.png 705 | 7590.png 706 | 20196.png 707 | 19929.png 708 | 2154.png 709 | 12701.png 710 | 10352.png 711 | 14950.png 712 | 15276.png 713 | 15139.png 714 | 22179.png 715 | 10852.png 716 | 879.png 717 | 4160.png 718 | 3724.png 719 | 19580.png 720 | 21833.png 721 | 4606.png 722 | 18397.png 723 | 1050.png 724 | 8243.png 725 | 10886.png 726 | 7599.png 727 | 19238.png 728 | 9216.png 729 | 17591.png 730 | 7327.png 731 | 17174.png 732 | 5569.png 733 | 1081.png 734 | 18900.png 735 | 8501.png 736 | 7637.png 737 | 23605.png 738 | 21102.png 739 | 8471.png 740 | 5005.png 741 | 21721.png 742 | 670.png 743 | 11228.png 744 | 1835.png 745 | 19987.png 746 | 13663.png 747 | 15173.png 748 | 10222.png 749 | 19674.png 750 | 16138.png 751 | 1507.png 752 | 13079.png 753 | 2641.png 754 | 9577.png 755 | 6151.png 756 | 20903.png 757 | 3586.png 758 | 20677.png 759 | 3721.png 760 | 5823.png 761 | 19647.png 762 | 4360.png 763 | 7594.png 764 | 10415.png 765 | 24503.png 766 | 12428.png 767 | 17200.png 768 | 13309.png 769 | 16655.png 770 | 2945.png 771 | 14767.png 772 | 18249.png 773 | 14240.png 774 | 16982.png 775 | 10071.png 776 | 9120.png 777 | 17629.png 778 | 17336.png 779 | 3748.png 780 | 18426.png 781 | 19145.png 782 | 14188.png 783 | 23358.png 784 | 5999.png 785 | 16327.png 786 | 2332.png 787 | 466.png 788 | 8267.png 789 | 13963.png 790 | 23211.png 791 | 1980.png 792 | 3964.png 793 | 9528.png 794 | 18909.png 795 | 6701.png 796 | 24813.png 797 | 19177.png 798 | 2603.png 799 | 8650.png 800 | 18990.png 801 | 19856.png 802 | 2830.png 803 | 3649.png 804 | 8187.png 805 | 23736.png 806 | 14783.png 807 | 7803.png 808 | 2606.png 809 | 4586.png 810 | 3150.png 811 | 2196.png 812 | 16129.png 813 | 16753.png 814 | 18412.png 815 | 8643.png 816 | 14913.png 817 | 17048.png 818 | 6061.png 819 | 16082.png 820 | 23655.png 821 | 20892.png 822 | 19322.png 823 | 9236.png 824 | 1810.png 825 | 12975.png 826 | 8457.png 827 | 20262.png 828 | 7540.png 829 | 13874.png 830 | 13213.png 831 | 12842.png 832 | 11513.png 833 | 6931.png 834 | 20850.png 835 | 4300.png 836 | 14247.png 837 | 12051.png 838 | 21905.png 839 | 21684.png 840 | 944.png 841 | 17508.png 842 | 5936.png 843 | 18852.png 844 | 16903.png 845 | 12141.png 846 | 15095.png 847 | 8233.png 848 | 12788.png 849 | 11393.png 850 | 6904.png 851 | 12073.png 852 | 15103.png 853 | 12221.png 854 | 15718.png 855 | 535.png 856 | 16690.png 857 | 21339.png 858 | 1808.png 859 | 12174.png 860 | 11577.png 861 | 10157.png 862 | 3008.png 863 | 11446.png 864 | 23718.png 865 | 22450.png 866 | 5129.png 867 | 6010.png 868 | 4682.png 869 | 11296.png 870 | 18753.png 871 | 23556.png 872 | 6457.png 873 | 18863.png 874 | 16236.png 875 | 14587.png 876 | 15374.png 877 | 2097.png 878 | 19594.png 879 | 9779.png 880 | 7925.png 881 | 7527.png 882 | 1556.png 883 | 12755.png 884 | 9999.png 885 | 19910.png 886 | 24181.png 887 | 6428.png 888 | 5153.png 889 | 17915.png 890 | 6929.png 891 | 20564.png 892 | 7258.png 893 | 486.png 894 | 16239.png 895 | 22802.png 896 | 17464.png 897 | 5458.png 898 | 21367.png 899 | 20280.png 900 | 21382.png 901 | 4500.png 902 | 6118.png 903 | 10287.png 904 | 12736.png 905 | 7057.png 906 | 3287.png 907 | 10858.png 908 | 16870.png 909 | 12734.png 910 | 1206.png 911 | 9041.png 912 | 18857.png 913 | 4638.png 914 | 14361.png 915 | 13703.png 916 | 7484.png 917 | 5759.png 918 | 9242.png 919 | 22999.png 920 | 13702.png 921 | 6040.png 922 | 13762.png 923 | 16281.png 924 | 7708.png 925 | 10064.png 926 | 12135.png 927 | 9596.png 928 | 10456.png 929 | 16976.png 930 | 16815.png 931 | 15990.png 932 | 9068.png 933 | 16535.png 934 | 18383.png 935 | 18682.png 936 | 10871.png 937 | 16981.png 938 | 205.png 939 | 22881.png 940 | 7706.png 941 | 7064.png 942 | 21874.png 943 | 6593.png 944 | 23331.png 945 | 6911.png 946 | 4298.png 947 | 14108.png 948 | 6445.png 949 | 9306.png 950 | 20713.png 951 | 22481.png 952 | 1856.png 953 | 8368.png 954 | 8241.png 955 | 1348.png 956 | 9601.png 957 | 6304.png 958 | 15093.png 959 | 10110.png 960 | 10139.png 961 | 20813.png 962 | 2138.png 963 | 2648.png 964 | 20895.png 965 | 11427.png 966 | 24609.png 967 | 13229.png 968 | 17688.png 969 | 12345.png 970 | 22954.png 971 | 7496.png 972 | 17979.png 973 | 6380.png 974 | 20725.png 975 | 704.png 976 | 15994.png 977 | 13029.png 978 | 21719.png 979 | 4078.png 980 | 13844.png 981 | 8640.png 982 | 2849.png 983 | 11319.png 984 | 8286.png 985 | 17704.png 986 | 13631.png 987 | 832.png 988 | 5958.png 989 | 4245.png 990 | 18066.png 991 | 858.png 992 | 10282.png 993 | 10821.png 994 | 21765.png 995 | 916.png 996 | 11823.png 997 | 4583.png 998 | 16730.png 999 | 11108.png 1000 | 9040.png 1001 | -------------------------------------------------------------------------------- /datasets/synthia_Dataset.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from PIL import Image 3 | import numpy as np 4 | import os 5 | import torch 6 | import imageio 7 | 8 | from datasets.cityscapes_Dataset import City_Dataset, to_tuple 9 | imageio.plugins.freeimage.download() 10 | 11 | synthia_set_16 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 15, 17, 18] 12 | 13 | 14 | class SYNTHIA_Dataset(City_Dataset): 15 | def __init__( 16 | self, 17 | root='./datasets/SYNTHIA', 18 | list_path='./datasets/SYNTHIA/list', 19 | split='train', 20 | base_size=769, 21 | crop_size=769, 22 | training=True, 23 | class_16=False, 24 | random_mirror=False, 25 | random_crop=False, 26 | resize=False, 27 | gaussian_blur=False, 28 | ): 29 | 30 | # Args 31 | self.data_path = root 32 | self.list_path = list_path 33 | self.split = split 34 | self.base_size = to_tuple(base_size) 35 | self.crop_size = to_tuple(crop_size) 36 | self.training = training 37 | 38 | # Augmentations 39 | self.random_mirror = random_mirror 40 | self.random_crop = random_crop 41 | self.resize = resize 42 | self.gaussian_blur = gaussian_blur 43 | 44 | # Files 45 | item_list_filepath = os.path.join(self.list_path, self.split + ".txt") 46 | if not os.path.exists(item_list_filepath): 47 | raise Warning("split must be train/val/trainavl/test") 48 | self.image_filepath = os.path.join(self.data_path, "RGB") 49 | self.gt_filepath = os.path.join(self.data_path, "GT/LABELS") 50 | self.items = [id.strip() for id in open(item_list_filepath)] 51 | 52 | # Label map 53 | self.id_to_trainid = { 54 | 1: 10, 2: 2, 3: 0, 4: 1, 5: 4, 6: 8, 7: 5, 8: 13, 9: 7, 10: 11, 11: 18, 55 | 12: 17, 15: 6, 16: 9, 17: 12, 18: 14, 19: 15, 20: 16, 21: 3 56 | } 57 | 58 | # Only consider 16 shared classes 59 | self.class_16 = class_16 60 | self.trainid_to_16id = {id: i for i, id in enumerate(synthia_set_16)} 61 | self.class_13 = False 62 | 63 | print("{} num images in SYNTHIA {} set have been loaded.".format( 64 | len(self.items), self.split)) 65 | 66 | def __getitem__(self, item): 67 | id = int(self.items[item]) 68 | name = f"{id:0>7d}.png" 69 | 70 | # Open image and label 71 | image_path = os.path.join(self.image_filepath, name) 72 | gt_image_path = os.path.join(self.gt_filepath, name) 73 | image = Image.open(image_path).convert("RGB") 74 | gt_image = imageio.imread(gt_image_path, format='PNG-FI')[:, :, 0] 75 | gt_image = Image.fromarray(np.uint8(gt_image)) 76 | 77 | # Augmentations 78 | if (self.split == "train" or self.split == "trainval" or self.split == "all") and self.training: 79 | image, gt_image = self._train_sync_transform(image, gt_image) 80 | else: 81 | image, gt_image = self._val_sync_transform(image, gt_image) 82 | return image, gt_image, item 83 | -------------------------------------------------------------------------------- /datasets/synthia_list/val.txt: -------------------------------------------------------------------------------- 1 | 9000 2 | 9001 3 | 9002 4 | 9003 5 | 9004 6 | 9005 7 | 9006 8 | 9007 9 | 9008 10 | 9009 11 | 9010 12 | 9011 13 | 9012 14 | 9013 15 | 9014 16 | 9015 17 | 9016 18 | 9017 19 | 9018 20 | 9019 21 | 9020 22 | 9021 23 | 9022 24 | 9023 25 | 9024 26 | 9025 27 | 9026 28 | 9027 29 | 9028 30 | 9029 31 | 9030 32 | 9031 33 | 9032 34 | 9033 35 | 9034 36 | 9035 37 | 9036 38 | 9037 39 | 9038 40 | 9039 41 | 9040 42 | 9041 43 | 9042 44 | 9043 45 | 9044 46 | 9045 47 | 9046 48 | 9047 49 | 9048 50 | 9049 51 | 9050 52 | 9051 53 | 9052 54 | 9053 55 | 9054 56 | 9055 57 | 9056 58 | 9057 59 | 9058 60 | 9059 61 | 9060 62 | 9061 63 | 9062 64 | 9063 65 | 9064 66 | 9065 67 | 9066 68 | 9067 69 | 9068 70 | 9069 71 | 9070 72 | 9071 73 | 9072 74 | 9073 75 | 9074 76 | 9075 77 | 9076 78 | 9077 79 | 9078 80 | 9079 81 | 9080 82 | 9081 83 | 9082 84 | 9083 85 | 9084 86 | 9085 87 | 9086 88 | 9087 89 | 9088 90 | 9089 91 | 9090 92 | 9091 93 | 9092 94 | 9093 95 | 9094 96 | 9095 97 | 9096 98 | 9097 99 | 9098 100 | 9099 101 | 9100 102 | 9101 103 | 9102 104 | 9103 105 | 9104 106 | 9105 107 | 9106 108 | 9107 109 | 9108 110 | 9109 111 | 9110 112 | 9111 113 | 9112 114 | 9113 115 | 9114 116 | 9115 117 | 9116 118 | 9117 119 | 9118 120 | 9119 121 | 9120 122 | 9121 123 | 9122 124 | 9123 125 | 9124 126 | 9125 127 | 9126 128 | 9127 129 | 9128 130 | 9129 131 | 9130 132 | 9131 133 | 9132 134 | 9133 135 | 9134 136 | 9135 137 | 9136 138 | 9137 139 | 9138 140 | 9139 141 | 9140 142 | 9141 143 | 9142 144 | 9143 145 | 9144 146 | 9145 147 | 9146 148 | 9147 149 | 9148 150 | 9149 151 | 9150 152 | 9151 153 | 9152 154 | 9153 155 | 9154 156 | 9155 157 | 9156 158 | 9157 159 | 9158 160 | 9159 161 | 9160 162 | 9161 163 | 9162 164 | 9163 165 | 9164 166 | 9165 167 | 9166 168 | 9167 169 | 9168 170 | 9169 171 | 9170 172 | 9171 173 | 9172 174 | 9173 175 | 9174 176 | 9175 177 | 9176 178 | 9177 179 | 9178 180 | 9179 181 | 9180 182 | 9181 183 | 9182 184 | 9183 185 | 9184 186 | 9185 187 | 9186 188 | 9187 189 | 9188 190 | 9189 191 | 9190 192 | 9191 193 | 9192 194 | 9193 195 | 9194 196 | 9195 197 | 9196 198 | 9197 199 | 9198 200 | 9199 201 | 9200 202 | 9201 203 | 9202 204 | 9203 205 | 9204 206 | 9205 207 | 9206 208 | 9207 209 | 9208 210 | 9209 211 | 9210 212 | 9211 213 | 9212 214 | 9213 215 | 9214 216 | 9215 217 | 9216 218 | 9217 219 | 9218 220 | 9219 221 | 9220 222 | 9221 223 | 9222 224 | 9223 225 | 9224 226 | 9225 227 | 9226 228 | 9227 229 | 9228 230 | 9229 231 | 9230 232 | 9231 233 | 9232 234 | 9233 235 | 9234 236 | 9235 237 | 9236 238 | 9237 239 | 9238 240 | 9239 241 | 9240 242 | 9241 243 | 9242 244 | 9243 245 | 9244 246 | 9245 247 | 9246 248 | 9247 249 | 9248 250 | 9249 251 | 9250 252 | 9251 253 | 9252 254 | 9253 255 | 9254 256 | 9255 257 | 9256 258 | 9257 259 | 9258 260 | 9259 261 | 9260 262 | 9261 263 | 9262 264 | 9263 265 | 9264 266 | 9265 267 | 9266 268 | 9267 269 | 9268 270 | 9269 271 | 9270 272 | 9271 273 | 9272 274 | 9273 275 | 9274 276 | 9275 277 | 9276 278 | 9277 279 | 9278 280 | 9279 281 | 9280 282 | 9281 283 | 9282 284 | 9283 285 | 9284 286 | 9285 287 | 9286 288 | 9287 289 | 9288 290 | 9289 291 | 9290 292 | 9291 293 | 9292 294 | 9293 295 | 9294 296 | 9295 297 | 9296 298 | 9297 299 | 9298 300 | 9299 301 | 9300 302 | 9301 303 | 9302 304 | 9303 305 | 9304 306 | 9305 307 | 9306 308 | 9307 309 | 9308 310 | 9309 311 | 9310 312 | 9311 313 | 9312 314 | 9313 315 | 9314 316 | 9315 317 | 9316 318 | 9317 319 | 9318 320 | 9319 321 | 9320 322 | 9321 323 | 9322 324 | 9323 325 | 9324 326 | 9325 327 | 9326 328 | 9327 329 | 9328 330 | 9329 331 | 9330 332 | 9331 333 | 9332 334 | 9333 335 | 9334 336 | 9335 337 | 9336 338 | 9337 339 | 9338 340 | 9339 341 | 9340 342 | 9341 343 | 9342 344 | 9343 345 | 9344 346 | 9345 347 | 9346 348 | 9347 349 | 9348 350 | 9349 351 | 9350 352 | 9351 353 | 9352 354 | 9353 355 | 9354 356 | 9355 357 | 9356 358 | 9357 359 | 9358 360 | 9359 361 | 9360 362 | 9361 363 | 9362 364 | 9363 365 | 9364 366 | 9365 367 | 9366 368 | 9367 369 | 9368 370 | 9369 371 | 9370 372 | 9371 373 | 9372 374 | 9373 375 | 9374 376 | 9375 377 | 9376 378 | 9377 379 | 9378 380 | 9379 381 | 9380 382 | 9381 383 | 9382 384 | 9383 385 | 9384 386 | 9385 387 | 9386 388 | 9387 389 | 9388 390 | 9389 391 | 9390 392 | 9391 393 | 9392 394 | 9393 395 | 9394 396 | 9395 397 | 9396 398 | 9397 399 | 9398 400 | 9399 401 | -------------------------------------------------------------------------------- /models/__init__.py: -------------------------------------------------------------------------------- 1 | from .deeplab_multi import DeeplabMulti 2 | 3 | 4 | def get_model(cfg): 5 | if cfg.model.backbone == "deeplabv2_multi": 6 | model = DeeplabMulti(num_classes=cfg.data.num_classes, init=cfg.model.imagenet_pretrained) 7 | params = model.optim_parameters(lr=cfg.opt.lr) 8 | else: 9 | raise NotImplementedError() 10 | return model, params 11 | -------------------------------------------------------------------------------- /models/deeplab_multi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import torch 3 | import torch.nn as nn 4 | import torch.nn.functional as F 5 | 6 | affine_par = True 7 | 8 | class GradientReverse(torch.autograd.Function): 9 | scale = 1.0 10 | 11 | @staticmethod 12 | def forward(ctx, x): 13 | return x.view_as(x) 14 | 15 | @staticmethod 16 | def backward(ctx, grad_output): 17 | return GradientReverse.scale * grad_output.neg() 18 | def grad_reverse(x, lambd=1.0): 19 | GradientReverse.scale = lambd 20 | return GradientReverse.apply(x) 21 | class Bottleneck(nn.Module): 22 | expansion = 4 23 | 24 | def __init__(self, inplanes, planes, stride=1, dilation=1, downsample=None, bn_momentum=0.1): 25 | super(Bottleneck, self).__init__() 26 | self.conv1 = nn.Conv2d( 27 | inplanes, planes, kernel_size=1, stride=stride, bias=False) # change 28 | self.bn1 = nn.BatchNorm2d(planes, affine=affine_par) 29 | 30 | padding = dilation 31 | self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=1, # change 32 | padding=padding, bias=False, dilation=dilation) 33 | self.bn2 = nn.BatchNorm2d(planes, affine=affine_par) 34 | 35 | self.conv3 = nn.Conv2d(planes, planes * 4, kernel_size=1, bias=False) 36 | self.bn3 = nn.BatchNorm2d(planes * 4, affine=affine_par) 37 | 38 | self.relu = nn.ReLU(inplace=True) 39 | self.downsample = downsample 40 | self.stride = stride 41 | 42 | def forward(self, x): 43 | residual = x 44 | 45 | out = self.conv1(x) 46 | out = self.bn1(out) 47 | out = self.relu(out) 48 | 49 | out = self.conv2(out) 50 | out = self.bn2(out) 51 | out = self.relu(out) 52 | 53 | out = self.conv3(out) 54 | out = self.bn3(out) 55 | 56 | if self.downsample is not None: 57 | residual = self.downsample(x) 58 | 59 | out += residual 60 | out = self.relu(out) 61 | 62 | return out 63 | 64 | 65 | class Classifier_Module(nn.Module): 66 | def __init__(self, inplanes, dilation_series, padding_series, num_classes): 67 | super(Classifier_Module, self).__init__() 68 | self.conv2d_list = nn.ModuleList() 69 | for dilation, padding in zip(dilation_series, padding_series): 70 | self.conv2d_list.append( 71 | nn.Conv2d(inplanes, num_classes, kernel_size=3, stride=1, padding=padding, dilation=dilation, bias=True)) 72 | #print(num_classes) 73 | #exit() 74 | for m in self.conv2d_list: 75 | m.weight.data.normal_(0, 0.01) 76 | 77 | def forward(self, x): 78 | out = self.conv2d_list[0](x) 79 | for i in range(len(self.conv2d_list) - 1): 80 | out += self.conv2d_list[i + 1](x) 81 | return out 82 | class Classifier_Module2(nn.Module): 83 | def __init__(self, inplanes, dilation_series, padding_series, num_classes, droprate = 0.1, use_se = True): 84 | super(Classifier_Module2, self).__init__() 85 | self.conv2d_list = nn.ModuleList() 86 | self.conv2d_list.append( 87 | nn.Sequential(*[ 88 | nn.Conv2d(inplanes, 256, kernel_size=1, stride=1, padding=0, dilation=1, bias=True), 89 | nn.GroupNorm(num_groups=32, num_channels=256, affine = True), 90 | nn.ReLU(inplace=True) ])) 91 | 92 | for dilation, padding in zip(dilation_series, padding_series): 93 | #self.conv2d_list.append( 94 | # nn.BatchNorm2d(inplanes)) 95 | self.conv2d_list.append( 96 | nn.Sequential(*[ 97 | #nn.ReflectionPad2d(padding), 98 | nn.Conv2d(inplanes, 256, kernel_size=3, stride=1, padding=padding, dilation=dilation, bias=True), 99 | nn.GroupNorm(num_groups=32, num_channels=256, affine = True), 100 | nn.ReLU(inplace=True) ])) 101 | 102 | if use_se: 103 | self.bottleneck = nn.Sequential(*[SEBlock(256 * (len(dilation_series) + 1)), 104 | nn.Conv2d(256 * (len(dilation_series) + 1), 256, kernel_size=3, stride=1, padding=1, dilation=1, bias=True) , 105 | nn.GroupNorm(num_groups=32, num_channels=256, affine = True) ]) 106 | else: 107 | self.bottleneck = nn.Sequential(*[ 108 | nn.Conv2d(256 * (len(dilation_series) + 1), 256, kernel_size=3, stride=1, padding=1, dilation=1, bias=True) , 109 | nn.GroupNorm(num_groups=32, num_channels=256, affine = True) ]) 110 | 111 | self.head = nn.Sequential(*[nn.Dropout2d(droprate), 112 | nn.Conv2d(256, num_classes, kernel_size=1, padding=0, dilation=1, bias=False) ]) 113 | 114 | ##########init####### 115 | for m in self.conv2d_list: 116 | if isinstance(m, nn.Conv2d): 117 | torch.nn.init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') 118 | m.bias.data.zero_() 119 | elif isinstance(m, nn.BatchNorm2d) or isinstance(m, nn.InstanceNorm2d) or isinstance(m, nn.GroupNorm): 120 | m.weight.data.fill_(1) 121 | m.bias.data.zero_() 122 | 123 | for m in self.bottleneck: 124 | if isinstance(m, nn.Conv2d): 125 | torch.nn.init.kaiming_normal_(m.weight.data, a=0, mode='fan_in') 126 | m.bias.data.zero_() 127 | elif isinstance(m, nn.Linear): 128 | torch.nn.init.kaiming_normal_(m.weight.data, a=0, mode='fan_out') 129 | m.bias.data.zero_() 130 | elif isinstance(m, nn.BatchNorm2d) or isinstance(m, nn.InstanceNorm2d) or isinstance(m, nn.GroupNorm) or isinstance(m, nn.LayerNorm): 131 | m.weight.data.fill_(1) 132 | m.bias.data.zero_() 133 | 134 | for m in self.head: 135 | if isinstance(m, nn.Conv2d): 136 | m.weight.data.normal_(0, 0.001) 137 | 138 | def forward(self, x, get_feat=False): 139 | out = self.conv2d_list[0](x) 140 | for i in range(len(self.conv2d_list) - 1): 141 | out = torch.cat( (out, self.conv2d_list[i+1](x)), 1) 142 | out = self.bottleneck(out) 143 | if get_feat: 144 | out_dict = {} 145 | out = self.head[0](out) 146 | out_dict['feat'] = out 147 | out = self.head[1](out) 148 | out_dict['out'] = out 149 | return out_dict 150 | else: 151 | out = self.head(out) 152 | return out 153 | class SEBlock(nn.Module): 154 | def __init__(self, inplanes, r = 16): 155 | super(SEBlock, self).__init__() 156 | self.global_pool = nn.AdaptiveAvgPool2d((1,1)) 157 | self.se = nn.Sequential( 158 | nn.Linear(inplanes, inplanes//r), 159 | nn.ReLU(inplace=True), 160 | nn.Linear(inplanes//r, inplanes), 161 | nn.Sigmoid() 162 | ) 163 | def forward(self, x): 164 | xx = self.global_pool(x) 165 | xx = xx.view(xx.size(0), xx.size(1)) 166 | se_weight = self.se(xx).unsqueeze(-1).unsqueeze(-1) 167 | return x.mul(se_weight) 168 | class ResNetMulti(nn.Module): 169 | def __init__(self, block, layers, num_classes): 170 | self.inplanes = 64 171 | super(ResNetMulti, self).__init__() 172 | self.conv1 = nn.Conv2d(3, 64, kernel_size=7, 173 | stride=2, padding=3, bias=False) 174 | self.bn1 = nn.BatchNorm2d(64, affine=affine_par) 175 | for i in self.bn1.parameters(): 176 | i.requires_grad = False 177 | self.relu = nn.ReLU(inplace=True) 178 | self.maxpool = nn.MaxPool2d( 179 | kernel_size=3, stride=2, padding=1, ceil_mode=True) # change 180 | self.layer1 = self._make_layer(block, 64, layers[0]) 181 | self.layer2 = self._make_layer(block, 128, layers[1], stride=2) 182 | self.layer3 = self._make_layer( 183 | block, 256, layers[2], stride=1, dilation=2) 184 | self.layer4 = self._make_layer( 185 | block, 512, layers[3], stride=1, dilation=4) 186 | self.layer5 = self._make_pred_layer(Classifier_Module, 1024, [6, 12, 18, 24], [ 187 | 6, 12, 18, 24], num_classes) 188 | self.layer6 = self._make_pred_layer(Classifier_Module, 2048, [6, 12, 18, 24], [ 189 | 6, 12, 18, 24], num_classes) 190 | 191 | for m in self.modules(): 192 | if isinstance(m, nn.Conv2d): 193 | n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels 194 | m.weight.data.normal_(0, 0.01) 195 | elif isinstance(m, nn.BatchNorm2d): 196 | m.weight.data.fill_(1) 197 | m.bias.data.zero_() 198 | 199 | # New! Rotation prediction head 200 | self.rotation_prediction_head = nn.Identity() 201 | self.proto_classifier=nn.Conv2d(2048, num_classes, kernel_size=1, stride=1, bias=False) 202 | self.fuse_weight_1 = nn.Parameter(torch.FloatTensor(1), requires_grad=True) 203 | self.fuse_weight_1.data.fill_(2) 204 | self.a=[] 205 | 206 | self.para = nn.Parameter(torch.tensor([0.5]), requires_grad=True) 207 | self.para.data.fill_(2) 208 | self.a.append(self.para) 209 | self.a.append(self.fuse_weight_1) 210 | def _make_layer(self, block, planes, blocks, stride=1, dilation=1): 211 | downsample = None 212 | if stride != 1 or self.inplanes != planes * block.expansion or dilation == 2 or dilation == 4: 213 | downsample = nn.Sequential( 214 | nn.Conv2d(self.inplanes, planes * block.expansion, 215 | kernel_size=1, stride=stride, bias=False), 216 | nn.BatchNorm2d(planes * block.expansion, affine=affine_par)) 217 | layers = [] 218 | layers.append(block(self.inplanes, planes, stride, 219 | dilation=dilation, downsample=downsample)) 220 | self.inplanes = planes * block.expansion 221 | for i in range(1, blocks): 222 | layers.append(block(self.inplanes, planes, dilation=dilation)) 223 | 224 | return nn.Sequential(*layers) 225 | 226 | def _make_pred_layer(self, block, inplanes, dilation_series, padding_series, num_classes): 227 | return block(inplanes, dilation_series, padding_series, num_classes) 228 | 229 | def forward(self, x): 230 | #print('we are ready') 231 | #exit() 232 | input_size = x.size()[2:] 233 | self.input_size=input_size 234 | x = self.conv1(x) 235 | x = self.bn1(x) 236 | x = self.relu(x) 237 | x = self.maxpool(x) 238 | x = self.layer1(x) 239 | x = self.layer2(x) 240 | x = self.layer3(x) 241 | 242 | # Resolution 1 243 | #x_norm=F.normalize(x) 244 | #exit() 245 | #x1 = self.layer5(20*x_norm) 246 | x1 = self.layer5(x) 247 | x1 = F.interpolate(x1, size=input_size, 248 | mode='bilinear', align_corners=True) 249 | 250 | # Resolution 2 251 | x2 = self.layer4(x) 252 | #x2_f=F.normalize(x2) 253 | x2_f=x2 254 | #print(x2_f.shape,x2.shape) 255 | x2 = self.layer6(x2) 256 | #print(x2_f.shape,x2.shape) 257 | x2_nointer=x2 258 | #print(x2_nointer.shape) 259 | #exit() 260 | #print(x2_f.shape,x2.shape) 261 | #exit() 262 | x2 = F.interpolate(x2, size=input_size, 263 | mode='bilinear', align_corners=True) 264 | #print(x2.shape,'lllllllllll') 265 | return x2, x1,x2_nointer,x2_f # changed! 266 | def classifier(self, x, reverse=False, eta=0.1): 267 | if reverse: 268 | x = grad_reverse(x, eta) 269 | x = self.layer6(x) 270 | return x # changed! 271 | def prototype(self, x): 272 | if True: 273 | x_logits = self.class_t(x) 274 | logit_size=x_logits.size() 275 | prototype=self.proto_classifier.weight 276 | #print(prototype.shape) 277 | prototype=prototype.reshape(-1,prototype.shape[0],prototype.shape[1]).repeat(x.shape[0],1,1)#.detach() 278 | #prototype=F.normalize(prototype)#.detach() 279 | #print(prototype.shape) 280 | #print(x_logits.shape,logit_size) 281 | #print(x.shape) 282 | #exit() 283 | prob=F.softmax(x_logits.reshape(logit_size[0],logit_size[1],-1),dim=1).transpose(1,2).contiguous() 284 | #print(self.fuse_weight_1) 285 | #exit() 286 | #print(prob.shape,prototype.shape) 287 | #exit() 288 | x_s_t=torch.bmm(prob,self.para*prototype).transpose(1,2).contiguous() 289 | x_o = self.layer6(x_s_t.reshape(x.shape[0],x.shape[1],x.shape[2],x.shape[3])) 290 | #x_o = F.interpolate(x_o, size=self.input_size, 291 | #mode='bilinear', align_corners=True) 292 | #print(x_s_t.shape,x.shape) 293 | #exit() 294 | #exit() 295 | #print(x_o.shape) 296 | #exit() 297 | else: 298 | w,h=x.shape[2],x.shape[3] 299 | prototype=self.proto_classifier.weight 300 | prototype_1=prototype.reshape(prototype.shape[0],prototype.shape[1],-1).transpose(0,2).contiguous().repeat(2,1,1) 301 | x=x.reshape(x.shape[0],x.shape[1],-1).transpose(1,2).contiguous() 302 | #print(x.shape,prototype.shape) 303 | #exit() 304 | x_o=torch.bmm(x,prototype_1).transpose(1,2).contiguous().reshape(x.shape[0],prototype_1.shape[2],w,h) 305 | x_o = F.interpolate(x_o, size=self.input_size, 306 | mode='bilinear', align_corners=True) 307 | return x_o # changed! 308 | def class_t(self, x): 309 | #print(x.shape) 310 | #print(self.proto_classifier.weight) 311 | if True: 312 | w,h=x.shape[2],x.shape[3] 313 | prototype=self.proto_classifier.weight 314 | #prototype=F.normalize(prototype).reshape(prototype.shape[0],prototype.shape[1],-1).transpose(0,2).contiguous().repeat(x.shape[0],1,1) 315 | prototype=prototype.reshape(prototype.shape[0],prototype.shape[1],-1).transpose(0,2).contiguous().repeat(x.shape[0],1,1) 316 | x=x.reshape(x.shape[0],x.shape[1],-1).transpose(1,2).contiguous() 317 | #print(x.shape,prototype.shape,torch.bmm(x,prototype).shape) 318 | #exit() 319 | #print(x.shape,prototype.shape) 320 | 321 | x_logits=torch.bmm(x,prototype).transpose(1,2).contiguous().reshape(x.shape[0],prototype.shape[2],w,h) 322 | #print(x_logits.shape) 323 | #exit() 324 | #print(x.shape,prototype.shape) 325 | #exit() 326 | #print(prototype.shape,'class_t') 327 | #exit(0) 328 | else: 329 | x_logits = self.proto_classifier(x) 330 | 331 | return x_logits # changed! 332 | def get_1x_lr_params_NOscale(self): 333 | """ 334 | This generator returns all the parameters of the net except for 335 | the last classification layer. Note that for each batchnorm layer, 336 | requires_grad is set to False in deeplab_resnet.py, therefore this function does not return 337 | any batchnorm parameter 338 | """ 339 | b = [] 340 | 341 | b.append(self.conv1) 342 | b.append(self.bn1) 343 | b.append(self.layer1) 344 | b.append(self.layer2) 345 | b.append(self.layer3) 346 | b.append(self.layer4) 347 | 348 | for i in range(len(b)): 349 | for j in b[i].modules(): 350 | jj = 0 351 | for k in j.parameters(): 352 | jj += 1 353 | if k.requires_grad: 354 | yield k 355 | 356 | def get_10x_lr_params(self): 357 | """ 358 | This generator returns all the parameters for the last layer of the net, 359 | which does the classification of pixel into classes 360 | """ 361 | b = [] 362 | b.append(self.layer5.parameters()) 363 | b.append(self.layer6.parameters()) 364 | b.append(self.proto_classifier.parameters()) 365 | #b.append(self.para.parameters()) 366 | b.append(self.a) 367 | for j in range(len(b)): 368 | for i in b[j]: 369 | yield i 370 | 371 | def optim_parameters(self, lr): 372 | return [{'params': self.get_1x_lr_params_NOscale(), 'lr': lr}, 373 | {'params': self.get_10x_lr_params(), 'lr': 10 * lr}] 374 | 375 | 376 | def DeeplabMulti(num_classes=21, init=None): 377 | 378 | # Create model 379 | model = ResNetMulti(Bottleneck, [3, 4, 23, 3], num_classes) 380 | 381 | # Standard DeepLabv2 initialization 382 | if init: 383 | saved_state_dict = torch.load(init) 384 | new_params = model.state_dict().copy() 385 | for i in saved_state_dict: 386 | i_parts = i.split('.') 387 | if not i_parts[1] == 'layer5': 388 | new_params['.'.join(i_parts[1:])] = saved_state_dict[i] 389 | model.load_state_dict(new_params) 390 | 391 | return model 392 | -------------------------------------------------------------------------------- /models/ema.py: -------------------------------------------------------------------------------- 1 | """ 2 | Props to https://github.com/valencebond/FixMatch_pytorch 3 | """ 4 | import torch 5 | 6 | 7 | class EMA(object): 8 | def __init__(self, model, alpha=0.999): 9 | """ Model exponential moving average. """ 10 | self.step = 0 11 | self.model = model 12 | self.alpha = alpha 13 | self.shadow = self.get_model_state() 14 | self.backup = {} 15 | self.param_keys = [k for k, _ in self.model.named_parameters()] 16 | #print(self.param_keys) 17 | 18 | # NOTE: Buffer values are for things that are not parameters, 19 | # such as batch norm statistics 20 | self.buffer_keys = [k for k, _ in self.model.named_buffers()] 21 | #print(self.buffer_keys) 22 | #exit() 23 | 24 | def update_params(self): 25 | decay = self.alpha 26 | state = self.model.state_dict() # current params 27 | for name in self.param_keys: 28 | self.shadow[name].copy_( 29 | decay * self.shadow[name] + (1 - decay) * state[name]) 30 | self.step += 1 31 | 32 | def update_buffer(self): 33 | # No EMA for buffer values (for now) 34 | state = self.model.state_dict() 35 | for name in self.buffer_keys: 36 | self.shadow[name].copy_(state[name]) 37 | 38 | def apply_shadow(self): 39 | self.backup = self.get_model_state() 40 | self.model.load_state_dict(self.shadow) 41 | 42 | def shadowdict(self,shadow_dict): 43 | self.shadow = shadow_dict 44 | 45 | def restore(self): 46 | self.model.load_state_dict(self.backup) 47 | 48 | def get_model_state(self): 49 | return { 50 | k: v.clone().detach() 51 | for k, v in self.model.state_dict().items() 52 | } 53 | 54 | 55 | if __name__ == '__main__': 56 | model = torch.nn.Sequential(torch.nn.Linear(5, 5), torch.nn.BatchNorm1d(5)) 57 | ema = EMA(model, 0.9, 0.02, 0.002) 58 | inten = torch.randn(10, 5) 59 | out = model(inten) 60 | ema.update_params() 61 | print(model.state_dict()) 62 | ema.update_buffer() 63 | print(model.state_dict()) 64 | -------------------------------------------------------------------------------- /perturbations/augmentations.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | import cv2 4 | import albumentations as al 5 | from datasets.cityscapes_Dataset import IMG_MEAN 6 | 7 | 8 | def get_augmentation(): 9 | return al.Compose([ 10 | #al.RandomResizedCrop(512, 512, scale=(0.2, 1.)), 11 | al.Compose([ 12 | # NOTE: RandomBrightnessContrast replaces ColorJitter 13 | al.RandomBrightnessContrast(p=1), 14 | al.HueSaturationValue(p=1), 15 | ], p=0.8), 16 | al.ToGray(p=0.2), 17 | al.GaussianBlur(5, p=0.5), 18 | ]) 19 | weak=al.Compose([ 20 | al.RandomResizedCrop(512, 512, scale=(0.2, 1.)) 21 | ]) 22 | 23 | def augment(images, labels, aug): 24 | """Augments both image and label. Assumes input is a PyTorch tensor with 25 | a batch dimension and values normalized to N(0,1).""" 26 | 27 | # Transform label shape: B, C, W, H ==> B, W, H, C 28 | labels_are_3d = (len(labels.shape) == 4) 29 | if labels_are_3d: 30 | labels = labels.permute(0, 2, 3, 1) 31 | 32 | # Transform each image independently. This is slow, but whatever. 33 | aug_images,w_images, aug_labels = [],[], [] 34 | for image, label in zip(images, labels): 35 | 36 | # Step 1: Undo normalization transformation, convert to numpy 37 | image = cv2.cvtColor(image.numpy().transpose( 38 | 1, 2, 0) + IMG_MEAN, cv2.COLOR_BGR2RGB).astype(np.uint8) 39 | label = label.numpy() # convert to np 40 | 41 | # Step 2: Perform transformations on numpy images 42 | data = weak(image=image, mask=label) 43 | image, label = data['image'], data['mask'] 44 | 45 | strong_img=aug(image=image, mask=label) 46 | img_s=strong_img['image'] 47 | # Step 3: Convert back to PyTorch tensors 48 | image = torch.from_numpy((cv2.cvtColor(image.astype( 49 | np.float32), cv2.COLOR_RGB2BGR) - IMG_MEAN).transpose(2, 0, 1)) 50 | img_s = torch.from_numpy((cv2.cvtColor(img_s.astype( 51 | np.float32), cv2.COLOR_RGB2BGR) - IMG_MEAN).transpose(2, 0, 1)) 52 | label = torch.from_numpy(label) 53 | if not labels_are_3d: 54 | label = label.long() 55 | 56 | # Add to list 57 | aug_images.append(img_s) 58 | w_images.append(image) 59 | aug_labels.append(label) 60 | 61 | # Stack 62 | images = torch.stack(aug_images, dim=0) 63 | images_w = torch.stack(w_images, dim=0) 64 | labels = torch.stack(aug_labels, dim=0) 65 | 66 | # Transform label shape back: B, C, W, H ==> B, W, H, C 67 | if labels_are_3d: 68 | labels = labels.permute(0, 3, 1, 2) 69 | return images, images_w,labels 70 | -------------------------------------------------------------------------------- /perturbations/cutmix.py: -------------------------------------------------------------------------------- 1 | """ 2 | Props to https://github.com/clovaai/CutMix-PyTorch/blob/master/train.py#L228 3 | """ 4 | 5 | import numpy as np 6 | import torch 7 | import torch.nn.functional as F 8 | 9 | 10 | def get_rand_bbox(size, lam): 11 | 12 | # Get cutout size 13 | W = size[2] 14 | H = size[3] 15 | cut_rat = np.sqrt(1. - lam) 16 | cut_w = np.int(W * cut_rat) 17 | cut_h = np.int(H * cut_rat) 18 | 19 | # Sample location uniformly at random 20 | cx = np.random.randint(W) 21 | cy = np.random.randint(H) 22 | 23 | # Clip 24 | bbx1 = np.clip(cx - cut_w // 2, 0, W) 25 | bby1 = np.clip(cy - cut_h // 2, 0, H) 26 | bbx2 = np.clip(cx + cut_w // 2, 0, W) 27 | bby2 = np.clip(cy + cut_h // 2, 0, H) 28 | return bbx1, bby1, bbx2, bby2 29 | 30 | 31 | def cutmix(images_1, images_2, labels_1, labels_2, beta=1.0): 32 | 33 | # Determine randomly which is the patch 34 | if np.random.rand() > 0.5: 35 | images_1, images_2 = images_2, images_1 36 | labels_1, labels_2 = labels_2, labels_1 37 | 38 | # Randomly sample lambda from beta distribution 39 | lam = np.random.beta(beta, beta) 40 | 41 | # Get bounding box 42 | bbx1, bby1, bbx2, bby2 = get_rand_bbox(images_1.shape, lam) 43 | 44 | # Cut and paste images and labels 45 | images, labels = images_1.clone(), labels_1.clone() 46 | images[:, :, bbx1:bbx2, bby1:bby2] = images_2[:, :, bbx1:bbx2, bby1:bby2] 47 | labels[:, :, bbx1:bbx2, bby1:bby2] = labels_2[:, :, bbx1:bbx2, bby1:bby2] 48 | return images, labels 49 | 50 | 51 | @torch.no_grad() 52 | def cutmix_combine(images_1, images_2, labels_1, labels_2, beta=1.0): 53 | """ Transfers style of style images to content images. Assumes input 54 | is a PyTorch tensor with a batch dimension.""" 55 | B, sC, sH, sW = images_1.shape 56 | B, tC, tH, tW = images_2.shape 57 | if (sH != tH) or (sW != tW): 58 | images_1 = F.interpolate(images_1, size=(tH, tW), mode='bicubic') 59 | labels_1 = F.interpolate( 60 | labels_1.float(), size=(tH, tW), mode='nearest').long() 61 | mixed_images, mixed_labels = cutmix( 62 | images_1, images_2, labels_1, labels_2, beta=1.0) 63 | return mixed_images, mixed_labels 64 | -------------------------------------------------------------------------------- /perturbations/fourier.py: -------------------------------------------------------------------------------- 1 | """ 2 | Adapted from https://github.com/YanchaoYang/FDA/blob/master/utils/__init__.py 3 | """ 4 | 5 | import numpy as np 6 | import torch 7 | import torch 8 | import torch.nn.functional as F 9 | 10 | 11 | def extract_ampl_phase(fft_im): 12 | # fft_im: size should be bx3xhxwx2 13 | fft_amp = fft_im[:, :, :, :, 0]**2 + fft_im[:, :, :, :, 1]**2 14 | fft_amp = torch.sqrt(fft_amp) 15 | fft_pha = torch.atan2(fft_im[:, :, :, :, 1], fft_im[:, :, :, :, 0]) 16 | return fft_amp, fft_pha 17 | 18 | 19 | def low_freq_mutate(amp_src, amp_trg, L=0.1): 20 | _, _, h, w = amp_src.size() 21 | b = (np.floor(np.amin((h, w)) * L)).astype(int) # get b 22 | amp_src[:, :, 0:b, 0:b] = amp_trg[:, :, 0:b, 0:b] # top left 23 | amp_src[:, :, 0:b, w - b:w] = amp_trg[:, :, 0:b, w - b:w] # top right 24 | amp_src[:, :, h - b:h, 0:b] = amp_trg[:, :, h - b:h, 0:b] # bottom left 25 | amp_src[:, :, h - b:h, w - b:w] = amp_trg[:, :, h - b:h, w - b:w] # bottom right 26 | return amp_src 27 | 28 | 29 | def FDA_source_to_target(src_img, trg_img, L=0.1): 30 | # exchange magnitude 31 | # input: src_img, trg_img 32 | 33 | # get fft of both source and target 34 | fft_src = torch.fft.rfft2(src_img.clone()) 35 | fft_src=torch.stack((fft_src.real,fft_src.imag),-1) 36 | fft_trg = torch.fft.rfft2(trg_img.clone()) 37 | fft_trg = torch.stack((fft_trg.real,fft_trg.imag),-1) 38 | 39 | # extract amplitude and phase of both ffts 40 | amp_src, pha_src = extract_ampl_phase(fft_src.clone()) 41 | amp_trg, pha_trg = extract_ampl_phase(fft_trg.clone()) 42 | 43 | # replace the low frequency amplitude part of source with that from target 44 | amp_src_ = low_freq_mutate(amp_src.clone(), amp_trg.clone(), L=L) 45 | 46 | # recompose fft of source 47 | fft_src_ = torch.zeros(fft_src.size(), dtype=torch.float) 48 | fft_src_[:, :, :, :, 0] = torch.cos(pha_src.clone()) * amp_src_.clone() 49 | fft_src_[:, :, :, :, 1] = torch.sin(pha_src.clone()) * amp_src_.clone() 50 | 51 | # get the recomposed image: source content, target style 52 | _, _, imgH, imgW = src_img.size() 53 | #print(imgH, imgW,fft_src_.shape) 54 | #exit() 55 | src_in_trg = torch.fft.irfft2(fft_src_, s=[imgH, imgW]) 56 | print(src_in_trg.shape) 57 | exit() 58 | return src_in_trg 59 | 60 | 61 | @torch.no_grad() 62 | def fourier_mix(src_images, tgt_images, L=0.1): 63 | """ Transfers style of style images to content images. Assumes input 64 | is a PyTorch tensor with a batch dimension.""" 65 | B, sC, sH, sW = src_images.shape 66 | B, tC, tH, tW = tgt_images.shape 67 | if (sH > tH) or (sW > tW): 68 | tgt_images = F.interpolate(tgt_images, size=(sH, sW), mode='bicubic') 69 | mixed_images = FDA_source_to_target(src_images, tgt_images, L=L) 70 | return mixed_images.to(src_images.device) 71 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | torch 1.10.1+cu113 2 | absl-py 1.0.0 3 | albumentations 1.1.0 4 | antlr4-python3-runtime 4.8 5 | cachetools 4.2.4 6 | certifi 2021.10.8 7 | charset-normalizer 2.0.10 8 | google-auth 2.3.3 9 | google-auth-oauthlib 0.4.6 10 | grpcio 1.43.0 11 | hydra-core 1.1.1 12 | idna 3.3 13 | imageio 2.14.0 14 | importlib-metadata 4.10.1 15 | importlib-resources 5.4.0 16 | joblib 1.1.0 17 | Markdown 3.3.6 18 | networkx 2.6.3 19 | numpy 1.21.5 20 | oauthlib 3.1.1 21 | omegaconf 2.1.1 22 | opencv-python 4.5.5.62 23 | opencv-python-headless 4.5.5.62 24 | packaging 21.3 25 | Pillow 9.0.0 26 | pip 21.2.2 27 | protobuf 3.19.3 28 | pyasn1 0.4.8 29 | pyasn1-modules 0.2.8 30 | pyparsing 3.0.7 31 | PyWavelets 1.2.0 32 | PyYAML 6.0 33 | qudida 0.0.4 34 | requests 2.27.1 35 | requests-oauthlib 1.3.0 36 | rsa 4.8 37 | scikit-image 0.19.1 38 | scikit-learn 1.0.2 39 | scipy 1.7.3 40 | setuptools 58.0.4 41 | six 1.16.0 42 | tensorboard 2.8.0 43 | tensorboard-data-server 0.6.1 44 | tensorboard-plugin-wit 1.8.1 45 | tensorboardX 2.4.1 46 | threadpoolctl 3.0.0 47 | tifffile 2021.11.2 48 | torchaudio 0.10.1+cu113 49 | torchvision 0.11.2+cu113 50 | tqdm 4.62.3 51 | typing_extensions 4.0.1 52 | urllib3 1.26.8 53 | Werkzeug 2.0.2 54 | wheel 0.37.1 55 | zipp 3.7.0 56 | -------------------------------------------------------------------------------- /scripts/video-from-frames.sh: -------------------------------------------------------------------------------- 1 | run_name="GTA5_pixmatch-2021-03-25-12-17-50" # "GTA5_source" 2 | framerate=30 3 | 4 | # First sequence 5 | ffmpeg -r $framerate -f image2 -s 1280x640 -i "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_outputs/${run_name}/stuttgart_00_000000_000%03d_leftImg8bit.png" -vcodec libx264 -crf 10 -pix_fmt yuv420p "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_videos/${run_name}-stuttgart_00.mp4" 6 | 7 | # Second sequence 8 | ffmpeg -r $framerate -f image2 -s 1280x640 -start_number 3500 -i "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_outputs/${run_name}/stuttgart_01_000000_00%04d_leftImg8bit.png" -vcodec libx264 -crf 10 -pix_fmt yuv420p "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_videos/${run_name}-stuttgart_01.mp4" 9 | 10 | # # Third sequence 11 | ffmpeg -r $framerate -f image2 -s 1280x640 -start_number 5100 -i "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_outputs/${run_name}/stuttgart_02_000000_00%04d_leftImg8bit.png" -vcodec libx264 -crf 10 -pix_fmt yuv420p "/home/luke/projects/experiments/pixmatch/tmp/demoVideo_videos/${run_name}-stuttgart_02.mp4" -------------------------------------------------------------------------------- /scripts/video-visualization.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "id": "handled-cathedral", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "/home/luke/projects/experiments/pixmatch\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "%cd /home/luke/projects/experiments/pixmatch" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 11, 24 | "id": "found-production", 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "import os\n", 29 | "import random\n", 30 | "import logging\n", 31 | "from pathlib import Path\n", 32 | "import torch\n", 33 | "import torch.nn as nn\n", 34 | "import torch.nn.functional as F\n", 35 | "from torch.utils.data.dataloader import DataLoader\n", 36 | "from tqdm import tqdm, trange\n", 37 | "import numpy as np\n", 38 | "from torch.utils.tensorboard import SummaryWriter\n", 39 | "from PIL import Image\n", 40 | "\n", 41 | "import hydra\n", 42 | "from hydra.experimental import initialize, compose\n", 43 | "from omegaconf import OmegaConf, DictConfig\n", 44 | "\n", 45 | "from datasets.cityscapes_Dataset import DemoVideo_City_Dataset, City_Dataset, inv_preprocess, decode_labels\n", 46 | "from datasets.gta5_Dataset import GTA5_Dataset\n", 47 | "from datasets.synthia_Dataset import SYNTHIA_Dataset\n", 48 | "from models import get_model\n", 49 | "from models.ema import EMA\n", 50 | "from utils.eval import Eval, synthia_set_16, synthia_set_13\n", 51 | "from main import Trainer" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 12, 57 | "id": "direct-concept", 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "# Parameters\n", 62 | "checkpoint_path = '/home/luke/projects/experiments/pixmatch/outputs/2021-03-25/12-17-50/best.pth' # 'pretrained/GTA5_source.pth'\n", 63 | "output_dir = Path('tmp/demoVideo_outputs/GTA5_pixmatch-2021-03-25-12-17-50') # GTA5_source')\n", 64 | "output_dir.mkdir(exist_ok=True, parents=True)" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 13, 70 | "id": "unauthorized-airplane", 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "# Initialize hydra\n", 75 | "with initialize(config_path='../configs'):\n", 76 | " cfg: DictConfig = compose(config_name=\"gta5.yaml\", overrides=[\"wandb=False\", f\"model.checkpoint={checkpoint_path}\"])" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 14, 82 | "id": "constant-pasta", 83 | "metadata": {}, 84 | "outputs": [], 85 | "source": [ 86 | "# # Print config\n", 87 | "# print(OmegaConf.to_yaml(cfg))" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 15, 93 | "id": "lesser-request", 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "name": "stdout", 98 | "output_type": "stream", 99 | "text": [ 100 | "12403 num images in GTA5 train set have been loaded.\n", 101 | "6382 num images in GTA5 val set have been loaded.\n", 102 | "2975 num images in Cityscapes train set have been loaded.\n", 103 | "500 num images in Cityscapes val set have been loaded.\n" 104 | ] 105 | } 106 | ], 107 | "source": [ 108 | "# Seeds\n", 109 | "random.seed(cfg.seed)\n", 110 | "np.random.seed(cfg.seed)\n", 111 | "torch.random.manual_seed(cfg.seed)\n", 112 | "\n", 113 | "# Logger\n", 114 | "logger = logging.getLogger(__name__)\n", 115 | "logger.setLevel(logging.INFO)\n", 116 | "writer = SummaryWriter('/tmp/vis')\n", 117 | "\n", 118 | "# Trainer\n", 119 | "trainer = Trainer(cfg=cfg, logger=logger, writer=writer)\n", 120 | "\n", 121 | "# Load pretrained checkpoint\n", 122 | "if cfg.model.checkpoint:\n", 123 | " assert Path(cfg.model.checkpoint).is_file(), f'not a file: {cfg.model.checkpoint}'\n", 124 | " trainer.load_checkpoint(cfg.model.checkpoint)" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 16, 130 | "id": "hawaiian-newcastle", 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "name": "stdout", 135 | "output_type": "stream", 136 | "text": [ 137 | "Using device: cuda:0\n" 138 | ] 139 | } 140 | ], 141 | "source": [ 142 | "# PyTorch setup\n", 143 | "torch.set_grad_enabled(False)\n", 144 | "device = trainer.model.conv1.weight.device\n", 145 | "print(f'Using device: {device}')" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": null, 151 | "id": "immediate-ballot", 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "name": "stderr", 156 | "output_type": "stream", 157 | "text": [ 158 | "\r", 159 | " 0%| | 0/2899 [00:00= vis_images:\n", 196 | " break\n", 197 | " \n", 198 | " # Forward\n", 199 | " pred = trainer.model(x.to(device))\n", 200 | " if isinstance(pred, tuple):\n", 201 | " pred = pred[0]\n", 202 | " pred = pred.to('cpu')\n", 203 | "\n", 204 | " # Convert to numpy\n", 205 | " argpred = np.argmax(pred.data.cpu().numpy(), axis=1)\n", 206 | "\n", 207 | " # Convert to images\n", 208 | " images_inv = inv_preprocess(x.clone().cpu(), numpy_transform=True)\n", 209 | " preds_colors = decode_labels(argpred)\n", 210 | " for index, (img_color, pred_color) in enumerate(zip(images_inv, preds_colors)):\n", 211 | " output_path = str(output_dir / Path(x_filepath[0]).name)\n", 212 | " Image.fromarray(tensor_to_np_image(pred_color)).save(output_path)\n", 213 | " # print(f'Saved image to {output_path}')" 214 | ] 215 | }, 216 | { 217 | "cell_type": "code", 218 | "execution_count": null, 219 | "id": "advisory-suspect", 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [] 223 | } 224 | ], 225 | "metadata": { 226 | "kernelspec": { 227 | "display_name": "Python 3", 228 | "language": "python", 229 | "name": "python3" 230 | }, 231 | "language_info": { 232 | "codemirror_mode": { 233 | "name": "ipython", 234 | "version": 3 235 | }, 236 | "file_extension": ".py", 237 | "mimetype": "text/x-python", 238 | "name": "python", 239 | "nbconvert_exporter": "python", 240 | "pygments_lexer": "ipython3", 241 | "version": "3.8.8" 242 | } 243 | }, 244 | "nbformat": 4, 245 | "nbformat_minor": 5 246 | } 247 | -------------------------------------------------------------------------------- /train.sh: -------------------------------------------------------------------------------- 1 | python main.py --config-name=gta5 lam_aug=0.10 name=gta5_baseline 2 | #python main.py --config-name=synthia lam_aug=0.10 lam_fourier=0.00 lam_cutmix=0.00 name=synthia_baseline -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljjcoder/EHTDI/862502b3ae294e3e2dbc613cbba307c33f40441c/utils/__init__.py -------------------------------------------------------------------------------- /utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljjcoder/EHTDI/862502b3ae294e3e2dbc613cbba307c33f40441c/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /utils/__pycache__/eval.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljjcoder/EHTDI/862502b3ae294e3e2dbc613cbba307c33f40441c/utils/__pycache__/eval.cpython-37.pyc -------------------------------------------------------------------------------- /utils/__pycache__/loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljjcoder/EHTDI/862502b3ae294e3e2dbc613cbba307c33f40441c/utils/__pycache__/loss.cpython-37.pyc -------------------------------------------------------------------------------- /utils/eval.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import numpy as np 4 | import torch 5 | from PIL import Image 6 | from datasets.cityscapes_Dataset import name_classes 7 | 8 | np.seterr(divide='ignore', invalid='ignore') 9 | 10 | synthia_set_16 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 15, 17, 18] 11 | synthia_set_13 = [0, 1, 2, 6, 7, 8, 10, 11, 12, 13, 15, 17, 18] 12 | synthia_set_16_to_13 = [0, 1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 13 | name_classes_synthia=[] 14 | for i in synthia_set_16: 15 | name_classes_synthia.append(name_classes[i]) 16 | 17 | class Eval(): 18 | def __init__(self, num_class): 19 | self.num_class = num_class 20 | self.confusion_matrix = np.zeros((self.num_class,) * 2) 21 | self.ignore_index = None 22 | self.synthia = True if num_class == 16 else False 23 | if self.synthia: 24 | self.name_classes=name_classes_synthia 25 | else: 26 | self.name_classes=name_classes 27 | def Pixel_Accuracy(self): 28 | if np.sum(self.confusion_matrix) == 0: 29 | print("Attention: pixel_total is zero!!!") 30 | PA = 0 31 | else: 32 | PA = np.diag(self.confusion_matrix).sum() / self.confusion_matrix.sum() 33 | 34 | return PA 35 | 36 | def Mean_Pixel_Accuracy(self, out_16_13=False): 37 | MPA = np.diag(self.confusion_matrix) / self.confusion_matrix.sum(axis=1) 38 | if self.synthia: 39 | MPA_16 = np.nanmean(MPA[:self.ignore_index]) 40 | MPA_13 = np.nanmean(MPA[synthia_set_16_to_13]) 41 | return MPA_16, MPA_13 42 | if out_16_13: 43 | MPA_16 = np.nanmean(MPA[synthia_set_16]) 44 | MPA_13 = np.nanmean(MPA[synthia_set_13]) 45 | return MPA_16, MPA_13 46 | MPA = np.nanmean(MPA[:self.ignore_index]) 47 | 48 | return MPA 49 | 50 | def Mean_Intersection_over_Union(self, out_16_13=False): 51 | MIoU = np.diag(self.confusion_matrix) / ( 52 | np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) - 53 | np.diag(self.confusion_matrix)) 54 | if self.synthia: 55 | print('class IOU16: ',MIoU[:self.ignore_index]) 56 | print('class IOU13: ',MIoU[synthia_set_16_to_13]) 57 | MIoU_16 = np.nanmean(MIoU[:self.ignore_index]) 58 | MIoU_13 = np.nanmean(MIoU[synthia_set_16_to_13]) 59 | return MIoU_16, MIoU_13 60 | if out_16_13: 61 | print('class IOU16: ',MIoU[synthia_set_16]) 62 | print('class IOU13: ',MIoU[synthia_set_13]) 63 | MIoU_16 = np.nanmean(MIoU[synthia_set_16]) 64 | MIoU_13 = np.nanmean(MIoU[synthia_set_13]) 65 | return MIoU_16, MIoU_13 66 | print('class IOU: ',MIoU[:self.ignore_index]) 67 | MIoU = np.nanmean(MIoU[:self.ignore_index]) 68 | 69 | return MIoU 70 | 71 | def Frequency_Weighted_Intersection_over_Union(self, out_16_13=False): 72 | FWIoU = np.multiply(np.sum(self.confusion_matrix, axis=1), np.diag(self.confusion_matrix)) 73 | FWIoU = FWIoU / (np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) - 74 | np.diag(self.confusion_matrix)) 75 | if self.synthia: 76 | FWIoU_16 = np.sum(i for i in FWIoU if not np.isnan(i)) / np.sum(self.confusion_matrix) 77 | FWIoU_13 = np.sum(i for i in FWIoU[synthia_set_16_to_13] if not np.isnan(i)) / np.sum(self.confusion_matrix) 78 | return FWIoU_16, FWIoU_13 79 | if out_16_13: 80 | FWIoU_16 = np.sum(i for i in FWIoU[synthia_set_16] if not np.isnan(i)) / np.sum(self.confusion_matrix) 81 | FWIoU_13 = np.sum(i for i in FWIoU[synthia_set_13] if not np.isnan(i)) / np.sum(self.confusion_matrix) 82 | return FWIoU_16, FWIoU_13 83 | FWIoU = np.sum(i for i in FWIoU if not np.isnan(i)) / np.sum(self.confusion_matrix) 84 | 85 | return FWIoU 86 | 87 | def Mean_Precision(self, out_16_13=False): 88 | Precision = np.diag(self.confusion_matrix) / self.confusion_matrix.sum(axis=0) 89 | if self.synthia: 90 | Precision_16 = np.nanmean(Precision[:self.ignore_index]) 91 | Precision_13 = np.nanmean(Precision[synthia_set_16_to_13]) 92 | return Precision_16, Precision_13 93 | if out_16_13: 94 | Precision_16 = np.nanmean(Precision[synthia_set_16]) 95 | Precision_13 = np.nanmean(Precision[synthia_set_13]) 96 | return Precision_16, Precision_13 97 | Precision = np.nanmean(Precision[:self.ignore_index]) 98 | return Precision 99 | 100 | def Print_Every_class_Eval(self, out_16_13=False, logger=None): 101 | MIoU = np.diag(self.confusion_matrix) / ( 102 | np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) - 103 | np.diag(self.confusion_matrix)) 104 | MPA = np.diag(self.confusion_matrix) / self.confusion_matrix.sum(axis=1) 105 | Precision = np.diag(self.confusion_matrix) / self.confusion_matrix.sum(axis=0) 106 | Class_ratio = np.sum(self.confusion_matrix, axis=1) / np.sum(self.confusion_matrix) 107 | Pred_retio = np.sum(self.confusion_matrix, axis=0) / np.sum(self.confusion_matrix) 108 | log_fn = print if logger is None else logger.info 109 | log_fn('===>Everyclass:\t' + 'MPA\t' + 'MIoU\t' + 'PC\t' + 'Ratio\t' + 'Pred_Retio') 110 | # if out_16_13: MIoU = MIoU[synthia_set_16] 111 | for ind_class in range(len(MIoU)): 112 | pa = str(round(MPA[ind_class] * 100, 2)) if not np.isnan(MPA[ind_class]) else 'nan' 113 | iou = str(round(MIoU[ind_class] * 100, 2)) if not np.isnan(MIoU[ind_class]) else 'nan' 114 | pc = str(round(Precision[ind_class] * 100, 2)) if not np.isnan(Precision[ind_class]) else 'nan' 115 | cr = str(round(Class_ratio[ind_class] * 100, 2)) if not np.isnan(Class_ratio[ind_class]) else 'nan' 116 | pr = str(round(Pred_retio[ind_class] * 100, 2)) if not np.isnan(Pred_retio[ind_class]) else 'nan' 117 | log_fn('===>' + self.name_classes[ind_class] + ':\t' + pa + '\t' + iou + '\t' + pc + '\t' + cr + '\t' + pr) 118 | 119 | # generate confusion matrix 120 | def __generate_matrix(self, gt_image, pre_image): 121 | 122 | mask = (gt_image >= 0) & (gt_image < self.num_class) 123 | label = self.num_class * gt_image[mask].astype('int') + pre_image[mask] 124 | count = np.bincount(label, minlength=self.num_class**2) 125 | confusion_matrix = count.reshape(self.num_class, self.num_class) 126 | return confusion_matrix 127 | 128 | def add_batch(self, gt_image, pre_image): 129 | # assert the size of two images are same 130 | assert gt_image.shape == pre_image.shape 131 | self.confusion_matrix += self.__generate_matrix(gt_image, pre_image) 132 | 133 | def reset(self): 134 | self.confusion_matrix = np.zeros((self.num_class,) * 2) 135 | 136 | 137 | def softmax(k, axis=None): 138 | exp_k = np.exp(k) 139 | return exp_k / np.sum(exp_k, axis=axis, keepdims=True) 140 | -------------------------------------------------------------------------------- /utils/loss.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from torch.autograd import Variable 5 | import numpy as np 6 | from math import ceil, floor 7 | 8 | def generate_ori_feature(pred_1,pred_2,pred_3,pred_aug_1,pred_aug_2,pred_aug_3,mask_source,x,y): 9 | #print(pred_1.shape) 10 | #print(pred_2.shape) 11 | #print(pred_aug_1.shape) 12 | #print(pred_aug_2.shape) 13 | #print(mask_source.shape) 14 | w=pred_aug_1.shape[2] 15 | #torch.zeros([1,1,pred_1.shape[2],pred_1.shape[3] 16 | pred_1_ori=(pred_aug_1*mask_source+pred_1[:,:,x:x+w,y:y+w]*(1-mask_source)).clone() 17 | pred_2_ori=(pred_aug_2*mask_source+pred_2[:,:,x:x+w,y:y+w]*(1-mask_source)).clone() 18 | pred_aug_1=(pred_aug_1*(1-mask_source)+pred_1[:,:,x:x+w,y:y+w]*(mask_source)) 19 | pred_aug_2=(pred_aug_2*(1-mask_source)+pred_2[:,:,x:x+w,y:y+w]*(mask_source)) 20 | input_size=pred_aug_3.size()[2:] 21 | mask_source = F.interpolate(mask_source.reshape(mask_source.shape[0],-1,mask_source.shape[1],mask_source.shape[2]).float(), size=input_size,mode='nearest').long() 22 | #print(mask_source.shape,pred_3.shape) 23 | #exit() 24 | pred_aug_3=(pred_aug_3*(1-mask_source)+pred_3[:,:,int(x/8):int(x/8)+input_size[0],int(y/8):int(y/8)+input_size[1]]*(mask_source)) 25 | pred_1[:,:,x:x+w,y:y+w]=pred_1_ori 26 | pred_2[:,:,x:x+w,y:y+w]=pred_2_ori 27 | #pred_2[:,:,x:x+w,y:y+w]=pred_2_ori 28 | #print(pred_1.shape) 29 | #print(pred_2.shape) 30 | #print(pred_aug_1.shape) 31 | #print(pred_aug_2.shape) 32 | #exit() 33 | return pred_1,pred_2,pred_aug_1,pred_aug_2,pred_aug_3 34 | 35 | 36 | 37 | def get_target_loss(loss_type, num_classes, ignore_index=-1, IW_ratio=0.2): 38 | if loss_type == "hard": 39 | loss = nn.CrossEntropyLoss(ignore_index=ignore_index) 40 | elif loss_type == "entropy": 41 | loss = softCrossEntropy(ignore_index=ignore_index) 42 | elif loss_type == "IW_entropy": 43 | loss = IWsoftCrossEntropy( 44 | ignore_index=ignore_index, num_class=num_classes, ratio=IW_ratio) 45 | elif loss_type == "maxsquare": 46 | loss = MaxSquareloss( 47 | ignore_index=ignore_index, num_class=num_classes) 48 | elif loss_type == "IW_maxsquare": 49 | loss = IW_MaxSquareloss( 50 | ignore_index=ignore_index, num_class=num_classes, ratio=IW_ratio) 51 | else: 52 | raise NotImplementedError() 53 | return loss 54 | 55 | 56 | class softCrossEntropy(nn.Module): 57 | def __init__(self, ignore_index=-1): 58 | super(softCrossEntropy, self).__init__() 59 | self.ignore_index = ignore_index 60 | return 61 | 62 | def forward(self, inputs, target): 63 | """ 64 | :param inputs: predictions (N, C, H, W) 65 | :param target: target distribution (N, C, H, W) 66 | :return: loss 67 | """ 68 | assert inputs.size() == target.size() 69 | mask = (target != self.ignore_index) 70 | 71 | log_likelihood = F.log_softmax(inputs, dim=1) 72 | loss = torch.mean(torch.mul(-log_likelihood, target)[mask]) 73 | 74 | return loss 75 | 76 | 77 | class IWsoftCrossEntropy(nn.Module): 78 | # class_wise softCrossEntropy for class balance 79 | def __init__(self, ignore_index=-1, num_class=19, ratio=0.2): 80 | super().__init__() 81 | self.ignore_index = ignore_index 82 | self.num_class = num_class 83 | self.ratio = ratio 84 | return 85 | 86 | def forward(self, inputs, target): 87 | """ 88 | :param inputs: predictions (N, C, H, W) 89 | :param target: target distribution (N, C, H, W) 90 | :return: loss with image-wise weighting factor 91 | """ 92 | assert inputs.size() == target.size() 93 | mask = (target != self.ignore_index) 94 | _, argpred = torch.max(inputs, 1) 95 | weights = [] 96 | batch_size = inputs.size(0) 97 | for i in range(batch_size): 98 | hist = torch.histc(argpred[i].cpu().data.float(), 99 | bins=self.num_class, min=0, 100 | max=self.num_class - 1).float() 101 | weight = (1 / torch.max(torch.pow(hist, self.ratio) * torch.pow(hist.sum(), 102 | 1 - self.ratio), torch.ones(1))).to(argpred.device)[argpred[i]].detach() 103 | weights.append(weight) 104 | weights = torch.stack(weights, dim=0) 105 | 106 | log_likelihood = F.log_softmax(inputs, dim=1) 107 | loss = torch.sum((torch.mul(-log_likelihood, target) 108 | * weights)[mask]) / (batch_size * self.num_class) 109 | return loss 110 | 111 | 112 | class IW_MaxSquareloss(nn.Module): 113 | def __init__(self, ignore_index=-1, num_class=19, ratio=0.2): 114 | super().__init__() 115 | self.ignore_index = ignore_index 116 | self.num_class = num_class 117 | self.ratio = ratio 118 | 119 | def forward(self, pred, prob, label=None): 120 | """ 121 | :param pred: predictions (N, C, H, W) 122 | :param prob: probability of pred (N, C, H, W) 123 | :param label(optional): the map for counting label numbers (N, C, H, W) 124 | :return: maximum squares loss with image-wise weighting factor 125 | """ 126 | # prob -= 0.5 127 | N, C, H, W = prob.size() 128 | mask = (prob != self.ignore_index) 129 | maxpred, argpred = torch.max(prob, 1) 130 | mask_arg = (maxpred != self.ignore_index) 131 | argpred = torch.where(mask_arg, argpred, torch.ones(1).to( 132 | prob.device, dtype=torch.long) * self.ignore_index) 133 | if label is None: 134 | label = argpred 135 | weights = [] 136 | batch_size = prob.size(0) 137 | for i in range(batch_size): 138 | hist = torch.histc(label[i].cpu().data.float(), 139 | bins=self.num_class + 1, min=-1, 140 | max=self.num_class - 1).float() 141 | hist = hist[1:] 142 | weight = (1 / torch.max(torch.pow(hist, self.ratio) * torch.pow(hist.sum(), 143 | 1 - self.ratio), torch.ones(1))).to(argpred.device)[argpred[i]].detach() 144 | weights.append(weight) 145 | weights = torch.stack(weights, dim=0) 146 | mask = mask_arg.unsqueeze(1).expand_as(prob) 147 | prior = torch.mean(prob, (2, 3), True).detach() 148 | loss = -torch.sum((torch.pow(prob, 2) * weights) 149 | [mask]) / (batch_size * self.num_class) 150 | return loss 151 | 152 | 153 | class MaxSquareloss(nn.Module): 154 | def __init__(self, ignore_index=-1, num_class=19): 155 | super().__init__() 156 | self.ignore_index = ignore_index 157 | self.num_class = num_class 158 | 159 | def forward(self, pred, prob): 160 | """ 161 | :param pred: predictions (N, C, H, W) 162 | :param prob: probability of pred (N, C, H, W) 163 | :return: maximum squares loss 164 | """ 165 | # prob -= 0.5 166 | mask = (prob != self.ignore_index) 167 | loss = -torch.mean(torch.pow(prob, 2)[mask]) / 2 168 | return loss 169 | -------------------------------------------------------------------------------- /utils/train_helper.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from torch.autograd import Variable 5 | 6 | from graphs.models.new_deeplab_multi import DeeplabMulti as NewDeeplabMulti 7 | from graphs.models.deeplab_multi import DeeplabMulti 8 | from graphs.models.deeplab_vgg import DeeplabVGG 9 | from graphs.models.vgg_fcn8s import VGG16_FCN8s 10 | 11 | def get_model(args): 12 | if args.backbone == "deeplabv2_multi": 13 | model = DeeplabMulti(num_classes=args.num_classes, 14 | pretrained=args.imagenet_pretrained) 15 | elif args.backbone == "new_deeplabv2_multi": 16 | model = NewDeeplabMulti(num_classes=args.num_classes, 17 | pretrained=args.imagenet_pretrained, 18 | use_se=args.use_se, 19 | train_bn=not args.freeze_bn, 20 | norm_style=args.norm_style) 21 | elif args.backbone == 'deeplabv3_resnest50': 22 | from encoding.models import get_segmentation_model 23 | from encoding.nn import SyncBatchNorm 24 | model = get_segmentation_model('deeplab', dataset='citys', backbone='resnest50', aux=True, norm_layer=SyncBatchNorm) 25 | elif args.backbone == 'deeplabv3_resnest101': 26 | from encoding.models import get_segmentation_model 27 | from encoding.nn import SyncBatchNorm 28 | model = get_segmentation_model('deeplab', dataset='citys', backbone='resnest101', aux=True, norm_layer=SyncBatchNorm) 29 | elif args.backbone == 'deeplabv2_vgg': 30 | model = DeeplabVGG(num_classes=args.num_classes) 31 | elif args.backbone == 'vgg16_fcn8s': 32 | model = VGG16_FCN8s(num_classes=args.num_classes) 33 | elif args.backbone == 'hrnet': 34 | raise NotImplementedError() 35 | # from graphs.models.hrnet import HighResolutionNet 36 | # model = HighResolutionNet(cfg) 37 | # model.init_weights(self.args.pretrained_ckpt_file) 38 | else: 39 | raise NotImplementedError() 40 | 41 | if 'deeplabv2' in args.backbone or 'vgg16_fcn8s' == args.backbone: 42 | params = model.optim_parameters(args) 43 | else: 44 | # https://github.com/zhanghang1989/PyTorch-Encoding/blob/master/experiments/segmentation/train.py#L153 45 | params = [{'params': model.pretrained.parameters(), 'lr': args.lr},] 46 | if hasattr(model, 'head'): 47 | params.append({'params': model.head.parameters(), 'lr': args.lr*10}) 48 | print("Model head has 10x LR") 49 | if hasattr(model, 'auxlayer'): 50 | params.append({'params': model.auxlayer.parameters(), 'lr': args.lr*10}) 51 | print("Model auxlayer has 10x LR") 52 | 53 | args.numpy_transform = True 54 | return model, params 55 | --------------------------------------------------------------------------------