Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f24d6c

Browse files
committedDec 19, 2024·
Do not add ProcessorTesterMixin everywhere
1 parent d92cd4b commit 6f24d6c

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed
 

‎tests/models/sam/test_processor_sam.py

+11-35
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727
from transformers.utils import is_tf_available, is_torch_available, is_vision_available
2828

29-
from ...test_processing_common import ProcessorTesterMixin
29+
from ...test_processing_common import ProcessorTesterMixin, prepare_image_inputs
3030

3131

3232
if is_vision_available():
@@ -164,9 +164,7 @@ def test_post_process_masks(self):
164164

165165
@require_vision
166166
@require_tf
167-
class TFSamProcessorTest(ProcessorTesterMixin, unittest.TestCase):
168-
processor_class = SamProcessor
169-
167+
class TFSamProcessorTest(unittest.TestCase):
170168
def setUp(self):
171169
self.tmpdirname = tempfile.mkdtemp()
172170
image_processor = SamImageProcessor()
@@ -179,20 +177,10 @@ def get_image_processor(self, **kwargs):
179177
def tearDown(self):
180178
shutil.rmtree(self.tmpdirname)
181179

182-
def test_chat_template_save_loading(self):
183-
self.skipTest("SamProcessor does not have a tokenizer")
184-
185-
def test_image_processor_defaults_preserved_by_image_kwargs(self):
186-
self.skipTest("SamProcessor does not have a tokenizer")
187-
188-
def test_kwargs_overrides_default_image_processor_kwargs(self):
189-
self.skipTest("SamProcessor does not have a tokenizer")
190-
191-
def test_kwargs_overrides_default_tokenizer_kwargs(self):
192-
self.skipTest("SamProcessor does not have a tokenizer")
193-
194-
def test_tokenizer_defaults_preserved_by_kwargs(self):
195-
self.skipTest("SamProcessor does not have a tokenizer")
180+
# This is to avoid repeating the skipping of the common tests
181+
def prepare_image_inputs(self):
182+
"""This function prepares a list of PIL images."""
183+
return prepare_image_inputs()
196184

197185
def test_save_load_pretrained_additional_features(self):
198186
processor = SamProcessor(image_processor=self.get_image_processor())
@@ -259,9 +247,7 @@ def test_post_process_masks(self):
259247

260248
@require_vision
261249
@require_torchvision
262-
class SamProcessorEquivalenceTest(ProcessorTesterMixin, unittest.TestCase):
263-
processor_class = SamProcessor
264-
250+
class SamProcessorEquivalenceTest(unittest.TestCase):
265251
def setUp(self):
266252
self.tmpdirname = tempfile.mkdtemp()
267253
image_processor = SamImageProcessor()
@@ -274,20 +260,10 @@ def get_image_processor(self, **kwargs):
274260
def tearDown(self):
275261
shutil.rmtree(self.tmpdirname)
276262

277-
def test_chat_template_save_loading(self):
278-
self.skipTest("SamProcessor does not have a tokenizer")
279-
280-
def test_image_processor_defaults_preserved_by_image_kwargs(self):
281-
self.skipTest("SamProcessor does not have a tokenizer")
282-
283-
def test_kwargs_overrides_default_image_processor_kwargs(self):
284-
self.skipTest("SamProcessor does not have a tokenizer")
285-
286-
def test_kwargs_overrides_default_tokenizer_kwargs(self):
287-
self.skipTest("SamProcessor does not have a tokenizer")
288-
289-
def test_tokenizer_defaults_preserved_by_kwargs(self):
290-
self.skipTest("SamProcessor does not have a tokenizer")
263+
# This is to avoid repeating the skipping of the common tests
264+
def prepare_image_inputs(self):
265+
"""This function prepares a list of PIL images."""
266+
return prepare_image_inputs()
291267

292268
@is_pt_tf_cross_test
293269
def test_post_process_masks_equivalence(self):

0 commit comments

Comments
 (0)
Please sign in to comment.