Pytorch implementation of four neural network based domain adaptation techniques: DeepCORAL, DDC, CDAN and CDAN+E. Evaluated on benchmark dataset Office31.

Overview

Deep-Unsupervised-Domain-Adaptation


Pytorch implementation of four neural network based domain adaptation techniques: DeepCORAL, DDC, CDAN and CDAN+E. Evaluated on benchmark dataset Office31.

Paper: Evaluation of Deep Neural Network Domain Adaptation Techniques for Image Recognition

Abstract

It has been well proved that deep networks are efficient at extracting features from a given (source) labeled dataset. However, it is not always the case that they can generalize well to other (target) datasets which very often have a different underlying distribution. In this report, we evaluate four different domain adaptation techniques for image classification tasks: Deep CORAL, Deep Domain Confusion (DDC), Conditional Adversarial Domain Adaptation (CDAN) and CDAN with Entropy Conditioning (CDAN+E). The selected domain adaptation techniques are unsupervised techniques where the target dataset will not carry any labels during training phase. The experiments are conducted on the office-31 dataset.

Results

Accuracy performance on the Office31 dataset for the source and domain data distributions (with and without transfer losses).

Deep CORAL DDC
CDAN CDAN+E

Target accuracies for all six domain shifts in Office31 dataset (amazon, webcam and dslr)

Method A → W A → D W → A W → D D → A D → W
No Adaptaion 43.1 ± 2.5 49.2 ± 3.7 35.6 ± 0.6 94.2 ± 3.1 35.4 ± 0.7 90.9 ± 2.4
DeepCORAL 49.5 ± 2.7 40.0 ± 3.3 38.3 ± 0.4 74.4 ± 4.3 38.5 ± 1.5 89.1 ± 4.4
DDC 41.7 ± 9.1 --- --- --- --- ---
CDAN 44.9 ± 3.3 49.5 ± 4.6 34.8 ± 2.4 93.3 ± 3.4 32.9 ± 3.4 88.3 ± 3.8
CDAN+E 48.7 ± 7.5 53.7 ± 4.7 35.3 ± 2.7 93.6 ± 3.4 33.9 ± 2.2 87.7 ± 4.0

Training and inference

To train the model in your computer you must download the Office31 dataset and put it in your data folder.

Execute training of a method by going to its folder (e.g. DeepCORAL):

cd DeepCORAL/
python main.py --epochs 100 --batch_size_source 128 --batch_size_target 128 --name_source amazon --name_target webcam

Loss and accuracy plots

Once the model is trained, you can generate plots like the ones shown above by running:

cd DeepCORAL/
python plot_loss_acc.py --source amazon --target webcam --no_epochs 10

The following is a list of the arguments the usuer can provide:

  • --epochs number of training epochs
  • --batch_size_source batch size of source data
  • --batch_size_target batch size of target data
  • --name_source name of source dataset
  • --name_target name of source dataset
  • --num_classes no. classes in dataset
  • --load_model flag to load pretrained model (AlexNet by default)
  • --adapt_domain bool argument to train with or without specific transfer loss

Requirements

  • tqdm
  • PyTorch
  • matplotlib
  • numpy
  • pickle
  • scikit-image
  • torchvision

References

You might also like...
Official pytorch implement for “Transformer-Based Source-Free Domain Adaptation”
Official pytorch implement for “Transformer-Based Source-Free Domain Adaptation”

Official implementation for TransDA Official pytorch implement for “Transformer-Based Source-Free Domain Adaptation”. Overview: Result: Prerequisites:

Unified unsupervised and semi-supervised domain adaptation network for cross-scenario face anti-spoofing, Pattern Recognition

USDAN The implementation of Unified unsupervised and semi-supervised domain adaptation network for cross-scenario face anti-spoofing, which is accepte

The dataset and source code for our paper: "Did You Ask a Good Question? A Cross-Domain Question IntentionClassification Benchmark for Text-to-SQL"

TriageSQL The dataset and source code for our paper: "Did You Ask a Good Question? A Cross-Domain Question Intention Classification Benchmark for Text

AugLy is a data augmentations library that currently supports four modalities (audio, image, text & video) and over 100 augmentations
AugLy is a data augmentations library that currently supports four modalities (audio, image, text & video) and over 100 augmentations

AugLy is a data augmentations library that currently supports four modalities (audio, image, text & video) and over 100 augmentations. Each modality’s augmentations are contained within its own sub-library. These sub-libraries include both function-based and class-based transforms, composition operators, and have the option to provide metadata about the transform applied, including its intensity.

🧠 A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation.', ECCV 2016
🧠 A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation.', ECCV 2016

Deep CORAL A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation. B Sun, K Saenko, ECCV 2016' Deep CORAL can learn

A Pytorch Implementation of Source Data-free Domain Adaptation for a Faster R-CNN

A Pytorch Implementation of Source Data-free Domain Adaptation for a Faster R-CNN Please follow Faster R-CNN and DAF to complete the environment confi

A Pytorch Implementation of Domain adaptation of object detector using scissor-like networks

A Pytorch Implementation of Domain adaptation of object detector using scissor-like networks Please follow Faster R-CNN and DAF to complete the enviro

(CVPR2021) DANNet: A One-Stage Domain Adaptation Network for Unsupervised Nighttime Semantic Segmentation
(CVPR2021) DANNet: A One-Stage Domain Adaptation Network for Unsupervised Nighttime Semantic Segmentation

DANNet: A One-Stage Domain Adaptation Network for Unsupervised Nighttime Semantic Segmentation CVPR2021(oral) [arxiv] Requirements python3.7 pytorch==

Code to reproduce the experiments in the paper
Code to reproduce the experiments in the paper "Transformer Based Multi-Source Domain Adaptation" (EMNLP 2020)

Transformer Based Multi-Source Domain Adaptation Dustin Wright and Isabelle Augenstein To appear in EMNLP 2020. Read the preprint: https://arxiv.org/a

Comments
  • Presence of target domain labels

    Presence of target domain labels

    I have noticed that most of the UDA experiments on Office 31 or visda provide a train_list.txt and val_list.txt during the dataloader creation stage. Doesn't providing the list for both source and target domain defeat the purpose of unsupervised domain adaptation where target domain has no information about the target labels.

    I was looking at the organization of office 31 dataset as well as the dataloader part in your code,and i feel that during training based on how data is being loaded ,the model will have access to the real target domain labels as well. Of course,if there is something which I am missing here please correct me.

    opened by sparshgarg23 0
  • About CORAL Loss

    About CORAL Loss

    There maybe a wrong with CORAL Loss loss = torch.norm(torch.mul((source_covariance-target_covariance), (source_covariance-target_covariance)), p="fro") It should be loss = torch.norm((source_covariance-target_covariance), p="fro")

    opened by ZhouWenjun2019 2
Owner
Alan Grijalva
M. Sc. Student in Autonomous Systems, B. Sc. Physics.
Alan Grijalva
Adversarial Adaptation with Distillation for BERT Unsupervised Domain Adaptation

Knowledge Distillation for BERT Unsupervised Domain Adaptation Official PyTorch implementation | Paper Abstract A pre-trained language model, BERT, ha

Minho Ryu 29 Nov 30, 2022
A PyTorch implementation for Unsupervised Domain Adaptation by Backpropagation(DANN), support Office-31 and Office-Home dataset

DANN A PyTorch implementation for Unsupervised Domain Adaptation by Backpropagation Prerequisites Linux or OSX NVIDIA GPU + CUDA (may CuDNN) and corre

null 8 Apr 16, 2022
LoveDA: A Remote Sensing Land-Cover Dataset for Domain Adaptive Semantic Segmentation (NeurIPS2021 Benchmark and Dataset Track)

LoveDA: A Remote Sensing Land-Cover Dataset for Domain Adaptive Semantic Segmentation by Junjue Wang, Zhuo Zheng, Ailong Ma, Xiaoyan Lu, and Yanfei Zh

Kingdrone 174 Dec 22, 2022
[ICLR 2021] "Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective" by Wuyang Chen, Xinyu Gong, Zhangyang Wang

Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective [PDF] Wuyang Chen, Xinyu Gong, Zhangyang Wang In ICLR 2

VITA 156 Nov 28, 2022
Employs neural networks to classify images into four categories: ship, automobile, dog or frog

Neural Net Image Classifier Employs neural networks to classify images into four categories: ship, automobile, dog or frog Viterbi_1.py uses a classic

Riley Baker 1 Jan 18, 2022
Code for CVPR2021 "Visualizing Adapted Knowledge in Domain Transfer". Visualization for domain adaptation. #explainable-ai

Visualizing Adapted Knowledge in Domain Transfer @inproceedings{hou2021visualizing, title={Visualizing Adapted Knowledge in Domain Transfer}, auth

Yunzhong Hou 80 Dec 25, 2022
[CVPR2021] Domain Consensus Clustering for Universal Domain Adaptation

[CVPR2021] Domain Consensus Clustering for Universal Domain Adaptation [Paper] Prerequisites To install requirements: pip install -r requirements.txt

Guangrui Li 84 Dec 26, 2022
CDTrans: Cross-domain Transformer for Unsupervised Domain Adaptation

CDTrans: Cross-domain Transformer for Unsupervised Domain Adaptation [arxiv] This is the official repository for CDTrans: Cross-domain Transformer for

null 238 Dec 22, 2022
CDTrans: Cross-domain Transformer for Unsupervised Domain Adaptation

[ICCV2021] TransReID: Transformer-based Object Re-Identification [pdf] The official repository for TransReID: Transformer-based Object Re-Identificati

DamoCV 569 Dec 30, 2022