ArXiv | Supplementary Material
Official pytorch implementation of the paper: "One Loss for All: Deep Hashing with a Single Cosine Similarity based Learning Objective"
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.
video_demo.mp4
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
.
- This code base is a simplified version and we did not include everything yet. We will release a version that will include the dataset we have generated and also the corresponding evaluation metrics, stay tune.
(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.
(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.
- As set by the previous protocols, the dataset is small in size (e.g., 13k training images for ImageNet100) and hence overfitting can easily happen during the training.
- We set a 10x lower learning rate for the backbone to avoid overfitting.
- An appropriate higher cosine margin should be able to get higher performance as it slow down the overfitting.
- We did not tune the data augmentation, but we believe that appropriate data augmentation can obtain a little bit of improvement in mAP.
-
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.
- Run with
--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
.
- Deep Polarized Network (DPN) - (https://github.com/kamwoh/DPN)
- Fast Image Retrieval (FIRe) - (https://github.com/CISiPLab/cisip-FIRe)
- You may get slightly different performance as compared with the paper, the random seed sometime affect the performance a lot (because of the generation of the codebook), but should be very close.
- We re-run the training (64-bit ImageNet100) with this simplified version can obtain 0.709~0.710 on average (paper: 0.711).
The project is open source under BSD-3 license (see the LICENSE
file).
©2021 Universiti Malaya.
Footnotes
-
We do not own the datasets. All datasets are own by their authors and we may have done some additional features extraction or processing. ↩