Official implementation of "DSP: Dual Soft-Paste for Unsupervised Domain Adaptive Semantic Segmentation"

Related tags

Deep Learning DSP
Overview

DSP

Official implementation of "DSP: Dual Soft-Paste for Unsupervised Domain Adaptive Semantic Segmentation". Accepted by ACM Multimedia 2021.

Authors: Li Gao, Jing Zhang, Lefei Zhang, Dacheng Tao.

Prerequisite

  • CUDA/CUDNN
  • Python3
  • PyTorch==1.7
  • Packages found in requirements.txt
  1. Creat a new conda environment
conda create -n dsp_env python=3.7
conda activate dsp_env
conda install pytorch=1.7 torchvision torchaudio cudatoolkit -c pytorch
pip install -r requirements.txt
  1. Download the code from github and change the directory
git clone https://github.com/GaoLii/DSP/
cd DSP
  1. Prepare dataset

Download Cityscapes, GTA5 and SYNTHIA dataset, then organize the folder as follows:

├── ../../dataset/
│   ├── Cityscapes/     
|   |   ├── gtFine/
|   |   ├── leftImg8bit/
│   ├── GTA5/
|   |   ├── images/
|   |   ├── labels/
│   ├── RAND_CITYSCAPES/ 
|   |   ├── GT/
|   |   ├── RGB/
...

Training and Evaluation example

Training and evaluation are on a single Tesla V100 GPU with 16G memory.

Train with unsupervised domain adaptation

GTA5->CityScapes

python train_DSP.py --config ./configs/configUDA_gta.json --name UDA_gta

SYNTHIA->CityScapes

python train_DSP.py --config ./configs/configUDA_syn.json --name UDA_syn

Evaluation

python evaluateUDA.py --model-path checkpoint.pth

Pretrained models

This model should be unzipped in the '../saved' folder.

License

The code is heavily borrowed from DACS.

If you use this code in your research please consider citing

