Skip to content

A PyTorch implementation of DaCo based on APIN 2023 paper "DaCo: Domain-Agnostic Contrastive Learning for Visual Place Recognition"

Notifications You must be signed in to change notification settings

leftthomas/DaCo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DaCo

A PyTorch implementation of DaCo based on APIN 2023 paper DaCo: Domain-Agnostic Contrastive Learning for Visual Place Recognition.

Network Architecture

Requirements

conda install pytorch=1.7.0 torchvision cudatoolkit=11.0 -c pytorch

Dataset

Tokyo 24/7, Cityscapes FoggyDBF and Synthia Seqs datasets are used in this repo, you could download these datasets from official websites, or download them from MEGA. The data should be rearranged, please refer the paper to acquire the details of train/val split. The data directory structure is shown as follows:

├──tokyo
  ├── original (orignal images)
      ├── domain_a (day images)
          ├── train
              ├── day_00001.jpg
              └── ...
          ├── val
              ├── day_00301.jpg
              └── ...
      ├── domain_b (night images)
          ├── train
              ├── night_00001.jpg
              └── ...
          ├── val
              ├── night_00301.jpg
              └── ...
  ├── generated (generated images)
      same structure as original
      ...
├──cityscapes
  same structure as tokyo
  ...
├──synthia
  same structure as tokyo 
  ... 

Usage

python main.py --data_name synthia --method_name simclr
optional arguments:
--data_root                   Datasets root path [default value is 'data']
--data_name                   Dataset name [default value is 'tokyo'](choices=['tokyo', 'cityscapes', 'synthia'])
--method_name                 Method name [default value is 'daco'](choices=['daco', simsiam', 'simclr', 'moco', 'npid'])
--hidden_dim                  Hidden feature dim for projection head [default value is 512]
--temperature                 Temperature used in softmax [default value is 0.1]
--batch_size                  Number of images in each mini-batch [default value is 16]
--iters                       Number of bp over the model to train [default value is 10000]
--ranks                       Selected recall [default value is [1, 2, 4, 8]]
--save_root                   Result saved root path [default value is 'result']
--lamda                       Lambda used for the weight of soft constrain [default value is 0.8]
--negs                        Negative sample number [default value is 4096]
--momentum                    Momentum used for the update of memory bank or shadow model [default value is 0.5]

For example, to train moco on cityscapes:

python main.py --data_name cityscapes --method_name moco --batch_size 32 --momentum 0.999

to train npid on tokyo:

python main.py --data_name tokyo --method_name npid --batch_size 64 --momentum 0.5

Benchmarks

The models are trained on one NVIDIA GTX TITAN (12G) GPU. Adam is used to optimize the model, lr is 1e-3 and weight decay is 1e-6. batch size is 16 for daco, 32 for simsiam, simclr and moco, 64 for npid. momentum is 0.999 for moco, 0.5 for npid, other hyper-parameters are the default values.

Tokyo 24/7

Method Day --> Night Night --> Day Day <--> Night Download
R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8
NPID 6.67 10.67 17.33 28.00 8.00 12.00 16.00 21.33 2.00 4.00 5.33 10.67 r2bg
MoCo 5.33 6.67 12.00 17.33 6.67 9.33 12.00 16.00 0.00 0.00 0.00 0.67 f2jt
SimCLR 25.33 32.00 45.33 56.00 33.33 37.33 46.67 58.67 8.67 9.33 14.00 18.67 agdw
SimSiam 4.00 5.33 9.33 16.00 4.00 5.33 6.67 14.67 1.33 1.33 1.33 3.33 d2i4
DaCo 61.33 68.00 78.67 84.00 60.00 70.67 81.33 88.00 45.33 56.67 64.00 74.67 5dzs

Foggy Cityscapes

Method Clear --> Foggy Foggy --> Clear Clear <--> Foggy Download
R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8
NPID 5.60 7.80 10.20 17.20 5.20 8.40 12.60 19.80 0.20 0.50 0.70 1.00 bbiv
MoCo 0.40 0.80 1.40 3.00 0.40 0.80 1.80 3.40 0.20 0.20 0.20 0.20 ma2a
SimCLR 34.60 48.00 59.60 71.40 54.60 66.80 78.40 86.00 0.50 1.00 1.70 2.90 hdhn
SimSiam 0.60 1.00 1.60 2.40 0.80 1.00 1.80 2.80 0.00 0.00 0.00 0.00 dau5
DaCo 98.80 99.60 99.80 100.0 98.60 99.20 99.40 99.80 90.20 96.00 98.60 99.20 azvx

Synthia Seqs

Method Sunset --> Rainy Night Rainy Night --> Sunset Sunset <--> Rainy Night Download
R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8 R@1 R@2 R@4 R@8
NPID 8.33 10.00 11.67 20.00 6.67 6.67 18.33 21.67 5.00 5.00 10.00 11.67 bgua
MoCo 5.00 5.00 8.33 16.67 10.00 15.00 16.67 25.00 1.67 1.67 1.67 3.33 sw7f
SimCLR 23.33 30.00 46.67 51.67 25.00 33.33 48.33 63.33 6.67 10.83 16.67 20.83 afeg
SimSiam 10.00 13.33 15.00 23.33 5.00 10.00 21.67 30.00 3.33 5.00 6.67 8.33 bjnj
DaCo 55.00 68.33 75.00 88.33 41.67 51.67 70.00 83.33 25.00 34.17 50.00 66.67 sasq

Results

Tokyo 24/7

tokyo

Foggy Cityscapes

cityscapes

Synthia Seqs

synthia

T-SNE

tsne

About

A PyTorch implementation of DaCo based on APIN 2023 paper "DaCo: Domain-Agnostic Contrastive Learning for Visual Place Recognition"

Topics

Resources

Stars

Watchers

Forks

Languages