Original code for "Zero-Shot Domain Adaptation with a Physics Prior"

Related tags

Deep LearningCIConv
Overview

Zero-Shot Domain Adaptation with a Physics Prior

[arXiv] [sup. material] - ICCV 2021 Oral paper, by Attila Lengyel, Sourav Garg, Michael Milford and Jan van Gemert.

This repository contains the PyTorch implementation of Color Invariant Convolutions and all experiments and datasets described in the paper.

Abstract

We explore the zero-shot setting for day-night domain adaptation. The traditional domain adaptation setting is to train on one domain and adapt to the target domain by exploiting unlabeled data samples from the test set. As gathering relevant test data is expensive and sometimes even impossible, we remove any reliance on test data imagery and instead exploit a visual inductive prior derived from physics-based reflection models for domain adaptation. We cast a number of color invariant edge detectors as trainable layers in a convolutional neural network and evaluate their robustness to illumination changes. We show that the color invariant layer reduces the day-night distribution shift in feature map activations throughout the network. We demonstrate improved performance for zero-shot day to night domain adaptation on both synthetic as well as natural datasets in various tasks, including classification, segmentation and place recognition.

Getting started

All code and experiments have been tested with PyTorch 1.7.0.

Create a local clone of this repository:

git clone https://github.com/Attila94/CIConv

The method directory contains the color invariant convolution (CIConv) layer, as well as custom ResNet and VGG models using the CIConv layer. To use the CIConv layer in your own architecture, simply copy ciconv2d.py to the desired directory and add it as a regular PyTorch layer as

from ciconv2d import CIConv2d
ciconv = CIConv2d('W', k=3, scale=0.0)

See resnet.py and vgg.py for examples.

Datasets

Shapenet Illuminants

[Download link]

Shapenet Illuminants is used in the synthetic classification experiment. The images are rendered from a subset of the ShapeNet dataset using the physically based renderer Mitsuba. The scene is illuminated by a point light modeled as a black-body radiator with temperatures ranging between [1900, 20000] K and an ambient light source. The training set contains 1,000 samples for each of the 10 object classes recorded under "normal" lighting conditions (T = 6500 K). Multiple test sets with 300 samples per class are rendered for a variety of light source intensities and colors.

shapenet_illuminants

Common Objects Day and Night

[Download link]

Common Objects Day and Night (CODaN) is a natural day-night image classification dataset. More information can be found on the separate Github repository: https://github.com/Attila94/CODaN.

codan

Experiments

1. Synthetic classification

  1. Download [link] and unpack the Shapenet Illuminants dataset.
  2. In your local CIConv clone navigate to experiments/1_synthetic_classification and run
python train.py --root 'path/to/shapenet_illuminants' --hflip --seed 0 --invariant 'W'

This will train a ResNet-18 with the 'W' color invariant from scratch and evaluate on all test sets.

shapenet_illuminants_results

Classification accuracy of ResNet-18 with various color invariants. RGB (not invariant) performance degrades when illumination conditions differ between train and test set, while color invariants remain more stable. W performs best overall.

2. CODaN classification

  1. Download the Common Objects Day and Night (CODaN) dataset from https://github.com/Attila94/CODaN.
  2. In your local CIConv clone navigate to experiments/2_codan_classification and run
python train.py --root 'path/to/codan' --invariant 'W' --scale 0. --hflip --jitter 0.3 --rr 20 --seed 0

This will train a ResNet-18 with the 'W' color invariant from scratch and evaluate on all test sets.

Selected results from the paper:

Method Day (% accuracy) Night (% accuracy)
Baseline 80.39 +- 0.38 48.31 +- 1.33
E 79.79 +- 0.40 49.95 +- 1.60
W 81.49 +- 0.49 59.67 +- 0.93
C 78.04 +- 1.08 53.44 +- 1.28
N 77.44 +- 0.00 52.03 +- 0.27
H 75.20 +- 0.56 50.52 +- 1.34

3. Semantic segmentation

  1. Download and unpack the following public datasets: Cityscapes, Nighttime Driving, Dark Zurich.

  2. In your local CIConv clone navigate to experiments/3_segmentation.

  3. Set the proper dataset locations in train.py.

  4. Run

    python train.py --hflip --rc --jitter 0.3 --scale 0.3 --batch-size 6 --pretrained --invariant 'W'

Selected results from the paper:

Method Nighttime Driving (mIoU) Dark Zurich (mIoU)
RefineNet [baseline] 34.1 30.6
W-RefineNet [ours] 41.6 34.5

4. Visual place recognition

  1. Setup conda environment

    conda create -n ciconv python=3.9 mamba -c conda-forge
    conda activate ciconv
    mamba install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 scikit-image -c pytorch
  2. Navigate to experiments/4_visual_place_recognition/cnnimageretrieval-pytorch/.

  3. Run

    git submodule update --init # download a fork of cnnimageretrieval-pytorch
    sh cirtorch/utils/setup_tests.sh # download datasets and pre-trained models 
    python3 -m cirtorch.examples.test --network-path data/networks/retrieval-SfM-120k_w_resnet101_gem/model.path.tar --multiscale '[1, 1/2**(1/2), 1/2]' --datasets '247tokyo1k' --whitening 'retrieval-SfM-120k'
  4. Use --network-path retrievalSfM120k-resnet101-gem to compare against the vanilla method (without using the color invariant trained ResNet101).

  5. Use --datasets 'gp_dl_nr' to test on the GardensPointWalking dataset.

Selected results from the paper:

Method Tokyo 24/7 (mAP)
ResNet101 GeM [baseline] 85.0
W-ResNet101 GeM [ours] 88.3

