🌷 PromptHash: Affinity-Prompted Collaborative Cross-Modal Learning for Adaptive Hashing Retrieval [CVPR 2025]
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
-
Clone the repository
git clone https://github.com/ShiShuMo/PromptHash.git cd PromptHash -
Create and activate the environment
conda create -n prompthash python=3.12 -y conda activate prompthash
-
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
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
.matfiles have already been uploaded in the./datasetdirectory. Use theunzipcommand 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)
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
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$.shfor training scripts. - For hyperparameter settings, refer to the paper.
- See
PromptHash_$DATASET$_TEST.shfor evaluation scripts. - Hash code files generated by our algorithm are included in the repository (
test.zip), which can be used directly for verification.
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}
}If you have any questions, please feel free to contact:
- Shuli Cheng (cslxju@xju.edu.cn)
- Qiang Zou (admin@52mss.cn)
This project is based on open_clip and CMCL — special thanks to all contributors.