๐Ÿš€ Setup

July 2, 2025 ยท View on GitHub

๐Ÿ‘€ ImageScope ๐Ÿ‘€

Unifying Language-Guided Image Retrieval via Large Multimodal Model Collective Reasoning

Accepted at WWW 2025

arXiv

Pengfei Luoโ€ , Jingbo Zhouโ€ก, Tong Xuโ€ , Yuan Xiaโ€ก, Linli Xuโ€ , Enhong Chenโ€ 

โ€  University of Science and Technology of China
โ€ก Baidu Inc

Task Image

PWC PWC PWC PWC PWC PWC

๐Ÿš€ Setup

Environment

Create virtual environment:

conda create -n ImageScope python=3.10.14
conda activate ImageScope

Install Pytorch

pip install torch==2.4.0 torchvision==0.19.0 --index-url https://download.pytorch.org/whl/cu118

Install other libraries:

pip install xformers==0.0.27.post2 --index-url https://download.pytorch.org/whl/cu118
pip install https://github.com/vllm-project/vllm/releases/download/v0.5.4/vllm-0.5.4+cu118-cp310-cp310-manylinux1_x86_64.whl
pip install -r requirements.txt

Datasets

Put all dataset in a folder data as follows:

./data
โ”œโ”€โ”€ CIRCO
โ”œโ”€โ”€ CIRR
โ”œโ”€โ”€ FashionIQ
โ”œโ”€โ”€ Flickr30K
โ”œโ”€โ”€ MSCOCO
โ””โ”€โ”€ VisDial

CIRCO

Please follow the instruction of the CIRCO official repository Github Iconmiccunifi/CIRCO to prepare the dataset.

Move the folder unlabeled2017 and the folder CIRCO structure should look like:

./CIRCO
โ”œโ”€โ”€ captions
โ”‚   โ”œโ”€โ”€ val.json
โ”‚   โ””โ”€โ”€ test.json
โ””โ”€โ”€ unlabeled2017
    โ”œโ”€โ”€ 000000572834.jpg
    โ”œโ”€โ”€ 000000088597.jpg
    โ”œโ”€โ”€ 000000386336.jpg
    โ”œโ”€โ”€ ...

CIRR

Please follow the instruction of the CIRR official repository Github IconCuberick-Orion/CIRR to prepare the dataset.

Make the folder CIRR structure looks as follows:

./CIRR
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ captions_ext
โ”‚   โ”œโ”€โ”€ cap.ext.rc2.test1.json
โ”‚   โ”œโ”€โ”€ cap.ext.rc2.train.json
โ”‚   โ”œโ”€โ”€ cap.ext.rc2.val.json
โ”œโ”€โ”€ image_splits
โ”‚   โ”œโ”€โ”€ split.rc2.val.json
โ”‚   โ”œโ”€โ”€ split.rc2.train.json
โ”‚   โ”œโ”€โ”€ split.rc2.test1.json
โ”œโ”€โ”€ dev
โ”‚   โ”œโ”€โ”€ dev-841-3-img0.png
โ”‚   โ”œโ”€โ”€ dev-30-2-img1.png
โ”‚   โ”œโ”€โ”€ dev-954-2-img1.png
โ”‚   โ”œโ”€โ”€ ...
โ”œโ”€โ”€ captions
โ”‚   โ”œโ”€โ”€ cap.rc2.train.json
โ”‚   โ”œโ”€โ”€ ._cap.rc2.val.json
โ”‚   โ”œโ”€โ”€ cap.rc2.val.json
โ”‚   โ”œโ”€โ”€ ...
โ””โ”€โ”€ test1
    โ”œโ”€โ”€ test1-1005-3-img0.png
    โ”œโ”€โ”€ test1-400-0-img1.png
    โ”œโ”€โ”€ test1-718-0-img0.png
    โ”œโ”€โ”€ ...

FashionIQ

Download and extract files form ๐Ÿค—HuggingFace - Plachta/FashionIQ, and organize the folder FashionIQ like:

./FashionIQ
โ”œโ”€โ”€ image_splits
โ”‚   โ”œโ”€โ”€ split.dress.val.json
โ”‚   โ”œโ”€โ”€ split.toptee.val.json
โ”‚   โ”œโ”€โ”€ split.dress.train.json
โ”‚   โ”œโ”€โ”€ ...
โ”œโ”€โ”€ captions
โ”‚   โ”œโ”€โ”€ cap.shirt.test.json
โ”‚   โ”œโ”€โ”€ cap.shirt.val.json
โ”‚   โ”œโ”€โ”€ cap.toptee.test.json
โ”‚   โ”œโ”€โ”€ ...
โ””โ”€โ”€ images
    โ”œโ”€โ”€ B0088D23WY.png
    โ”œโ”€โ”€ B000QB12QY.png
    โ”œโ”€โ”€ B001I90CD2.png
    โ”œโ”€โ”€ ...

Flickr30K

Download and extract files form ๐Ÿค—HuggingFace - nlphuji/flickr_1k_test_image_text_retrieval, and organize the folder Flickr30K like:

./Flickr30K
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ test_1k_flickr.csv
โ”œโ”€โ”€ images_flickr_1k_test.zip
โ”œโ”€โ”€ test_1k_flickr.csv
โ””โ”€โ”€ images
    โ”œโ”€โ”€ 2847514745.jpg
    โ”œโ”€โ”€ 4689169924.jpg
    โ”œโ”€โ”€ 2088705195.jpg
    โ”œโ”€โ”€ ..

MSCOCO

Download and extract files form ๐Ÿค—HuggingFace - nlphuji/mscoco_2014_5k_test_image_text_retrieval, and organize the folder MSCOCO like:

./MSCOCO
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ test_5k_mscoco_2014.csv
โ”œโ”€โ”€ mscoco_2014_5k_test_image_text_retrieval.py
โ”œโ”€โ”€ images_mscoco_2014_5k_test.zip
โ”œโ”€โ”€ .gitattributes
โ””โ”€โ”€ images
    โ”œโ”€โ”€ COCO_val2014_000000466052.jpg
    โ”œโ”€โ”€ COCO_val2014_000000335631.jpg
    โ”œโ”€โ”€ COCO_val2014_000000297972.jpg
    โ”œโ”€โ”€ ...

VisDial

Obtain Protocal/Search_Space_val_50k.json and dialogues/VisDial_v1.0_queries_val.json from the Github IconSaehyung-Lee/PlugIR repository. Download the images COCO 2017 Unlabeled Images. Place the downloaded files in the folder VisDial and organize it as follows:

./VisDial
โ”œโ”€โ”€ Search_Space_val_50k.json
โ”œโ”€โ”€ VisDial_v1.0_queries_val.json
โ””โ”€โ”€ unlabeled2017
    โ”œโ”€โ”€ 000000572834.jpg
    โ”œโ”€โ”€ 000000088597.jpg
    โ”œโ”€โ”€ 000000386336.jpg
    โ”œโ”€โ”€ ...

Once you have completed these steps, your dataset is ready for use.

Models

Download the pre-trained model weights from the links provided below.

RoleModelLink
CaptionerLLaVA-v1.6-vicuna-7B๐Ÿค—llava-hf/llava-v1.6-vicuna-7b-hf
ReasonerLLaMA3-8B-Instruct๐Ÿค—meta-llama/Meta-Llama-3-8B-Instruct
VerifierPaliGemma-3B-mix-224๐Ÿค—google/paligemma-3b-mix-224
EvaluatorInternVL2-8B๐Ÿค—OpenGVLab/InternVL2-8B
VLMCLIP-ViT-B-32-laion2B-s34B-b79K
CLIP-ViT-L-14-laion2B-s32B-b82K
๐Ÿค—laion/CLIP-ViT-B-32-laion2B-s34B-b79K
๐Ÿค—laion/CLIP-ViT-L-14-laion2B-s32B-b82K

You can place the downloaded weights in a directory of your choice, and specify the path to the models in the configuration or script when running the pipeline.

๐Ÿ“ Inference and Evaluation

Inference

To run inference on a specific dataset, modify the model path in the corresponding script located in the script/run_{dataset_name}.sh folder. Replace the placeholder with your actual model path. Once updated, execute the script using the command bash script/run_{dataset_name}.sh to initiate the inference process.

By default, the script utilizes all available GPUs. If you wish to restrict GPU usage, manually configure the CUDA_VISIBLE_DEVICES environment variable. On the first run, the pipeline will automatically create an image_db directory to store image captions and embeddings for retrieval purposes.

Note: For the CIRR subset setting, you need to include the --subset flag in the command within the script.

Evaluation

After completing the inference, evaluation metrics (for FashionIQ, Flickr30K, MSCOCO, and VisDial) or submission files (for CIRCO and CIRR) can be found in the runs folder. Metrics are logged in files located at runs/{dataset_name}/{runs_name}/{clip_version}-{timestamp}/output.log, while prediction results are saved as JSON files at runs/{dataset_name}/{runs_name}/{clip_version}-{timestamp}/{timestamp}_{dataset_name}_test_stage3_eval.json. You can submit these JSON files to the CIRR Evaluation Server or CIRCO Evaluation Server to obtain the final evaluation results.

Experimental Results

Exp Result CIR

Exp Result TIR

๐Ÿ“š Citation

If you find our paper and code are useful in your research, please cite it as follows:

@inproceedings{luo2025imagescope,
  title={ImageScope: Unifying Language-Guided Image Retrieval via Large Multimodal Model Collective Reasoning},
  author={Luo, Pengfei and Zhou, Jingbo and Xu, Tong and Xia, Yuan and Xu, Linli and Chen, Enhong},
  booktitle={The Web Conference 2025},
  year={2025}
}