Skip to content

Official Code of AAAI 2021 Paper "Multi-level Distance Regularization for Deep Metric Learning"

License

Notifications You must be signed in to change notification settings

kakaoenterprise/AAAI2021_MDR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-level Distance Regularization for Deep Metric Learning

Official Code of AAAI 2021 Paper "Multi-level Distance Regularization for Deep Metric Learning", * Yonghyun Kim and * Wonpyo Park. (* Equal Contribution)

alt tag

Dependencies

You need a CUDA-enabled GPU and python (>3.6) to run the source code.

  • torchvision >= 0.4.2
  • torch >= 1.3.1
  • tqdm
  • scipy
  • Pillow
pip install -r requirements.txt

Preparing datasets

1. Make dataset directory

mkdir ./dataset

2. (Optional) Only for In-Shop Clothes Retrieval

The source code will automatically download CUB-200-2011, Cars-196, and Stanford Online Products datasets.

But you need to manually download In-Shop Clothes Retrieval dataset.

  1. Make Inshop directory in ./dataset directory
mkdir -p ./dataset/Inshop
  1. Download img.zip at the following link, and unzip it in Inshop directory
https://drive.google.com/drive/folders/0B7EVK8r0v71pYkd5TzBiclMzR00
  1. Download list_eval_partition.txt at the following link, and put it in the Inshop directory.
https://drive.google.com/drive/folders/0B7EVK8r0v71pWVBJelFmMW5EWnM

Testing on the trained weights

# The models are trained with Triplet+MDR, please check Table 1.

# CUB-200-2011
wget https://github.com/anonymous-ai-research/pretrained/raw/master/cub200/cub200.pth
python run.py --mode eval --dataset cub200 --load cub200.pth

# Cars-196
wget https://github.com/anonymous-ai-research/pretrained/raw/master/cars196/cars196.pth
python run.py --mode eval --dataset cars196 --load cars196.pth

# Stanford Online Products
wget https://github.com/anonymous-ai-research/pretrained/raw/master/sop/sop.pth
python run.py --mode eval --dataset stanford --load sop.pth

# In-Shop Clothes Retrieval
wget https://github.com/anonymous-ai-research/pretrained/raw/master/inshop/inshop.pth
python run_inshop.py --mode eval --load inshop.pth

Training

# CUB-200-2011
# Triplet
python run.py --dataset cub200 --lr 5e-5 --recall 1 2 4 8
# Triplet+L2Norm
python run.py --dataset cub200 --lr 5e-5 --recall 1 2 4 8 --l2norm
# Triplet+MDR
python run.py --dataset cub200 --lr 5e-5 --recall 1 2 4 8 --lambda-mdr 0.6 --nu-mdr 0.01
# Cars-196
# Triplet
python run.py --dataset cars196 --lr 5e-5 --recall 1 2 4 8
# Triplet+L2Norm
python run.py --dataset cars196 --lr 5e-5 --recall 1 2 4 8 --l2norm
# Triplet+MDR
python run.py --dataset cars196 --lr 5e-5 --recall 1 2 4 8 --lambda-mdr 0.2 --nu-mdr 0.01
# Stanford Online Products
# Triplet
python run.py --dataset stanford --num-image-per-class 3 --batch 256 --lr 1e-4 --recall 1 10 100 1000
# Triplet+L2Norm
python run.py --dataset stanford --num_image_per_class 3 --batch 256 --lr 1e-4 --recall 1 10 100 1000 --l2norm
# Triplet+MDR
python run.py --dataset stanford --num-image-per-class 3 --batch 256 --lr 1e-4 --recall 1 10 100 1000 --lambda-mdr 0.1 --nu-mdr 0.01
# In-Shop Clothes Retrieval
# Triplet
python run_inshop.py --num-image-per-class 3 --batch 256 --lr 1e-4 --recall 1 10 20 30 40 
# Triplet+L2Norm
python run_inshop.py --num-image-per-class 3 --batch 256 --lr 1e-4 --recall 1 10 20 30 40 --l2norm
# Triplet+MDR
python run_inshop.py --num-image-per-class 3 --batch 256 --lr 1e-4 --recall 1 10 20 30 40 --lambda-mdr 0.1 --nu-mdr 0.01

Citation

If you use this method or this code in your research, please cite as:

@InProceedings{Kim_2021_AAAI,
  author = {Kim, Yonghyun and Park, Wonpyo},
  title = {Multi-level Distance Regularization for Deep Metric Learning},
  booktitle = {Proceedings of the 35th AAAI Conference on Artificial Intelligence},
  year = {2021}
}

Contact

Yonghyun Kim

Wonpyo Park

Kakao Enterprise/Vision Team

About

Official Code of AAAI 2021 Paper "Multi-level Distance Regularization for Deep Metric Learning"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages