Deep Relational Metric Learning

This repository is the official PyTorch implementation of Deep Relational Metric Learning.

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/train/main.py \
--save_name <experiment-name> \
--data_path <path-of-data> \
--phase train \
--device 0 \
--setting proxy_baseline \
--dataset cub200 \
--num_classes 100 \
--batch_size 120 \
--delete_old

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

CUDA_VISIBLE_DEVICES=0 python examples/train/main.py \
--save_name <experiment-name> \
--data_path <path-of-data> \
--phase train \
--device 0 \
--setting proxy_baseline \
--dataset cars196 \
--num_classes 98 \
--batch_size 120 \
--delete_old

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/train/main.py \
--save_name <experiment-name> \
--data_path <path-of-data> \
--phase train \
--device 0 \
--setting proxy \
--dataset cub200 \
--num_classes 100 \
--batch_size 120 \
--delete_old

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

CUDA_VISIBLE_DEVICES=0 python examples/train/main.py \
--save_name <experiment-name> \
--data_path <path-of-data> \
--phase train \
--device 0 \
--setting proxy \
--dataset cars196 \
--num_classes 98 \
--batch_size 120 \
--delete_old

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

  • We will upload the code for cross-validation setting soon.
  • We will update the optimal hyper-parameters of the experiments soon.

GitHub

GitHub - zbr17/DRML: [ICCV 2021] Official PyTorch implementation for Deep Relational Metric Learning.
[ICCV 2021] Official PyTorch implementation for Deep Relational Metric Learning. - GitHub - zbr17/DRML: [ICCV 2021] Official PyTorch implementation for Deep Relational Metric Learning.