Skip to content

Source code for CVPR'25 paper "PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval"

License

Notifications You must be signed in to change notification settings

CCRG-XJU/PromptHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌷 PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval [CVPR 2025]

Overview 🌟

PromptHash (Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval) is a method for adaptive hashing retrieval through collaborative cross-modal learning.
This repository contains the code associated with the paper:

"PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval" (accepted to CVPR 2025)
Qiang Zou, Shuli Cheng✉️, and Jiayi Chen


Usage 🛠️

  1. Clone the repository

    git clone https://github.com/ShiShuMo/PromptHash.git
    cd PromptHash
  2. Create and activate the environment

    conda create -n prompthash python=3.12 -y
    conda activate prompthash
  3. Install dependencies

    # Install PyTorch 2.7.1
    pip3 install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128
    
    # Install mamba_ssm
    # See: https://github.com/state-spaces/mamba
    # For CUDA 12.8, download pre-built .whl from the release page
    
    # Install causal-conv1d
    # See: https://github.com/Dao-AILab/causal-conv1d
    # For CUDA 12.8, download pre-built .whl from the release page

Data 🗂️

Directory Structure:

dataset
├── coco
│   ├── caption.mat
│   ├── prompt_caption.npz 
│   ├── index.mat
│   └── label.mat 
├── flickr25k
│   ├── caption.mat
│   ├── prompt_caption.npz
│   ├── index.mat
│   └── label.mat
├── nuswide
│   ├── caption.txt
│   ├── prompt_caption.npz
│   ├── index.mat 
│   └── label.mat
  • Please preprocess the datasets to the required input format.
  • All .mat files have already been uploaded in the ./dataset directory. Use the unzip command to extract them.
  • Cleaned datasets (MIRFLICKR25K, MSCOCO, NUSWIDE), including all files required for experiments, are available via Baidu Netdisk.

🔗 Baidu Netdisk Download
Password: kdq7

(Source: CMCL)


About prompt_caption.npz 📝

The prompt_caption.npz file for each dataset contains:

  • Pseudo-label embeddings generated by large language models.
  • Template sentence embeddings for each dataset sample.

These files are generated and preprocessed for direct use in training and evaluation.
You do not need to generate them yourself.
The prompt_caption.npz files are included in the Baidu Netdisk dataset below.

🔗 Baidu Netdisk Download
Password: krua


Training 🏋️‍♂️

After preparing the Python environment, pretrained MetaCLIP model, and dataset, you can train the PromptHash model.

  • The script will automatically download the required weights. Ensure your network connection is stable.
  • See PromptHash_$DATASET$.sh for training scripts.
  • For hyperparameter settings, refer to the paper.

Evaluation 📊

  • See PromptHash_$DATASET$_TEST.sh for evaluation scripts.
  • Hash code files generated by our algorithm are included in the repository (test.zip), which can be used directly for verification.

Citation 📜

If you find the PromptHash paper and code useful for your research and applications, please cite using this BibTeX:

@InProceedings{Zou_2025_CVPR,
    author    = {Zou, Qiang and Cheng, Shuli and Chen, Jiayi},
    title     = {PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval},
    booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
    month     = {June},
    year      = {2025},
    pages     = {19649-19658}
}

Any Question ✉️

If you have any questions, please feel free to contact:


Acknowledgements 🌸

This project is based on open_clip and CMCL — special thanks to all contributors.


About

Source code for CVPR'25 paper "PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval"

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages