Official PyTorch implementation of Relationship Constraint Deep Metric Learning.
- Python3
- PyTorch (> 1.0)
- NumPy
- tqdm
- wandb
- Pytorch-Metric-Learning
-
Download four public benchmarks for deep metric learning
- CUB-200-2011
- Cars-196 (Img, Annotation)
- Stanford Online Products (Link)
-
Extract the tgz or zip file into
./data/
(Exceptionally, for Cars-196, put the files in a./data/cars196
)
python resave/train_best.py --seed 2412 \
--src 0.01 \ # the weight of Sample Relationship Constraint
--prc 0.05 \ # the weight of Proxy Relationship Constraint
--model bn_inception \
--embedding-size 512 \
--batch-size 128 \
--lr 1e-4 \
--dataset cub
Follow the below steps to evaluate the provided pretrained model or your trained model.
Trained best model will be saved in the ./logs/folder_name
.
# The parameters should be changed according to the model to be evaluated.
python code/evaluate.py --gpu-id 0 \
--batch-size 128 \
--model bn_inception \
--embedding-size 512 \
--dataset cub \
--resume /set/your/model/path/best_model.pth
Our code is modified and adapted on these great repositories: