Skip to content

[NeurIPS 2021] Official implementation of the paper "One Loss for All: Deep Hashing with a Single Cosine Similarity based Learning Objective"

License

Notifications You must be signed in to change notification settings

kamwoh/orthohash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrthoHash

ArXiv | Supplementary Material

Official pytorch implementation of the paper: "One Loss for All: Deep Hashing with a Single Cosine Similarity based Learning Objective"

NeurIPS 2021

(Released on September 29, 2021)

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))

Description

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

How to run

Training

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.

Testing

python val.py -l /path/to/logdir

Dataset

Category-level Retrieval (ImageNet, NUS-WIDE, MS-COCO)

Instance-level Retrieval (GLDv2, ROxf, RPar)

  • 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.

Performance Tuning (Some Tricks)

We have found some tricks to further improve the mAP score.

Avoid Overfitting

  • 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.

An appropriate learning rate for backbone

  • We set a 10x lower learning rate for the backbone to avoid overfitting.

Cosine Margin

  • An appropriate higher cosine margin should be able to get higher performance as it slow down the overfitting.

Data Augmentation

  • We did not tune the data augmentation, but we believe that appropriate data augmentation can obtain a little bit of improvement in mAP.

Database Shuffling

  • 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

  • Run with --codebook-method O might help to improve mAP by 1~2%. The improvement is explained in our paper.

Feedback

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.

Related Work

  1. Deep Polarized Network (DPN) - (https://github.com/kamwoh/DPN)
  2. Fast Image Retrieval (FIRe) - (https://github.com/CISiPLab/cisip-FIRe)

Notes

  1. 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.
  2. We re-run the training (64-bit ImageNet100) with this simplified version can obtain 0.709~0.710 on average (paper: 0.711).

License and Copyright

The project is open source under BSD-3 license (see the LICENSE file).

©2021 Universiti Malaya.

Footnotes

  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.