Skip to content

Commit

Permalink
Add backwards compatibility for KOSMOS-2
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsRogge committed Nov 27, 2023
1 parent 5540458 commit 135bc9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/transformers/models/clip/image_processing_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def __init__(
self.image_std = image_std if image_std is not None else OPENAI_CLIP_STD
self.do_convert_rgb = do_convert_rgb

# for backwards compatibility of KOSMOS-2
if "use_square_size" in kwargs:
self.size = {"height": size["shortest_edge"], "width": size["shortest_edge"]}

def resize(
self,
image: np.ndarray,
Expand Down
2 changes: 1 addition & 1 deletion tests/models/kosmos2/test_processor_kosmos2.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Kosmos2ProcessorTest(unittest.TestCase):
def setUp(self):
self.tmpdirname = tempfile.mkdtemp()

image_processor = CLIPImageProcessor(use_square_size=True)
image_processor = CLIPImageProcessor()

# We have a SentencePiece fixture for testing
slow_tokenizer = XLMRobertaTokenizer(SAMPLE_VOCAB)
Expand Down

0 comments on commit 135bc9d

Please sign in to comment.