Pix2StructImageProcessor requires torch>=1.11.0 (#24270)
* fix * fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,10 @@ from ...test_image_processing_common import ImageProcessingSavingTestMixin, prep
|
||||
if is_torch_available():
|
||||
import torch
|
||||
|
||||
from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
|
||||
else:
|
||||
is_torch_greater_or_equal_than_1_11 = False
|
||||
|
||||
if is_vision_available():
|
||||
from PIL import Image
|
||||
|
||||
@@ -70,6 +74,10 @@ class Pix2StructImageProcessingTester(unittest.TestCase):
|
||||
return raw_image
|
||||
|
||||
|
||||
@unittest.skipIf(
|
||||
not is_torch_greater_or_equal_than_1_11,
|
||||
reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`.",
|
||||
)
|
||||
@require_torch
|
||||
@require_vision
|
||||
class Pix2StructImageProcessingTest(ImageProcessingSavingTestMixin, unittest.TestCase):
|
||||
@@ -237,6 +245,10 @@ class Pix2StructImageProcessingTest(ImageProcessingSavingTestMixin, unittest.Tes
|
||||
)
|
||||
|
||||
|
||||
@unittest.skipIf(
|
||||
not is_torch_greater_or_equal_than_1_11,
|
||||
reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`.",
|
||||
)
|
||||
@require_torch
|
||||
@require_vision
|
||||
class Pix2StructImageProcessingTestFourChannels(ImageProcessingSavingTestMixin, unittest.TestCase):
|
||||
|
||||
@@ -48,6 +48,9 @@ if is_torch_available():
|
||||
Pix2StructVisionModel,
|
||||
)
|
||||
from transformers.models.pix2struct.modeling_pix2struct import PIX2STRUCT_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
|
||||
else:
|
||||
is_torch_greater_or_equal_than_1_11 = False
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -697,6 +700,10 @@ def prepare_img():
|
||||
return im
|
||||
|
||||
|
||||
@unittest.skipIf(
|
||||
not is_torch_greater_or_equal_than_1_11,
|
||||
reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`.",
|
||||
)
|
||||
@require_vision
|
||||
@require_torch
|
||||
@slow
|
||||
|
||||
@@ -19,9 +19,14 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
from transformers.testing_utils import require_torch, require_vision
|
||||
from transformers.utils import is_vision_available
|
||||
from transformers.utils import is_torch_available, is_vision_available
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
|
||||
else:
|
||||
is_torch_greater_or_equal_than_1_11 = False
|
||||
|
||||
if is_vision_available():
|
||||
from PIL import Image
|
||||
|
||||
@@ -34,6 +39,10 @@ if is_vision_available():
|
||||
)
|
||||
|
||||
|
||||
@unittest.skipIf(
|
||||
not is_torch_greater_or_equal_than_1_11,
|
||||
reason="`Pix2StructImageProcessor` requires `torch>=1.11.0`.",
|
||||
)
|
||||
@require_vision
|
||||
@require_torch
|
||||
class Pix2StructProcessorTest(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user