Skip to content

Commit

Permalink
added single and no image to error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yonigozlan committed Oct 24, 2024
1 parent a58d9a4 commit 6b75745
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/models/idefics2/test_processor_idefics2.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@ def test_process_interleaved_images_prompts_image_error(self):
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)

text = [
"This is a test sentence.",
"In this other sentence we try some good things<image>",
]
images = [[self.image1], []]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [[], [self.image2]]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [self.image1, self.image2]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [self.image1]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)

def test_apply_chat_template(self):
# Message contains content which a mix of lists with images and image urls and string
messages = [
Expand Down
18 changes: 18 additions & 0 deletions tests/models/idefics3/test_processor_idefics3.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def test_non_nested_images_with_batched_text(self):
self.assertEqual(np.array(inputs["pixel_values"]).shape, (2, 2, 3, 364, 364))
self.assertEqual(np.array(inputs["pixel_attention_mask"]).shape, (2, 2, 364, 364))

# Copied from tests.models.idefics2.test_processor_idefics2.Idefics2ProcessorTest.test_process_interleaved_images_prompts_image_error
def test_process_interleaved_images_prompts_image_error(self):
processor = self.get_processor()

Expand Down Expand Up @@ -300,6 +301,23 @@ def test_process_interleaved_images_prompts_image_error(self):
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)

text = [
"This is a test sentence.",
"In this other sentence we try some good things<image>",
]
images = [[self.image1], []]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [[], [self.image2]]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [self.image1, self.image2]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)
images = [self.image1]
with self.assertRaises(ValueError):
processor(text=text, images=images, padding=True)

def test_apply_chat_template(self):
# Message contains content which a mix of lists with images and image urls and string
messages = [
Expand Down

0 comments on commit 6b75745

Please sign in to comment.