26
26
)
27
27
from transformers .utils import is_tf_available , is_torch_available , is_vision_available
28
28
29
- from ...test_processing_common import prepare_image_inputs
29
+ from ...test_processing_common import ProcessorTesterMixin
30
30
31
31
32
32
if is_vision_available ():
43
43
44
44
@require_vision
45
45
@require_torchvision
46
- class SamProcessorTest (unittest .TestCase ):
46
+ class SamProcessorTest (ProcessorTesterMixin , unittest .TestCase ):
47
+ processor_class = SamProcessor
48
+
47
49
def setUp (self ):
48
50
self .tmpdirname = tempfile .mkdtemp ()
49
51
image_processor = SamImageProcessor ()
@@ -56,11 +58,6 @@ def get_image_processor(self, **kwargs):
56
58
def tearDown (self ):
57
59
shutil .rmtree (self .tmpdirname )
58
60
59
- # Processor tester class can't use ProcessorTesterMixin atm because the processor is atypical e.g. only contains an image processor
60
- def prepare_image_inputs (self ):
61
- """This function prepares a list of PIL images."""
62
- return prepare_image_inputs ()
63
-
64
61
def prepare_mask_inputs (self ):
65
62
"""This function prepares a list of PIL images, or a list of numpy arrays if one specifies numpify=True,
66
63
or a list of PyTorch tensors if one specifies torchify=True.
@@ -69,6 +66,21 @@ def prepare_mask_inputs(self):
69
66
mask_inputs = [Image .fromarray (x ) for x in mask_inputs ]
70
67
return mask_inputs
71
68
69
+ def test_chat_template_save_loading (self ):
70
+ self .skipTest ("SamProcessor does not have a tokenizer" )
71
+
72
+ def test_image_processor_defaults_preserved_by_image_kwargs (self ):
73
+ self .skipTest ("SamProcessor does not have a tokenizer" )
74
+
75
+ def test_kwargs_overrides_default_image_processor_kwargs (self ):
76
+ self .skipTest ("SamProcessor does not have a tokenizer" )
77
+
78
+ def test_kwargs_overrides_default_tokenizer_kwargs (self ):
79
+ self .skipTest ("SamProcessor does not have a tokenizer" )
80
+
81
+ def test_tokenizer_defaults_preserved_by_kwargs (self ):
82
+ self .skipTest ("SamProcessor does not have a tokenizer" )
83
+
72
84
def test_save_load_pretrained_additional_features (self ):
73
85
processor = SamProcessor (image_processor = self .get_image_processor ())
74
86
processor .save_pretrained (self .tmpdirname )
@@ -152,7 +164,9 @@ def test_post_process_masks(self):
152
164
153
165
@require_vision
154
166
@require_tf
155
- class TFSamProcessorTest (unittest .TestCase ):
167
+ class TFSamProcessorTest (ProcessorTesterMixin , unittest .TestCase ):
168
+ processor_class = SamProcessor
169
+
156
170
def setUp (self ):
157
171
self .tmpdirname = tempfile .mkdtemp ()
158
172
image_processor = SamImageProcessor ()
@@ -165,10 +179,20 @@ def get_image_processor(self, **kwargs):
165
179
def tearDown (self ):
166
180
shutil .rmtree (self .tmpdirname )
167
181
168
- # Processor tester class can't use ProcessorTesterMixin as processor is atypical e.g. only contains an image processor and it assumes torch
169
- def prepare_image_inputs (self ):
170
- """This function prepares a list of PIL images."""
171
- return prepare_image_inputs ()
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" )
172
196
173
197
def test_save_load_pretrained_additional_features (self ):
174
198
processor = SamProcessor (image_processor = self .get_image_processor ())
@@ -235,7 +259,9 @@ def test_post_process_masks(self):
235
259
236
260
@require_vision
237
261
@require_torchvision
238
- class SamProcessorEquivalenceTest (unittest .TestCase ):
262
+ class SamProcessorEquivalenceTest (ProcessorTesterMixin , unittest .TestCase ):
263
+ processor_class = SamProcessor
264
+
239
265
def setUp (self ):
240
266
self .tmpdirname = tempfile .mkdtemp ()
241
267
image_processor = SamImageProcessor ()
@@ -248,10 +274,20 @@ def get_image_processor(self, **kwargs):
248
274
def tearDown (self ):
249
275
shutil .rmtree (self .tmpdirname )
250
276
251
- # Processor tester class can't use ProcessorTesterMixin atm because the processor is atypical e.g. only contains an image processor
252
- def prepare_image_inputs (self ):
253
- """This function prepares a list of PIL images."""
254
- return prepare_image_inputs ()
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" )
255
291
256
292
@is_pt_tf_cross_test
257
293
def test_post_process_masks_equivalence (self ):
0 commit comments