Skip to content

Commit

Permalink
it's Monday let's go
Browse files Browse the repository at this point in the history
  • Loading branch information
ydshieh committed Dec 16, 2024
1 parent 2c47915 commit 395a636
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/models/kosmos2_5/test_processor_kosmos2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,35 @@ def test_model_input_names(self):
with pytest.raises(ValueError):
processor()

@require_torch
@require_vision
def test_structured_kwargs_nested(self):
# Rewrite as KOSMOS-2.5 processor doesn't use `rescale_factor`
if "image_processor" not in self.processor_class.attributes:
self.skipTest(f"image_processor attribute not present in {self.processor_class}")
image_processor = self.get_component("image_processor")
tokenizer = self.get_component("tokenizer")

processor = self.processor_class(tokenizer=tokenizer, image_processor=image_processor)
self.skip_processor_without_typed_kwargs(processor)

input_str = self.prepare_text_inputs()
image_input = self.prepare_image_inputs()

# Define the kwargs for each modality
all_kwargs = {
"common_kwargs": {"return_tensors": "pt"},
"images_kwargs": {"max_patches": 1024},
"text_kwargs": {"padding": "max_length", "max_length": 76},
}

inputs = processor(text=input_str, images=image_input, **all_kwargs)
self.skip_processor_without_typed_kwargs(processor)

self.assertEqual(inputs["flattened_patches"].shape[1], 1024)

self.assertEqual(len(inputs["input_ids"][0]), 76)

@require_torch
def test_full_processor(self):
url = "https://huggingface.co/kirp/kosmos2_5/resolve/main/receipt_00008.png"
Expand Down

0 comments on commit 395a636

Please sign in to comment.