Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add torchscript test for decode_gif #8418

Merged
merged 2 commits into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ def test_pathlib_support(tmpdir):


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

tv_out = read_image(path)
encoded_bytes = read_file(path)
f = torch.jit.script(decode_gif) if scripted else decode_gif
tv_out = f(encoded_bytes)
if tv_out.ndim == 3:
tv_out = tv_out[None]

Expand Down
Loading