Giter Site home page Giter Site logo

fsdr's Introduction

FSDR: Frequency Space Domain Randomization for Domain Generalization

Updates

Paper

FSDR: Frequency Space Domain Randomization for Domain Generalization
Jiaxing Huang, Dayan Guan, Xiao Aoran, Shijian Lu
School of Computer Science Engineering, Nanyang Technological University, Singapore
IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021

If you find this code useful for your research, please cite our paper:

@InProceedings{Huang_2021_CVPR,
    author    = {Huang, Jiaxing and Guan, Dayan and Xiao, Aoran and Lu, Shijian},
    title     = {FSDR: Frequency Space Domain Randomization for Domain Generalization},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {6891-6902}
}

Abstract

Domain generalization aims to learn a generalizable model from a 'known’ source domain for various 'unknown’ target domains. It has been studied widely by domain randomization that transfers source images to different styles in spatial space for learning domain-agnostic features. However, most existing randomization methods use GANs that often lack of controls and even alter semantic structures of images undesirably. Inspired by the idea of JPEG that converts spatial images into multiple frequency components (FCs), we propose Frequency Space Domain Randomization (FSDR) that randomizes images in frequency space by keeping domain-invariant FCs (DIFs) and randomizing domain-variant FCs (DVFs) only. FSDR has two unique features: 1) it decomposes images into DIFs and DVFs which allows explicit access and manipulation of them and more controllable randomization; 2) it has minimal effects on semantic structures of images and domain-invariant features. We examined domain variance and invariance property of FCs statistically and designed a network that can identify and fuse DIFs and DVFs dynamically through iterative learning. Extensive experiments over multiple domain generalizable segmentation tasks show that FSDR achieves superior segmentation and its performance is even on par with domain adaptation methods that access target data in training.

Preparation

Pre-requisites

  • Python 3.7
  • Pytorch >= 0.4.1
  • CUDA 9.0 or higher

Install FSDR

  1. Clone the repo:
$ git clone https://github.com/jxhuang0508/FSDR.git
$ cd FSDR
  1. Clone ADVENT:
$ git https://github.com/valeoai/ADVENT.git
  1. Initialization:
$ cd ADVENT
$ conda install -c menpo opencv
$ pip install -e <root_dir_of_ADVENT>
$ 

You can also take a look at the ADVENT if you are uncertain about steps to install ADVENT project and environment.

Datasets

Similar to ADVENT, the datasets are put in FSDR/ADVENT/data.

  • Cityscapes: You can follow the guidelines in Cityscape to download the validation images and ground-truths. The Cityscapes dataset directory is supposed to have the following structure:
FSDR/ADVENT/data/Cityscapes/                         % Cityscapes dataset root              
FSDR/ADVENT/data/Cityscapes/leftImg8bit/val          % Cityscapes validation images
FSDR/ADVENT/data/Cityscapes/gtFine/val               % Cityscapes validation ground-truths
...

Prepare FSDR