@article{Gao_2021,
   title={DSP: Dual Soft-Paste for Unsupervised Domain Adaptive Semantic Segmentation},
   url={https://arxiv.org/abs/2107.09600},
   DOI={10.1145/3474085.3475186},
   journal={Proceedings of the 29th ACM International Conference on Multimedia},
   publisher={ACM},
   author={Gao, Li and Zhang, Jing and Zhang, Lefei and Tao, Dacheng},
   year={2021},
   month={Oct}
}
  
Comments
  • How to run your method on a different setup?

    How to run your method on a different setup?

    Hi,

    Thanks for your contribution and the publication of your code. I was wondering if it is possible to run your method in a different setup, for example, let's say that I want to adapt Cityscapes ===> BDD.

    I have tried to run this setup by making some minor modifications but it seems like your method is conditioned to these id2json class-wise objects, which I do not know how I can generate those files for the aforementioned setup Cityscapes ===> BDD.

    Could you please help me out on this?

    opened by fabriziojpiva 1
  • The mistake in Tabel 2 of paper

    The mistake in Tabel 2 of paper

    Thanks for sharing the code, it's really an awesome work!

    But there seems to exist a mistake in "Table 2: Results of different domain adaptation methods for the SYNTHIA → Cityscapes task".

    The mIoU* of 13 classes should be 59.9 but not 63.8 according to the IoU per class, can you check it?

    opened by super233 1
  • the difference between tthe offered pretrained model and the model in ulr

    the difference between tthe offered pretrained model and the model in ulr

    hi, I want to ask is there any difference between the pretrained models in the baidu cloud and the model in http://vllab1.ucmerced.edu/~whung/adv-semi-seg/resnet101COCO-41f33a49.pth. And could you do me a favor to offer the model in http://vllab1.ucmerced.edu/~whung/adv-semi-seg/resnet101COCO-41f33a49.pth? I can't connect to that and download it.

    opened by ywher 0
  • Could GPU 3090 run your code.

    Could GPU 3090 run your code.

    RuntimeError: CUDA out of memory. Tried to allocate 18.00 MiB (GPU 0; 23.70 GiB total capacity; 1.38 GiB already allocated; 7.00 MiB free; 1.42 GiB reserved in total by PyTorch)
    

    I have two 3090 GPU. But it CUDA out of memory

    opened by yuheyuan 0
  • Long tail class inmixing

    Long tail class inmixing

    Hello, first of all thanks for the contribution and sharing the code. I have been using this implementation for a while and considering the class "rand_mixer" for mixing the long tail classes with source/target inputs, I notice that the long tail classes tend to not show up in the mixed result. To ilustrate the issue, I add some screenshots of plots for each variable.

    Considering the code, I believe that the long tail class mixing in line 325 in train.py:

       data, target = transformsgpu.oneMix(MixMask, data=mixdata, target=mixtarget)
    

    I introduced plotting the data and targets before and after this function to see the long tail mixing in action with the following code:

          plot_input(MixMask, 'mask_lt', 'Mask over the long tail class image', save=True)
          plot_input(img, 'image_lt', "Image where the long tail class is in", save=True)
          plot_input(lbl, 'label_lt', 'Label of the longtail class image', save=True)
    
          data, target = transformsgpu.oneMix(MixMask, data=mixdata, target=mixtarget)
    
          plot_input(mixdata[1], 'image_lt', 'Image where the long tail class comes in', save=True)
          plot_input(data[0], 'image_lt', 'Mixed image', save=True)
    
          plot_input(mixtarget[1], 'label_lt', 'Label where the long tail class comes in', save=True)
          plot_input(target[0], 'label_lt', 'Mixed label', save=True)
    

    The plot input functions that is used above, is shown here:

       def plot_input(input, input_type, name=None, save=False):
        with torch.no_grad():
    
            if input_type == 'image_lt':  # Image while in long tail function
                input = input.cpu().detach().numpy()
    
                input = np.transpose(input, (1, 2, 0))
    
                image = input + IMG_MEAN
                image = image[:, :, ::-1]
     
                plt.imshow(image.astype(int))
    
    
            elif input_type == 'mask_lt': # mask while in long tail function
    
                input = input.cpu().detach().numpy()
                plt.imshow(input, cmap='binary')
    
            elif input_type == 'label_lt': # label while in long tail function
    
                input = input.cpu().detach().numpy()
                color_mask = cm_eval(input)
                # print(color_mask)
                plt.imshow(color_mask)
    
            else:
                print("Incorrect input for creating an image")
    
            if not (name is None):
                title_obj = plt.title(name)  # get the title property handler
                plt.getp(title_obj)
    
            if save:
                start_writeable = datetime.datetime.now().strftime('%m-%d_%H-%M')
                plt.savefig(os.path.join("./saved/images", start_writeable+input_type+name), bbox_inches='tight')
            plt.show()
    

    So when I plot this. The following figures are displayed:

    • The Mask over the long tail image: 12-14_10-56mask_ltMask over the long tail class image

    • The Image with the long tail class object in it: 12-14_10-56image_ltImage where the long tail class is in

    • The Label with the long tail class object in it: 12-14_10-56label_ltLabel of the longtail class image

    • The Image where the long tail class object comes into: 12-14_10-57image_ltImage where the long tail class comes in

    • The Label where the long tail class object comes into: 12-14_10-57label_ltLabel where the long tail class comes in

    • The Image with the long tail class object mixed in: 12-14_10-57image_ltMixed image

    • The Label with the long tail class object mixed in: 12-14_10-57label_ltMixed label

    As you can see, the long tail class is not mixed into the image. This happens in every occasion, but in many situations the long tail class is really small, so not visible in the image. Above a clear example is shown.

    Countering the argument above, I have had two times a situation, where the image with the long tail class objects was overwritten in the image and label partly. However, this was done in a small strip in the vertical direction. An additional requirement for this to occur, was that the long tail class object was at the (x,0) position. I have established to save one of those examples. These are shown below:

    • The Mask over the long tail image: 12-14_10-52mask_ltMask over the long tail class image

    • The Image with the long tail class object in it: 12-14_10-52image_ltImage where the long tail class is in

    • The Label with the long tail class object in it: 12-14_10-52label_ltLabel of the longtail class image

    • The Image where the long tail class object comes into: 12-14_10-52image_ltImage where the long tail class comes in

    • The Label where the long tail class object comes into: 12-14_10-52label_ltLabel where the long tail class comes in

    • The Image with the long tail class object mixed in: 12-14_10-52image_ltMixed image

    • The Label with the long tail class object mixed in: 12-14_10-52label_ltMixed label

    Could someone explain this behavior to me? And if possible suggest a solution to this problem.

    opened by guuske31 0
  • Some questions

    Some questions

    Thanks for your sharing code, it's really an awesome work! I have 2 questions as follows:

    1. Does there exist the warmup stage of adversarial training?
    2. I notice that is only used in DSP, considering that the process is in a soft manner, why is it not used as a weight to compute loss?
    opened by super233 0
  • Error when running training with batch size = 4

    Error when running training with batch size = 4

    If I try to double the current batch size of 2 to 4, I get the following error:

    torch.Size([2, 19, 512, 512]) torch.Size([4, 512, 512]) Traceback (most recent call last): File "train.py", line 819, in <module> main() File "train.py", line 660, in main L_l2 = loss_calc(logits_t_s, labels) * (1-lam) + lam * loss_calc(logits_t_s, targets_t) File "train.py", line 112, in loss_calc return criterion(pred, label) File "~/miniconda3/envs/dsp_env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "~/projects/DSP/utils/loss.py", line 30, in forward predict = predict[target_mask.view(n, h, w, 1).repeat(1, 1, 1, c)].view(-1, c) I have printed the shapes and it seems like logits_t_s still has a batch size of 2. Any particular reason for this?

    opened by fabriziojpiva 0
  • Training time and problem of DACS training curve reported in your paper

    Training time and problem of DACS training curve reported in your paper

    Hi, I try to reproduce your code (gta5 -> cityscapes) and I found that it has a very slow training speed, which is nearly 4x slower than the DACS. I wonder why... And also, can I ask you the total training time for you to reproduce the result (miou =55) ? Another issue is I found that the training curve of DACS in your paper is mismatch with my experiment result as below, I wonder how you get the result in your paper ? My experiment on DACS Screen Shot 2021-08-15 at 11 54 49 PM

    Yours Screen Shot 2021-08-15 at 11 56 18 PM

    opened by mimiliaogo 1
Owner
null
Official implementation of AAAI-21 paper "Label Confusion Learning to Enhance Text Classification Models"

Description: This is the official implementation of our AAAI-21 accepted paper Label Confusion Learning to Enhance Text Classification Models. The str

null 101 Nov 25, 2022
Official PyTorch implementation for paper Context Matters: Graph-based Self-supervised Representation Learning for Medical Images

Context Matters: Graph-based Self-supervised Representation Learning for Medical Images Official PyTorch implementation for paper Context Matters: Gra

null 49 Nov 23, 2022
The official implementation of NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021]. https://arxiv.org/pdf/2101.12378.pdf

NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021] Release Notes The offical PyTorch implementation of NeMo, p

Angtian Wang 76 Nov 23, 2022
StyleGAN2-ADA - Official PyTorch implementation

Abstract: Training generative adversarial networks (GAN) using too little data typically leads to discriminator overfitting, causing training to diverge. We propose an adaptive discriminator augmentation mechanism that significantly stabilizes training in limited data regimes.

NVIDIA Research Projects 3.2k Dec 30, 2022
Official implementation of the ICLR 2021 paper

You Only Need Adversarial Supervision for Semantic Image Synthesis Official PyTorch implementation of the ICLR 2021 paper "You Only Need Adversarial S

Bosch Research 272 Dec 28, 2022
Official PyTorch implementation of Joint Object Detection and Multi-Object Tracking with Graph Neural Networks

This is the official PyTorch implementation of our paper: "Joint Object Detection and Multi-Object Tracking with Graph Neural Networks". Our project website and video demos are here.

Richard Wang 443 Dec 6, 2022
Official implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis https://arxiv.org/abs/2011.13775

CIPS -- Official Pytorch Implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis Requirements pip install -r requi

Multimodal Lab @ Samsung AI Center Moscow 201 Dec 21, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement Official pytorch implementation of paper "Image-to-image Translation

null 364 Dec 14, 2022
Official pytorch implementation of paper "Inception Convolution with Efficient Dilation Search" (CVPR 2021 Oral).

IC-Conv This repository is an official implementation of the paper Inception Convolution with Efficient Dilation Search. Getting Started Download Imag

Jie Liu 111 Dec 31, 2022
Official PyTorch Implementation of Unsupervised Learning of Scene Flow Estimation Fusing with Local Rigidity

UnRigidFlow This is the official PyTorch implementation of UnRigidFlow (IJCAI2019). Here are two sample results (~10MB gif for each) of our unsupervis

Liang Liu 28 Nov 16, 2022
Official implementation of our paper "LLA: Loss-aware Label Assignment for Dense Pedestrian Detection" in Pytorch.

LLA: Loss-aware Label Assignment for Dense Pedestrian Detection This project provides an implementation for "LLA: Loss-aware Label Assignment for Dens

null 35 Dec 6, 2022
Official implementation of Self-supervised Graph Attention Networks (SuperGAT), ICLR 2021.

SuperGAT Official implementation of Self-supervised Graph Attention Networks (SuperGAT). This model is presented at How to Find Your Friendly Neighbor

Dongkwan Kim 127 Dec 28, 2022
An official implementation of "SFNet: Learning Object-aware Semantic Correspondence" (CVPR 2019, TPAMI 2020) in PyTorch.

PyTorch implementation of SFNet This is the implementation of the paper "SFNet: Learning Object-aware Semantic Correspondence". For more information,

CV Lab @ Yonsei University 87 Dec 30, 2022
This project is the official implementation of our accepted ICLR 2021 paper BiPointNet: Binary Neural Network for Point Clouds.

BiPointNet: Binary Neural Network for Point Clouds Created by Haotong Qin, Zhongang Cai, Mingyuan Zhang, Yifu Ding, Haiyu Zhao, Shuai Yi, Xianglong Li

Haotong Qin 59 Dec 17, 2022
Official code implementation for "Personalized Federated Learning using Hypernetworks"

Personalized Federated Learning using Hypernetworks This is an official implementation of Personalized Federated Learning using Hypernetworks paper. [

Aviv Shamsian 121 Dec 25, 2022
StyleGAN2 - Official TensorFlow Implementation

StyleGAN2 - Official TensorFlow Implementation

NVIDIA Research Projects 10.1k Dec 28, 2022
Old Photo Restoration (Official PyTorch Implementation)

Bringing Old Photo Back to Life (CVPR 2020 oral)

Microsoft 11.3k Dec 30, 2022
Official implementation of "GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators" (NeurIPS 2020)

GS-WGAN This repository contains the implementation for GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators (NeurIPS

null 46 Nov 9, 2022
Official PyTorch implementation of Spatial Dependency Networks.

Spatial Dependency Networks: Neural Layers for Improved Generative Image Modeling Đorđe Miladinović   Aleksandar Stanić   Stefan Bauer   Jürgen Schmid

Djordje Miladinovic 34 Jan 19, 2022