[NeurIPS 2021] Official implementation of the paper "One Loss for All: Deep Hashing with a Single Cosine Similarity based Learning Objective"
ArXiv | Supplementary Material
Updated on August, 2022 (Include datasets for instance-level retrieval)
Updated on October, 2022 (Released a general framework for reproducility of other deep hashing methods at (https://github.com/CISiPLab/cisip-FIRe))
This paper proposes a novel deep hashing model with only a single learning objective which is a simplification from most state of the art papers generally use lots of losses and regularizer. Specifically, it maximizes the cosine similarity between the continuous codes and their corresponding binary orthogonal codes to ensure both the discriminative capability of hash codes and the quantization error minimization. Besides, it adopts a Batch Normalization layer to ensure code balance and leverages the Label Smoothing strategy to modify the Cross-Entropy loss to tackle multi-labels classification. Extensive experiments show that the proposed method achieves better performance compared with the state-of-the-art multi-loss hashing methods on several benchmark datasets.
python main.py --codebook-method B --ds cifar10 --margin 0.3 --seed 59495
Run python main.py --help
to check what hyperparameters to run with. All the hyperparameters are the default parameters to get the performance in the paper.
The above command should obtain mAP of 0.824 at best for CIFAR-10.
python val.py -l /path/to/logdir
You may refer to this repo (https://github.com/swuxyj/DeepHash-pytorch) to download the datasets. We were using the same dataset format as HashNet. See utils/datasets.py
to understand how to save the data folder.
Dataset sample: https://raw.githubusercontent.com/swuxyj/DeepHash-pytorch/master/data/imagenet/test.txt
For CIFAR-10, the code will auto generate a dataset at the first run. See utils/datasets.py
.
(Update) The datasets for instance-level retrieval are uploaded here OrthoHash Datasets (address updated Aug 2022)[^1]. ~We still haven't updated the codebase for loading the embedding and the evaluation, but you can still refer to our supplementary metarial for the evaluation protocol.~ Please refer to CISiP-FIRe for embedding loading and evaluation. [^1]: We do not own the datasets. All datasets are own by their authors and we may have done some additional features extraction or processing.
(Update) We have released a general framework for reproducility of other deep hashing methods as well, please head to the this repo (https://github.com/CISiPLab/cisip-FIRe) for the details of loading the embedding.
We have found some tricks to further improve the mAP score.
If you shuffle the order of database before calculate_mAP
, you might get 1~2% improvement in mAP.
It is because many items with same hamming distance will not be sorted properly, hence it will affect the mAP calculation.
--codebook-method O
might help to improve mAP by 1~2%. The improvement is explained in our paper.Suggestions and opinions on this work (both positive and negative) are greatly welcomed. Please contact the authors by sending an email to jiuntian at gmail.com
or kamwoh at gmail.com
or cs.chan at um.edu.my
.
The project is open source under BSD-3 license (see the LICENSE
file).
©2021 Universiti Malaya.