metriclearningbench icon indicating copy to clipboard operation
metriclearningbench copied to clipboard

Metric learning models in PyTorch with results on CUB2011, CARS196, Stanford Online Products

trafficstars

Metric learning models in PyTorch, recall@1

CUB2011 CARS196 Stanford Online Products
Margin contrastive loss, semi-hard 0.58 @ epoch60 0.80 @ epoch60 0.7526 @ epoch90
Lifted structured embedding
Triplet loss

Original impl of Margin contrastive loss published at: https://github.com/apache/incubator-mxnet/tree/19ede063c4756fa49cfe741e654180aee33991c6/example/gluon/embedding_learning (temporarily removed in https://github.com/apache/incubator-mxnet/pull/20602)

Examples

# evaluation results are saved in ./data/log.txt

# train margin contrastive loss on CUB2011 using ResNet-50
python train.py --dataset cub2011 --model margin --base resnet50

# download GoogLeNet weights and train using LiftedStruct loss
wget -P ./data https://github.com/vadimkantorov/metriclearningbench/releases/download/data/googlenet.h5
python train.py --dataset cub2011 --model liftedstruct --base inception_v1_googlenet

# evaluate raw final layer embeddings on CUB2011 using ResNet-50
python train.py --dataset cub2011 --model untrained  --epochs 1