Skip to content
Caffe implementation of "Hybrid-Attention based Decoupled Metric Learning for Zero-Shot Image Retrieval"
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake
docker 2019.4.2 Apr 2, 2019
docs 2019.4.2 Apr 2, 2019
evaluation update readme.md Apr 2, 2019
examples/CUB update readme.md Apr 2, 2019
include/caffe 2019.4.2 Apr 2, 2019
scripts
src
tools 2019.4.2 Apr 2, 2019
CMakeLists.txt 2019.4.2 Apr 2, 2019
LICENSE 2019.4.2 Apr 2, 2019
LICENSE-Caffe 2019.4.2 Apr 2, 2019
Makefile
Makefile.config 2019.4.2 Apr 2, 2019
Makefile.config (copy).example 2019.4.2 Apr 2, 2019
README.md update readme.md Apr 3, 2019
README.md~ update readme.md Apr 3, 2019
caffe.cloc 2019.4.2 Apr 2, 2019

README.md

Code for CVPR 2019 Paper "Hybrid-Attention based Decoupled Metric Learning for Zero-Shot Image Retrieval"

This code is developed based on Caffe.

Updates

  • Apr 02, 2019
    • The code and training prototxt for our CVPR19 paper are released.
    • For simplication, we use Hinge_Loss-like adversarial constraint instead of the original adversary network (This will reduce the final performance a little but ease the training. We also provide the "gradients_reverse_layer" for the implementation of the orginal adversary network, you can try it by yourself.).
    • If you train our Network on CUB-200, the expected retrieval performance of DeML(I=3,J=3) will be ~(R@1=64.7, R@2=75.1, R@4=83.2, R@8=89.4) at ~10k iterations.

Files

  • Original Caffe library
  • BinomialLoss
    • src/caffe/proto/caffe.proto
    • include/caffe/layers/Binomial_loss_layer.hpp
    • src/caffe/layers/Binomial_loss_layer.cpp
  • ActLoss
    • src/caffe/proto/caffe.proto
    • include/caffe/layers/act_loss.hpp
    • src/caffe/layers/act_loss.cpp
  • OAM
    • src/caffe/proto/caffe.proto
    • include/caffe/layers/proposal_crop_layer.hpp (For single convolution input)
    • src/caffe/layers/proposal_crop_layer.cpp (For single convolution input)
    • include/caffe/layers/proposal_crop_layer.hpp (For multi convolution input)
    • src/caffe/layers/proposal_crop_layer.cpp (For multi convolution input)
  • gradients_reverse
    • src/caffe/proto/caffe.proto
    • include/caffe/layers/gradients_reverse_layer.hpp
    • src/caffe/layers/gradients_reverse_layer.cpp
    • src/caffe/layers/gradients_reverse_layer.cu
  • CUB
    • examples/CUB/U512 (This is for the implementation of baseline method U512)
    • examples/CUB/DeML3-3_512 (This is for the implementation of our method DeML(I=3,J=3))
    • examples/CUB/pre-trained-model

Prerequisites

  • Caffe
  • Matlab (for evaluation)
  • 2GPUs, each > 11G

Train_Model

  1. The Installation is completely the same as Caffe. Please follow the installation instructions. Make sure you have correctly installed before using our code.
  2. Download the training images CUB {google drive, baidu(psw:w3vh)} and move it to $(your_path). The images are preprossed the same as Lifted Loss, i.e. with zero paddings.
  3. Download the training list(400M) {google drive, baidu (psw:xbct)}, and move it to folder "~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/". (Or you can create your own list by randomly selecting 65 classes with 2 samples each class.)
  4. Download googlenetV1 (used for U512) and 3nets {google drive, baidu(psw:dmev)} (used for DeML3-3_512) to folder "~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/pre-trained-model/". (each stream of 3nets model is intialized by the same googlenetV1 model)
  5. Modify the images path by changing "root_folder" into $(your_path) in all *.prototxt .
  6. Then you can train our baseline method U512 and the proposed DeML(I=3,J=3) by running
        cd ~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/U512
        ./finetune_U512.sh

and

        cd ~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/DeML3-3_512
        ./finetune_DeML3-3_512.sh

the trained models are stored in folder "run_U512/" and "run_DeML3-3_512/" respectively.

Extract_DeepFeature

  1. run the following code for U512 and DeML(I=3,J=3) respectively.
        cd ~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/U512
        ./extractfeatures.sh
        cd ~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/examples/CUB/DeML3-3_512
        ./extractfeatures.sh

the feature files are stored at folder "features/"

Evaluation

  1. Run code in folder "~/Hybrid-Attention-based-Decoupled-Metric-Learning-master/evaluation/"

Contact

Citation

You are encouraged to cite the following papers if this work helps your research.

@inproceedings{chen2017hybrid,
  title={Hybrid-Attention based Decoupled metric Learning for Zero-Shot Image Retrieval},
  author={Chen, Binghui and Deng, Weihong},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2019},
}
@InProceedings{chen2019energy,
author = {Chen, Binghui and Deng, Weihong},
title = {Energy Confused Adversarial Metric Learning for Zero-Shot Image Retrieval and Clustering},
booktitle = {AAAI Conference on Artificial Intelligence},
year = {2019}
}
@inproceedings{songCVPR16,
Author = {Hyun Oh Song and Yu Xiang and Stefanie Jegelka and Silvio Savarese},
Title = {Deep Metric Learning via Lifted Structured Feature Embedding},
Booktitle = {Computer Vision and Pattern Recognition (CVPR)},
Year = {2016}
}

License

Copyright (c) Binghui Chen

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


You can’t perform that action at this time.