$ cd ..
$ cp fsdr/domain_adaptation/* ADVENT/advent/domain_adaptation
$ cp fsdr/model/* ADVENT/advent/model
$ cp fsdr/script/test_city_fcn.py ADVENT/advent/script
$ cp fsdr/script/configs/* ADVENT/advent/script/configs

Pre-trained models

Pre-trained models can be downloaded here and put in FSDR/ADVENT/pretrained_models

Evaluation

$ cd FSDR/ADVENT/advent/scripts
$ python test.py --cfg ./configs/fsdr_pretrained.yml
$ Evaluating model /home/jiaxinghuang/ADVENT/experiments/snapshots/GTA2Cityscapes_DeepLabv2_MinEnt/model_50.pth
$  20%|███████████████████▊                                                                               | 100/500 [00:33<02:04,  3.21it/s]100 / 500: 44.26
$  40%|███████████████████████████████████████▌                                                           | 200/500 [01:04<01:35,  3.13it/s]200 / 500: 43.10
$  60%|███████████████████████████████████████████████████████████▍                                       | 300/500 [01:36<01:02,  3.18it/s]300 / 500: 43.56
$  80%|███████████████████████████████████████████████████████████████████████████████▏                   | 400/500 [02:08<00:31,  3.18it/s]400 / 500: 44.04
$ 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 500/500 [02:40<00:00,  3.11it/s]
$	Current mIoU: 44.75
$	Current best model: /home/jiaxinghuang/ADVENT/experiments/snapshots/GTA2Cityscapes_DeepLabv2_MinEnt/model_50.pth
$	Current best mIoU: 44.75
$ road	91.8
$ sidewalk	48.3
$ building	81.99
$ wall	32.49
$ fence	20.69
$ pole	37.28
$ light	37.66
$ sign	26.2
$ vegetation	83.65
$ terrain	38.98
$ sky	60.98
$ person	60.91
$ rider	26.91
$ car	81.54
$ truck	36.89
$ bus	41.58
$ train	0.52
$ motocycle	15.43
$ bicycle	26.46
$ cd FSDR/ADVENT/advent/scripts
$ python test_fcn.py --cfg ./configs/fsdr_pretrained_fcn.yml
$ Evaluating model /home/jiaxinghuang/ADVENT/experiments/snapshots/GTA2Cityscapes_FCN_fsdr_fcn2/model_200.pth
$  20%|████████▏                                | 100/500 [00:34<02:18,  2.89it/s]100 / 500: 45.66
$  40%|████████████████▍                        | 200/500 [01:08<01:39,  3.00it/s]200 / 500: 44.50
$  60%|████████████████████████▌                | 300/500 [01:40<01:01,  3.23it/s]300 / 500: 44.48
$  80%|████████████████████████████████▊        | 400/500 [02:11<00:30,  3.23it/s]400 / 500: 44.18
$ 100%|█████████████████████████████████████████| 500/500 [02:41<00:00,  3.09it/s]
$ 	Current mIoU: 44.86
$ 	Current best model: /home/jiaxinghuang/ADVENT/experiments/snapshots/GTA2Cityscapes_FCN_fsdr_fcn2/model_200.pth
$ 	Current best mIoU: 44.86
$ road	92.07
$ sidewalk	52.6
$ building	82.33
$ wall	26.51
$ fence	27.1
$ pole	35.85
$ light	35.67
$ sign	39.75
$ vegetation	85.33
$ terrain	42.53
$ sky	72.22
$ person	60.24
$ rider	20.95
$ car	84.43
$ truck	33.23
$ bus	36.33
$ train	0.5
$ motocycle	10.04
$ bicycle	14.73

Acknowledgements

This codebase is heavily borrowed from ADVENT and AdaptSegNet.

Contact

If you have any questions, please contact: [email protected]

fsdr's People

Contributors

jxhuang0508 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fsdr's Issues

Largely lower results on BDD and Maphillary

Hi @jxhuang0508 @Dayan-Guan,

I tested your provided models of both deeplabv2 and FCN, and use the advent code to evaluate the three datasets, I got the same results on cityscapes, but got largely lower results on BDD and Maphillary.

DeeplabV2: B=39.37% M=40.66% C=44.75%

FCN: B=36.40% (reported 41.2) M=38.53% (reported 43.4) C=44.86%

Could you provide the testing code for BDD and Maphillary? As well as also provide the training code?

Thanks!

Training code

Hi @jxhuang0508 @Dayan-Guan, thanks for sharing code for your great work.

However, I can only find the testing code. Could you also provide the source code? Thanks!

Also, could you provide the results of VGG, ResNet101 for both FSRD and IBN-Net. I would like to reproduce them.

And, could you also provide the testing code on BDD and Maphillary?

Thanks for your consideration!

关于Spectrum Analysis的问题

作者您好,我想请教一下,在FSDR论文中的3.2节您提出将RGB图片的每个通道都进行64次band-filter,得到了H×W×3×64的数据;在这之后是又对这个数据使用了band reject filter是吗? 还有得到的这个数据再加上batch-size已经达到五维了,这样如何参与模型训练呢?

About the ImageNet images

Hi authors,

Thank you for your great work. Could you provide more details about the subset of ImageNet you were used for domain randomization?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.