Safetensors
sailvl
custom_code
Blue-skyyy commited on
Commit
bd6174a
·
verified ·
1 Parent(s): 91209b9

Update processing_sailvl.py

Browse files
Files changed (1) hide show
  1. 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
- for num_patches in image_inputs['num_patches_list']:
132
- image_tokens = '<img>' + '<IMG_CONTEXT>' * self.num_image_token * num_patches + '</img>'
133
- query = query.replace('<image>', image_tokens, 1)
134
- image_inputs.pop('num_patches_list')
 
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()