Image-Text-to-Text
Transformers
PyTorch
English
qwen2_vl
Embedding
text-generation-inference
File size: 10,642 Bytes
5394e9a
 
d94b5f6
 
 
 
 
 
 
 
 
 
 
 
5394e9a
d94b5f6
 
 
 
 
 
 
 
2ce76d7
d94b5f6
 
 
 
e98d039
 
 
 
 
d94b5f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ce76d7
d94b5f6
 
 
2ce76d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d94b5f6
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
---

license: cc-by-nc-4.0
datasets:
- TIGER-Lab/MMEB-train
- Sony/SCaR-Train
language:
- en
metrics:
- accuracy
base_model:
- Qwen/Qwen2-VL-7B-Instruct
library_name: transformers
tags:
- Embedding
---


# VIRTUE Model Card

[VIRTUE-2B-SCaR](https://huggingface.co/Sony/VIRTUE-2B-SCaR) and [VIRTUE-7B-SCaR](https://huggingface.co/Sony/VIRTUE-7B-SCaR) are the official checkpoints for the paper "[VIRTUE: Visual-Interactive Text-Image Universal Embedder](https://arxiv.org/abs/2510.00523)" that are trained with MMEB-Train and SCaR-Train.
VIRTUE is a visual-interactive text-image universal embedder consisting of a VLM as well as a segmentation model to enable the visual interaction modality for human interactions.
In addition, we introduce the SCaR benchmark ([train](https://huggingface.co/datasets/Sony/SCaR-Train), [eval](https://huggingface.co/datasets/Sony/SCaR-Eval)), composed of 1M samples for visual-interactive image-to-text retrieval, to evaluate visual-interactive embedding capabilities.
SCaR enables evaluation of advanced reasoning and compositional tasks in multimodal, visual-interaction-aware embedding scenarios that remain unexplored.

## Model Checkpoints

- [VIRTUE-2B-SCaR](https://huggingface.co/Sony/VIRTUE-2B-SCaR)
- [VIRTUE-7B-SCaR](https://huggingface.co/Sony/VIRTUE-7B-SCaR)

## SCaR Dataset

- [SCaR-Train](https://huggingface.co/datasets/Sony/SCaR-Train)
- [SCaR-Eval](https://huggingface.co/datasets/Sony/SCaR-Eval)

## Experimental Results

### MMEB
- Without SCaR-Train: 

  ![MMEB Results](images/MMEB-results.png)
- With SCaR-Train

  ![MMEB Results with SCaR-Train](images/MMEB-results-with-SCaR.png)


### SCaR
![SCaR Results](images/SCaR-results.png)

## Resources
- [Paper](https://arxiv.org/abs/2510.00523)
- [Webpage](https://sony.github.io/virtue/)
- [Repository](https://github.com/sony/virtue)

## How to Use
```=python

import os

import sys

import torch

import numpy as np

import json

import hydra

from hydra.core.global_hydra import GlobalHydra

from PIL import Image



# Add parent directory to path for src imports

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))



from src.arguments import ModelArguments, DataArguments, TrainingArguments

from src.model.model import MMEBModel

from src.model.processor import load_processor, VLM_IMAGE_TOKENS, get_backbone_name, process_vlm_inputs_fns

from transformers import AutoConfig





# Initialize Hydra for SAM2 loading

if not GlobalHydra().is_initialized():

    hydra.initialize(config_path="./configs", version_base=None)



# Determinism

torch.manual_seed(42)

torch.cuda.manual_seed_all(42)

torch.backends.cudnn.deterministic = True

torch.backends.cudnn.benchmark = False

np.random.seed(42)



model_dir = 'Sony/VIRTUE-2B-SCaR'

device = 'cuda' if torch.cuda.is_available() else 'cpu'



config = AutoConfig.from_pretrained(model_dir, trust_remote_code=True, token=True)



# Build arguments directly (no YAML required)

model_args = ModelArguments(

    model_name=model_dir,

    checkpoint_path=None,

    pooling="last",

    normalize=True,

    lora=False,

    model_backbone='qwen2_vl',

)

persisted_sam = config.virtue_sam



model_args.sam = True

model_args.sam_config = {

    "config_path": persisted_sam.get('config_path') if persisted_sam else None,

    "checkpoint": persisted_sam.get('checkpoint') if persisted_sam else None,

    "points_per_side": (persisted_sam.get('points_per_side') if persisted_sam else 16),

    "feature_levels": (persisted_sam.get('feature_levels') if persisted_sam else 3),

}



data_args = DataArguments()

training_args = TrainingArguments()



processor = load_processor(model_args, data_args)

model = MMEBModel.load(model_args, is_trainable=False, processor=processor)

model.eval()

model = model.to(device, dtype=torch.bfloat16)



# Get model backbone and image token

model_backbone = get_backbone_name(hf_config=config)

image_token = VLM_IMAGE_TOKENS[model_backbone]



# Image + Text -> Text

image_path = '../assets/example.jpg'

image = Image.open(image_path).convert('RGB')



model_inputs = {

    'text': [f"{image_token}\nRepresent the given image with the following question: What is in the image"],

    'images': [image]

}



process_fn = process_vlm_inputs_fns[model_backbone]

inputs = process_fn(model_inputs, processor=processor, max_length=512)

device = next(model.parameters()).device

inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in inputs.items()}



with torch.no_grad():

    with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

        qry_output = model(qry=inputs)["qry_reps"]



# Candidates for all scenarios

test_strings = ['A cat', 'A dog', 'A tiger']



# Scenario 1: No visual prompts (image only)

print("\n--- Similarities (no visual prompts) ---")

for string in test_strings:

    cand_inputs = process_fn({'text': [string], 'images': [None]}, processor=processor)

    cand_inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in cand_inputs.items()}

    with torch.no_grad():

        with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

            tgt_output = model(tgt=cand_inputs)["tgt_reps"]

    sim = model.compute_similarity(qry_output, tgt_output)

    print(f"no-prompt | {string} = {sim}")



'''

--- Similarities (no visual prompts) ---

no-prompt | A cat = tensor([[0.3030]], device='cuda:0')

no-prompt | A dog = tensor([[0.2453]], device='cuda:0')

no-prompt | A tiger = tensor([[0.1714]], device='cuda:0')

'''



# Scenario 2: Point prompts — two examples (left/right)

print("\n--- Similarities (point prompts) ---")

sam_size = 1024  # SAM2Transforms output size

point_examples = [(0.25, 0.5), (0.75, 0.5)]

for (px, py) in point_examples:

    point_text = f"{image_token}\nFind the caption that best describes the segmented object, considering both local details and global context in the given image.\nReferring object point: ({int(px*image.size[0])}, {int(py*image.size[1])})"

    q_inputs = process_fn({'text': [point_text], 'images': [image]}, processor=processor)

    q_inputs['point'] = [px * sam_size, py * sam_size]

    q_inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in q_inputs.items()}

    with torch.no_grad():

        with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

            point_qry = model(qry=q_inputs)["qry_reps"]

    for string in test_strings:

        cand_inputs = process_fn({'text': [string], 'images': [None]}, processor=processor)

        cand_inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in cand_inputs.items()}

        with torch.no_grad():

            with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

                tgt_output = model(tgt=cand_inputs)["tgt_reps"]

        sim = model.compute_similarity(point_qry, tgt_output)

        print(f"point ({px:.2f},{py:.2f}) | {string} = {sim}")



'''

--- Similarities (point prompts) ---

point (0.25,0.50) | A cat = tensor([[0.1793]], device='cuda:0')

point (0.25,0.50) | A dog = tensor([[0.1339]], device='cuda:0')

point (0.25,0.50) | A tiger = tensor([[0.1314]], device='cuda:0')

point (0.75,0.50) | A cat = tensor([[0.2232]], device='cuda:0')

point (0.75,0.50) | A dog = tensor([[0.1742]], device='cuda:0')

point (0.75,0.50) | A tiger = tensor([[0.1692]], device='cuda:0')

'''



# Scenario 3: BBox prompts — two examples (left/right)

print("\n--- Similarities (bbox prompts) ---")

bbox_examples = [

    (0.05, 0.20, 0.45, 0.80),  # left

    (0.55, 0.20, 0.95, 0.80),  # right

]

for (x1, y1, x2, y2) in bbox_examples:

    bbox_text = f"{image_token}\nFind the caption that best describes the object in the bounding box, considering both local details and global context in the given image.\nReferring object bbox: ({int(x1*image.size[0])}, {int(y1*image.size[1])}, {int(x2*image.size[0])}, {int(y2*image.size[1])})"

    q_inputs = process_fn({'text': [bbox_text], 'images': [image]}, processor=processor)

    q_inputs['bbox'] = [x1 * sam_size, y1 * sam_size, x2 * sam_size, y2 * sam_size]

    q_inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in q_inputs.items()}

    with torch.no_grad():

        with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

            bbox_qry = model(qry=q_inputs)["qry_reps"]

    for string in test_strings:

        cand_inputs = process_fn({'text': [string], 'images': [None]}, processor=processor)

        cand_inputs = {k: v.to(device) if torch.is_tensor(v) else v for k, v in cand_inputs.items()}

        with torch.no_grad():

            with torch.autocast(enabled=True, dtype=torch.bfloat16, device_type="cuda"):

                tgt_output = model(tgt=cand_inputs)["tgt_reps"]

        sim = model.compute_similarity(bbox_qry, tgt_output)

        print(f"bbox ({x1:.2f},{y1:.2f},{x2:.2f},{y2:.2f}) | {string} = {sim}")



'''

--- Similarities (bbox prompts) ---

bbox (0.05,0.20,0.45,0.80) | A cat = tensor([[0.2100]], device='cuda:0')

bbox (0.05,0.20,0.45,0.80) | A dog = tensor([[0.1512]], device='cuda:0')

bbox (0.05,0.20,0.45,0.80) | A tiger = tensor([[0.1719]], device='cuda:0')

bbox (0.55,0.20,0.95,0.80) | A cat = tensor([[0.1583]], device='cuda:0')

bbox (0.55,0.20,0.95,0.80) | A dog = tensor([[0.1953]], device='cuda:0')

bbox (0.55,0.20,0.95,0.80) | A tiger = tensor([[0.1225]], device='cuda:0')

'''

```

## Ethical Considerations
_Note: This section is mainly taken from the [AKI](https://huggingface.co/Sony/AKI-4B-phi-3.5-mini) models_.

This release is for research purposes only in support of an academic paper. Our models, datasets, and code are not specifically designed or evaluated for all downstream purposes. We strongly recommend users evaluate and address potential concerns related to accuracy, safety, and fairness before deploying this model. We encourage users to consider the common limitations of AI, comply with applicable laws, and leverage best practices when selecting use cases, particularly for high-risk scenarios where errors or misuse could significantly impact people’s lives, rights, or safety.


## Citation
```

@article{wangICLR2026virtue,

  author       = {Wei-Yao Wang and

                  Kazuya Tateishi and

                  Qiyu Wu and

                  Shusuke Takahashi and

                  Yuki Mitsufuji},

  title        = {VIRTUE: Visual-Interactive Text-Image Universal Embedder},

  journal      = {arXiv preprint arXiv:2510.00523},

  year         = {2025}

}

```