Skip to content

Caffe implementation of CVPR2019 paper "Hybrid-Attention based Decoupled Metric Learning for Zero-Shot Image Retrieval"

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-Caffe
Notifications You must be signed in to change notification settings

chenbinghui1/Hybrid-Attention-based-Decoupled-Metric-Learning

Repository files navigation

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{chen2019hybrid,
  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.


About

Caffe implementation of CVPR2019 paper "Hybrid-Attention based Decoupled Metric Learning for Zero-Shot Image Retrieval"

Topics

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-Caffe

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published