Skip to content

Commit c9eab68

Browse files
authored
Add torchscript test for decode_gif (#8418)
1 parent 17d972a commit c9eab68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_image.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ def test_pathlib_support(tmpdir):
552552

553553

554554
@pytest.mark.parametrize("name", ("gifgrid", "fire", "porsche", "treescap", "treescap-interlaced", "solid2", "x-trans"))
555-
def test_decode_gif(tmpdir, name):
555+
@pytest.mark.parametrize("scripted", (True, False))
556+
def test_decode_gif(tmpdir, name, scripted):
556557
# Using test images from GIFLIB
557558
# https://sourceforge.net/p/giflib/code/ci/master/tree/pic/, we assert PIL
558559
# and torchvision decoded outputs are equal.
@@ -565,7 +566,9 @@ def test_decode_gif(tmpdir, name):
565566
with open(path, "wb") as f:
566567
f.write(requests.get(url).content)
567568

568-
tv_out = read_image(path)
569+
encoded_bytes = read_file(path)
570+
f = torch.jit.script(decode_gif) if scripted else decode_gif
571+
tv_out = f(encoded_bytes)
569572
if tv_out.ndim == 3:
570573
tv_out = tv_out[None]
571574

0 commit comments

Comments
 (0)