Home

Awesome

Deep Relational Metric Learning

This repository is the official PyTorch implementation of Deep Relational Metric Learning, which is based on another repository GeDML.

News

Framework

AEL

DRML

Datasets

CUB-200-2011

Download from here.

Organize the dataset as follows:

- cub200
    |- train
    |   |- class0
    |   |   |- image0_1
    |   |   |- ...
    |   |- ...
    |- test
        |- class100
        |   |- image100_1
        |   |- ...
        |- ...

Cars196

Download from here.

Organize the dataset as follows:

- cars196
    |- train
    |   |- class0
    |   |   |- image0_1
    |   |   |- ...
    |   |- ...
    |- test
        |- class98
        |   |- image98_1
        |   |- ...
        |- ...

Requirements

To install requirements:

pip install -r requirements.txt

Training

Baseline models

To train the baseline model with the ProxyAnchor loss on CUB200, run this command:

CUDA_VISIBLE_DEVICES=0 python examples/demo.py --data_path /home/zbr/Workspace/datasets --save_path /home/zbr/Workspace/exp/DRML --device 0 --batch_size 180 --test_batch_size 180 --setting proxy_anchor --embeddings_dim 512 --proxyanchor_margin 0.1 --proxyanchor_alpha 32 --num_classes 100 --wd 0.0001 --gamma 0.5 --step 10 --lr_trunk 0.0001 --lr_embedder 0.0001 --lr_collector 0.01 --dataset cub200 --delete_old --warm_up 1 --warm_up_list embedder collector 

DRML models

To train the proposed DRML model using the ProxyAnchor loss on CUB200 in the paper, run this command:

CUDA_VISIBLE_DEVICES=0 python examples/demo.py --data_path /home/zbr/Workspace/datasets --save_path /home/zbr/Workspace/exp/DRML --device 0 --batch_size 180 --test_batch_size 180 --setting proxy_anchor_drml --embeddings_dim 512 --features_dim 1024 --branch_num 4 --proxyanchor_margin 0.2 --proxyanchor_alpha 64 --num_classes 100 --wd 0.0001 --gamma 0.5 --step 10 --lr_trunk 0.00005 --lr_embedder 0.001 --lr_collector 0.01 --weight_recon_loss 1 --weight_repre_loss 10 --dataset cub200 --delete_old --warm_up 1 --warm_up_list embedder ensemble repre 

Device

We tested our code on a linux machine with an Nvidia RTX 3090 GPU card. We recommend using a GPU card with a memory > 8GB (BN-Inception + batch-size of 120 ).

Results

The baseline models achieve the following performances:

Model nameRecall @ 1Recall @ 2Recall @ 4Recall @ 8NMI
cub200-ProxyAnchor-baseline67.377.785.791.468.7
cars196-ProxyAnchor-baseline84.490.794.396.869.7

Our models achieve the following performances:

Model nameRecall @ 1Recall @ 2Recall @ 4Recall @ 8NMI
cub200-ProxyAnchor-ours68.778.686.391.669.3
cars196-ProxyAnchor-ours86.992.195.297.472.1

COMING SOON

Citation

If you find our work useful in your research, please consider citing:

@inproceedings{zheng2021deep,
  title={Deep Relational Metric Learning},
  author={Zheng, Wenzhao and Zhang, Borui and Lu, Jiwen and Zhou, Jie},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={12065--12074},
  year={2021}
}