Citation

If you find this repository useful for your work, please cite as follows:

@article{lengyel2021zeroshot,
      title={Zero-Shot Domain Adaptation with a Physics Prior}, 
      author={Attila Lengyel and Sourav Garg and Michael Milford and Jan C. van Gemert},
      year={2021},
      eprint={2108.05137},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
Owner
Attila Lengyel
PhD candidate @ TU Delft Computer Vision Lab.
Attila Lengyel
Official Repo of my work for SREC Nandyal Machine Learning Bootcamp

About the Bootcamp A 3-day Machine Learning Bootcamp organised by Department of Electronics and Communication Engineering, Santhiram Engineering Colle

MS 1 Nov 29, 2021
AutoPentest-DRL: Automated Penetration Testing Using Deep Reinforcement Learning

AutoPentest-DRL: Automated Penetration Testing Using Deep Reinforcement Learning AutoPentest-DRL is an automated penetration testing framework based o

Cyber Range Organization and Design Chair 217 Jan 01, 2023
A tool for calculating distortion parameters in coordination complexes.

OctaDist Octahedral distortion calculator: A tool for calculating distortion parameters in coordination complexes. https://octadist.github.io/ Registe

OctaDist 12 Oct 04, 2022
Attention-driven Robot Manipulation (ARM) which includes Q-attention

Attention-driven Robotic Manipulation (ARM) This codebase is home to: Q-attention: Enabling Efficient Learning for Vision-based Robotic Manipulation I

Stephen James 84 Dec 29, 2022
DETReg: Unsupervised Pretraining with Region Priors for Object Detection

DETReg: Unsupervised Pretraining with Region Priors for Object Detection Amir Bar, Xin Wang, Vadim Kantorov, Colorado J Reed, Roei Herzig, Gal Chechik

Amir Bar 283 Dec 27, 2022
Myia prototyping

Myia Myia is a new differentiable programming language. It aims to support large scale high performance computations (e.g. linear algebra) and their g

Mila 456 Nov 07, 2022
Large-Scale Unsupervised Object Discovery

Large-Scale Unsupervised Object Discovery Huy V. Vo, Elena Sizikova, Cordelia Schmid, Patrick Pérez, Jean Ponce [PDF] We propose a novel ranking-based

17 Sep 19, 2022
Companion code for the paper "Meta-Learning the Search Distribution of Black-Box Random Search Based Adversarial Attacks" by Yatsura et al.

META-RS This is the companion code for the paper "Meta-Learning the Search Distribution of Black-Box Random Search Based Adversarial Attacks" by Yatsu

Bosch Research 7 Dec 09, 2022
Monocular Depth Estimation - Weighted-average prediction from multiple pre-trained depth estimation models

merged_depth runs (1) AdaBins, (2) DiverseDepth, (3) MiDaS, (4) SGDepth, and (5) Monodepth2, and calculates a weighted-average per-pixel absolute dept

Pranav 39 Nov 21, 2022
Distance Encoding for GNN Design

Distance-encoding for GNN design This repository is the official PyTorch implementation of the DEGNN and DEAGNN framework reported in the paper: Dista

172 Nov 08, 2022
PaRT: Parallel Learning for Robust and Transparent AI

PaRT: Parallel Learning for Robust and Transparent AI This repository contains the code for PaRT, an algorithm for training a base network on multiple

Mahsa 0 May 02, 2022
C3D is a modified version of BVLC caffe to support 3D ConvNets.

C3D C3D is a modified version of BVLC caffe to support 3D convolution and pooling. The main supporting features include: Training or fine-tuning 3D Co

Meta Archive 1.1k Nov 14, 2022
The official pytorch implementation of our paper "Is Space-Time Attention All You Need for Video Understanding?"

TimeSformer This is an official pytorch implementation of Is Space-Time Attention All You Need for Video Understanding?. In this repository, we provid

Facebook Research 1k Dec 31, 2022
Official implementation for Scale-Aware Neural Architecture Search for Multivariate Time Series Forecasting

1 SNAS4MTF This repo is the official implementation for Scale-Aware Neural Architecture Search for Multivariate Time Series Forecasting. 1.1 The frame

SZJ 5 Sep 21, 2022
Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow.

Denoised-Smoothing-TF Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow. Denoised Smoothing is

Sayak Paul 19 Dec 11, 2022
torchlm is aims to build a high level pipeline for face landmarks detection, it supports training, evaluating, exporting, inference(Python/C++) and 100+ data augmentations

💎A high level pipeline for face landmarks detection, supports training, evaluating, exporting, inference and 100+ data augmentations, compatible with torchvision and albumentations, can easily instal

DefTruth 142 Dec 25, 2022
DCSL - Generalizable Crowd Counting via Diverse Context Style Learning

DCSL Generalizable Crowd Counting via Diverse Context Style Learning Requirement

3 Jun 13, 2022
ICCV2021 Papers with Code

ICCV2021 Papers with Code

Amusi 1.4k Jan 02, 2023
DeepSpamReview: Detection of Fake Reviews on Online Review Platforms using Deep Learning Architectures. Summer Internship project at CoreView Systems.

Detection of Fake Reviews on Online Review Platforms using Deep Learning Architectures Dataset: https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polar

Ashish Salunkhe 37 Dec 17, 2022
Yoloxkeypointsegment - An anchor-free version of YOLO, with a simpler design but better performance

Introduction 关键点版本:已完成 全景分割版本:已完成 实例分割版本:已完成 YOLOX is an anchor-free version of

23 Oct 20, 2022