Update processing_sailvl.py
Browse files- processing_sailvl.py +5 -4
processing_sailvl.py
CHANGED
|
@@ -128,10 +128,11 @@ class SAILVLProcessor(ProcessorMixin):
|
|
| 128 |
raise ValueError("Invalid input text. Please provide a string, or a list of strings")
|
| 129 |
|
| 130 |
query = text[0]
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
| 135 |
|
| 136 |
model_inputs = self.tokenizer(query, return_tensors='pt')
|
| 137 |
input_ids = model_inputs['input_ids'].cuda()
|
|
|
|
| 128 |
raise ValueError("Invalid input text. Please provide a string, or a list of strings")
|
| 129 |
|
| 130 |
query = text[0]
|
| 131 |
+
if images is not None:
|
| 132 |
+
for num_patches in image_inputs['num_patches_list']:
|
| 133 |
+
image_tokens = '<img>' + '<IMG_CONTEXT>' * self.num_image_token * num_patches + '</img>'
|
| 134 |
+
query = query.replace('<image>', image_tokens, 1)
|
| 135 |
+
image_inputs.pop('num_patches_list')
|
| 136 |
|
| 137 |
model_inputs = self.tokenizer(query, return_tensors='pt')
|
| 138 |
input_ids = model_inputs['input_ids'].cuda()
|