@@ -81,7 +81,7 @@ def get_image_processor(self, **kwargs):
8181 def get_processor (self , ** kwargs ):
8282 return AutoProcessor .from_pretrained (self .tmpdirname , ** kwargs )
8383
84- def get_splitted_image_expected_tokens (self , processor , image_rows , image_cols ):
84+ def get_split_image_expected_tokens (self , processor , image_rows , image_cols ):
8585 text_split_images = []
8686 for n_h in range (image_rows ):
8787 for n_w in range (image_cols ):
@@ -185,8 +185,8 @@ def test_process_interleaved_images_prompts_image_splitting(self):
185185
186186 # fmt: off
187187 tokenized_sentence = processor .tokenizer (text_str , add_special_tokens = False )
188- splitted_image1_tokens = self .get_splitted_image_expected_tokens (processor , 3 , 4 )
189- expected_input_ids_1 = [[self .bos_token_id ] + splitted_image1_tokens + tokenized_sentence ["input_ids" ]]
188+ split_image1_tokens = self .get_split_image_expected_tokens (processor , 3 , 4 )
189+ expected_input_ids_1 = [[self .bos_token_id ] + split_image1_tokens + tokenized_sentence ["input_ids" ]]
190190 self .assertEqual (inputs ["input_ids" ], expected_input_ids_1 )
191191 self .assertEqual (inputs ["attention_mask" ], [[1 ] * len (expected_input_ids_1 [0 ])])
192192 self .assertEqual (np .array (inputs ["pixel_values" ]).shape , (1 , 13 , 3 , 364 , 364 ))
@@ -210,11 +210,11 @@ def test_process_interleaved_images_prompts_image_splitting(self):
210210 tokenized_sentence_1 = processor .tokenizer (text_str_1 , add_special_tokens = False )
211211 tokenized_sentence_2 = processor .tokenizer (text_str_2 , add_special_tokens = False )
212212
213- splitted_image1_tokens = self .get_splitted_image_expected_tokens (processor , 3 , 4 )
214- splitted_image2_tokens = self .get_splitted_image_expected_tokens (processor , 4 , 4 )
215- splitted_image3_tokens = self .get_splitted_image_expected_tokens (processor , 3 , 4 )
216- expected_input_ids_1 = [self .bos_token_id ] + splitted_image1_tokens + tokenized_sentence_1 ["input_ids" ]
217- expected_input_ids_2 = [self .bos_token_id ] + tokenized_sentence_2 ["input_ids" ] + splitted_image2_tokens + splitted_image3_tokens
213+ split_image1_tokens = self .get_split_image_expected_tokens (processor , 3 , 4 )
214+ split_image2_tokens = self .get_split_image_expected_tokens (processor , 4 , 4 )
215+ split_image3_tokens = self .get_split_image_expected_tokens (processor , 3 , 4 )
216+ expected_input_ids_1 = [self .bos_token_id ] + split_image1_tokens + tokenized_sentence_1 ["input_ids" ]
217+ expected_input_ids_2 = [self .bos_token_id ] + tokenized_sentence_2 ["input_ids" ] + split_image2_tokens + split_image3_tokens
218218 # Pad the first input to match the second input
219219 pad_len = len (expected_input_ids_2 ) - len (expected_input_ids_1 )
220220 padded_expected_input_ids_1 = [self .padding_token_id ] * pad_len + expected_input_ids_1
@@ -240,12 +240,12 @@ def test_add_special_tokens_processor(self):
240240 # fmt: off
241241 inputs = processor (text = text , images = self .image1 , add_special_tokens = False )
242242 tokenized_sentence = processor .tokenizer (text_str , add_special_tokens = False )
243- splitted_image1_tokens = self .get_splitted_image_expected_tokens (processor , 3 , 4 )
244- expected_input_ids = [tokenized_sentence ["input_ids" ] + splitted_image1_tokens ]
243+ split_image1_tokens = self .get_split_image_expected_tokens (processor , 3 , 4 )
244+ expected_input_ids = [tokenized_sentence ["input_ids" ] + split_image1_tokens ]
245245 self .assertEqual (inputs ["input_ids" ], expected_input_ids )
246246
247247 inputs = processor (text = text , images = self .image1 )
248- expected_input_ids = [[self .bos_token_id ] + tokenized_sentence ["input_ids" ] + splitted_image1_tokens ]
248+ expected_input_ids = [[self .bos_token_id ] + tokenized_sentence ["input_ids" ] + split_image1_tokens ]
249249 self .assertEqual (inputs ["input_ids" ], expected_input_ids )
250250 # fmt: on
251251
0 commit comments