Views
No views yet
2024-3-4 🚀🚀 We have released the MMRet-MLLM models on Hugging Face: MMRet-MLLM-S1 and MMRet-MLLM-S2. MMRet-MLLM-S1 is trained exclusively on our MegaPairs dataset, achieving outstanding performance in composed image retrieval, with an 8.1% improvement on the CIRCO benchmark (mAP@5) over the previous state-of-the-art. MMRet-MLLM-S2 builds on MMRet-MLLM-S1 with an additional epoch of fine-tuning on the MMEB benchmark training set, delivering enhanced performance across a broader range of multimodal embedding tasks.2024-12-19 🎉🎉 Release our paper: MegaPairs: Massive Data Synthesis For Universal Multimodal Retrieval.transformers1import torch
2from transformers import AutoModel
3
4MODEL_NAME = "JUNJIE99/MMRet-base" # or "JUNJIE99/MMRet-large"
5
6model = AutoModel.from_pretrained(MODEL_NAME, trust_remote_code=True) # You must set trust_remote_code=True
7model.set_processor(MODEL_NAME)
8model.eval()
9
10with torch.no_grad():
11 query = model.encode(
12 images = "./assets/cir_query.png",
13 text = "Make the background dark, as if the camera has taken the photo at night"
14 )
15
16 candidates = model.encode(
17 images = ["./assets/cir_candi_1.png", "./assets/cir_candi_2.png"]
18 )
19
20 scores = query @ candidates.T
21print(scores)1import torch
2from transformers import AutoModel
3from PIL import Image
4
5MODEL_NAME= "JUNJIE99/MMRet-MLLM-S1"
6
7model = AutoModel.from_pretrained(MODEL_NAME, trust_remote_code=True)
8model.eval()
9model.cuda()
10
11with torch.no_grad():
12 model.set_processor(MODEL_NAME)
13
14 query_inputs = model.data_process(
15 text="Make the background dark, as if the camera has taken the photo at night",
16 images="./assets/cir_query.png",
17 q_or_c="q",
18 task_instruction="Retrieve the target image that best meets the combined criteria by using both the provided image and the image retrieval instructions: "
19 )
20
21 candidate_inputs = model.data_process(
22 images=["./assets/cir_candi_1.png", "./assets/cir_candi_2.png"],
23 q_or_c="c",
24 )
25
26 query_embs = model(**query_inputs, output_hidden_states=True)[:, -1, :]
27 candi_embs = model(**candidate_inputs, output_hidden_states=True)[:, -1, :]
28
29 query_embs = torch.nn.functional.normalize(query_embs, dim=-1)
30 candi_embs = torch.nn.functional.normalize(candi_embs, dim=-1)
31
32 scores = torch.matmul(query_embs, candi_embs.T)
33print(scores)



@article{zhou2024megapairs,
title={MegaPairs: Massive Data Synthesis For Universal Multimodal Retrieval},
author={Zhou, Junjie and Liu, Zheng and Liu, Ze and Xiao, Shitao and Wang, Yueze and Zhao, Bo and Zhang, Chen Jason and Lian, Defu and Xiong, Yongping},
journal={arXiv preprint arXiv:2412.14475},
year={2024}
}