Loading imgutils/preprocess/torchvision.py +2 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,8 @@ def _get_interpolation_mode(value): def _get_int_from_interpolation_mode(value): from torchvision.transforms import InterpolationMode if not isinstance(value, InterpolationMode): raise TypeError(f'Unknown type of interpolation mode, cannot be transformed to int - {value!r}') raise TypeError( f'Unknown type of interpolation mode, cannot be transformed to int - {value!r}') # pragma: no cover _INTERMODE_TO_INT = { InterpolationMode.NEAREST: 0, Loading test/preprocess/test_pillow.py +4 −0 Original line number Diff line number Diff line Loading @@ -1552,3 +1552,7 @@ class TestPreprocessPillow: grid_transparent(expected_image), throw_exception=False ) < 1e-2 def test_pad_to_size_error(self): with pytest.raises(TypeError): PillowPadToSize((512, 512))(np.random.randn(1, 3, 384, 384)) test/preprocess/test_torchvision.py +6 −1 Original line number Diff line number Diff line from typing import Union, Tuple from unittest import skipUnless import numpy as np import pytest from PIL import Image from hbutils.testing import tmatrix Loading @@ -8,7 +9,7 @@ from hbutils.testing import tmatrix from imgutils.data import load_image, grid_transparent from imgutils.preprocess import NotParseTarget, create_pillow_transforms from imgutils.preprocess.torchvision import _get_interpolation_mode, create_torchvision_transforms, \ parse_torchvision_transforms, register_torchvision_transform, register_torchvision_parse parse_torchvision_transforms, register_torchvision_transform, register_torchvision_parse, PadToSize from test.testings import get_testfile try: Loading Loading @@ -353,3 +354,7 @@ class TestPreprocessPillow: ]) def test_pad_to_size_repr_text(self, json_, repr_text): assert repr(create_torchvision_transforms(json_)) == repr_text def test_pad_to_size_error(self): with pytest.raises(TypeError): PadToSize((512, 512))(np.random.randn(1, 3, 384, 384)) Loading
imgutils/preprocess/torchvision.py +2 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,8 @@ def _get_interpolation_mode(value): def _get_int_from_interpolation_mode(value): from torchvision.transforms import InterpolationMode if not isinstance(value, InterpolationMode): raise TypeError(f'Unknown type of interpolation mode, cannot be transformed to int - {value!r}') raise TypeError( f'Unknown type of interpolation mode, cannot be transformed to int - {value!r}') # pragma: no cover _INTERMODE_TO_INT = { InterpolationMode.NEAREST: 0, Loading
test/preprocess/test_pillow.py +4 −0 Original line number Diff line number Diff line Loading @@ -1552,3 +1552,7 @@ class TestPreprocessPillow: grid_transparent(expected_image), throw_exception=False ) < 1e-2 def test_pad_to_size_error(self): with pytest.raises(TypeError): PillowPadToSize((512, 512))(np.random.randn(1, 3, 384, 384))
test/preprocess/test_torchvision.py +6 −1 Original line number Diff line number Diff line from typing import Union, Tuple from unittest import skipUnless import numpy as np import pytest from PIL import Image from hbutils.testing import tmatrix Loading @@ -8,7 +9,7 @@ from hbutils.testing import tmatrix from imgutils.data import load_image, grid_transparent from imgutils.preprocess import NotParseTarget, create_pillow_transforms from imgutils.preprocess.torchvision import _get_interpolation_mode, create_torchvision_transforms, \ parse_torchvision_transforms, register_torchvision_transform, register_torchvision_parse parse_torchvision_transforms, register_torchvision_transform, register_torchvision_parse, PadToSize from test.testings import get_testfile try: Loading Loading @@ -353,3 +354,7 @@ class TestPreprocessPillow: ]) def test_pad_to_size_repr_text(self, json_, repr_text): assert repr(create_torchvision_transforms(json_)) == repr_text def test_pad_to_size_error(self): with pytest.raises(TypeError): PadToSize((512, 512))(np.random.randn(1, 3, 384, 384))