ilyassmoummad/hashing-baseline

Pytorch implementation of the paper "Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models", ICASSP 2026

2

stars

5

commits

Python

primary language

Apr 4, 2026

updated

README

Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models (ICASSP 2026)

arXiv

👩‍💻 Authors

1 Ilyass Moummad, 1,2 Kawtar Zaher, 3 Lukas Rauch, 1 Alexis Joly

1 INRIA, LIRMM, Université de Montpellier, France
2 Institut National de l’Audiovisuel, France
3 University of Kassel, Germany


🏗️ Repository Overview

This repository demonstrates a simple, training-free baseline for retrieval of images and audio. It works by combining deep pre-trained features with traditional hashing stepsPCA, random orthogonal projection, and a thresholding operation — to produce compact binary codes.

The resulting Hashing-Baseline produces compact binary codes that:

  • Retain semantic similarity from the pretrained features
  • Allow fast similarity search

This setup provides a straightforward reference for comparing more complex or learned hashing methods on large datasets.


⚙️ Method Overview

Overview of Hashing-Baseline

The Hashing-Baseline pipeline consists of four main steps:

  1. Feature Extraction
    Extract high-dimensional features from images or audio using pre-trained models.

  2. Dimensionality Reduction with PCA
    Apply Principal Component Analysis (PCA) to reduce feature dimensionality while retaining key semantic information.

  3. Random Orthogonal Projection and Binarization
    Project PCA-reduced features with a random orthogonal matrix and binarize by checking whether values are greater than 0, resulting in compact 16-bit hash codes.

  4. Retrieval
    Perform similarity search in Hamming space using the binary codes.

This simple pipeline shows that even standard hashing techniques can preserve semantic similarity when applied on strong pretrained features, without any additional training.


🔎 Retrieval Example

The figure below shows two query images from the Flickr25K dataset and their 5 nearest neighbors, retrieved using features from a SimDINO ViT-B/16 model pretrained on ImageNet-1K (100 epochs).

  • Original features → continuous feature vectors extracted from the backbone (CLS token).
  • Hashed 16-bit codes → binary codes produced by applying our Hashing-Baseline to the original features.

5-NN Retrieval

This demonstrates that Hashing-Baseline preserves semantic similarity, even with compact 16-bit codes.

📂 Repository Structure

  • image/ — Contains code for image retrieval hashing.
    Supports datasets: cifar10, flickr25k, and coco.
    Supported models: dfn and DINOv2/SimDINOv2 via their checkpoints (.pth).
    See image/README.md for detailed instructions.

  • audio/ — Contains code for audio retrieval hashing.
    Supports datasets: esc50, gtzan, and speechcommands.
    Supports models: clap, ced, and dasheng.
    See audio/README.md for detailed instructions.


🚀 Getting Started

  1. Clone the repository
    git clone https://github.com/ilyassmoummad/hashing-baseline
    cd hashing-baseline
    
  2. Create a Python environment
    python -m venv envhashingbaseline
    source envhashingbaseline/bin/activate
    python -m pip install -r requirements.txt
    
  3. Choose your modality folder (image or audio).
  4. Follow the instructions in the README file of the respective folder to download and set up the datasets.
  5. Run the provided scripts with your desired model, dataset, and hashing parameters.

📚 References

Image Models

Audio Models


📝 To cite this work:

@misc{hashingbaseline,
      title={Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models}, 
      author={Ilyass Moummad and Kawtar Zaher and Lukas Rauch and Alexis Joly},
      year={2025},
      eprint={2509.14427},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2509.14427}, 
}

Contributors

ilyassmoummad

5 commits

ilyassmoummad/hashing-baseline

Pytorch implementation of the paper "Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models", ICASSP 2026

2

stars

5

commits

Python

primary language

Apr 4, 2026

updated

README

Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models (ICASSP 2026)

arXiv

👩‍💻 Authors

1 Ilyass Moummad, 1,2 Kawtar Zaher, 3 Lukas Rauch, 1 Alexis Joly

1 INRIA, LIRMM, Université de Montpellier, France
2 Institut National de l’Audiovisuel, France
3 University of Kassel, Germany


🏗️ Repository Overview

This repository demonstrates a simple, training-free baseline for retrieval of images and audio. It works by combining deep pre-trained features with traditional hashing stepsPCA, random orthogonal projection, and a thresholding operation — to produce compact binary codes.

The resulting Hashing-Baseline produces compact binary codes that:

  • Retain semantic similarity from the pretrained features
  • Allow fast similarity search

This setup provides a straightforward reference for comparing more complex or learned hashing methods on large datasets.


⚙️ Method Overview

Overview of Hashing-Baseline

The Hashing-Baseline pipeline consists of four main steps:

  1. Feature Extraction
    Extract high-dimensional features from images or audio using pre-trained models.

  2. Dimensionality Reduction with PCA
    Apply Principal Component Analysis (PCA) to reduce feature dimensionality while retaining key semantic information.

  3. Random Orthogonal Projection and Binarization
    Project PCA-reduced features with a random orthogonal matrix and binarize by checking whether values are greater than 0, resulting in compact 16-bit hash codes.

  4. Retrieval
    Perform similarity search in Hamming space using the binary codes.

This simple pipeline shows that even standard hashing techniques can preserve semantic similarity when applied on strong pretrained features, without any additional training.


🔎 Retrieval Example

The figure below shows two query images from the Flickr25K dataset and their 5 nearest neighbors, retrieved using features from a SimDINO ViT-B/16 model pretrained on ImageNet-1K (100 epochs).

  • Original features → continuous feature vectors extracted from the backbone (CLS token).
  • Hashed 16-bit codes → binary codes produced by applying our Hashing-Baseline to the original features.

5-NN Retrieval

This demonstrates that Hashing-Baseline preserves semantic similarity, even with compact 16-bit codes.

📂 Repository Structure

  • image/ — Contains code for image retrieval hashing.
    Supports datasets: cifar10, flickr25k, and coco.
    Supported models: dfn and DINOv2/SimDINOv2 via their checkpoints (.pth).
    See image/README.md for detailed instructions.

  • audio/ — Contains code for audio retrieval hashing.
    Supports datasets: esc50, gtzan, and speechcommands.
    Supports models: clap, ced, and dasheng.
    See audio/README.md for detailed instructions.


🚀 Getting Started

  1. Clone the repository
    git clone https://github.com/ilyassmoummad/hashing-baseline
    cd hashing-baseline
    
  2. Create a Python environment
    python -m venv envhashingbaseline
    source envhashingbaseline/bin/activate
    python -m pip install -r requirements.txt
    
  3. Choose your modality folder (image or audio).
  4. Follow the instructions in the README file of the respective folder to download and set up the datasets.
  5. Run the provided scripts with your desired model, dataset, and hashing parameters.

📚 References

Image Models

Audio Models


📝 To cite this work:

@misc{hashingbaseline,
      title={Hashing-Baseline: Rethinking Hashing in the Age of Pretrained Models}, 
      author={Ilyass Moummad and Kawtar Zaher and Lukas Rauch and Alexis Joly},
      year={2025},
      eprint={2509.14427},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2509.14427}, 
}

Contributors

ilyassmoummad

5 commits

Languages

Python

100.0%