Remove use_square_size after loading (#30567)

* fix

* add test

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2024-04-30 21:11:37 +02:00
committed by GitHub
parent 87927b248e
commit 78fdd64dcf
2 changed files with 14 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import os
import shutil
import tempfile
import unittest
from tempfile import TemporaryDirectory
import numpy as np
import pytest
@@ -84,6 +85,15 @@ class Kosmos2ProcessorTest(unittest.TestCase):
return image_inputs
def test_image_procesor_load_save_reload(self):
# make sure load from Hub repo. -> save -> reload locally work
image_processor = CLIPImageProcessor.from_pretrained("microsoft/kosmos-2-patch14-224")
with TemporaryDirectory() as tmp_dir:
image_processor.save_pretrained(tmp_dir)
reloaded_image_processor = CLIPImageProcessor.from_pretrained(tmp_dir)
assert image_processor.to_dict() == reloaded_image_processor.to_dict()
assert image_processor.to_json_string() == reloaded_image_processor.to_json_string()
def test_save_load_pretrained_additional_features(self):
processor = Kosmos2Processor(tokenizer=self.get_tokenizer(), image_processor=self.get_image_processor())
processor.save_pretrained(self.tmpdirname)