Skip to content

Commit 10ff9fe

Browse files
committed
Fix some tests
1 parent 951396e commit 10ff9fe

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

test/smoke_test.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,21 @@ def smoke_test_torchvision_read_decode() -> None:
3434
raise RuntimeError(f"Unexpected shape of img_webp: {img_webp.shape}")
3535

3636
if sys.platform == "linux":
37-
pass
38-
# img_avif = decode_avif(read_file(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif")))
39-
# if img_avif.shape != (3, 100, 100):
40-
# raise RuntimeError(f"Unexpected shape of img_avif: {img_avif.shape}")
41-
42-
# img_heic = decode_heic(
43-
# read_file(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch_incorrectly_encoded_but_who_cares.heic"))
44-
# )
45-
# if img_heic.shape != (3, 100, 100):
46-
# raise RuntimeError(f"Unexpected shape of img_heic: {img_heic.shape}")
37+
if torch.cuda.is_available():
38+
# TODO: For whatever reason this only passes on the runners that
39+
# support CUDA.
40+
# Strangely, on the CPU runners where this fails, the AVIF/HEIC
41+
# tests (ran with pytest) are passing. This is likely related to a
42+
# libcxx symbol thing.
43+
img_avif = decode_avif(read_file(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif")))
44+
if img_avif.shape != (3, 100, 100):
45+
raise RuntimeError(f"Unexpected shape of img_avif: {img_avif.shape}")
46+
47+
img_heic = decode_heic(
48+
read_file(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch_incorrectly_encoded_but_who_cares.heic"))
49+
)
50+
if img_heic.shape != (3, 100, 100):
51+
raise RuntimeError(f"Unexpected shape of img_heic: {img_heic.shape}")
4752
else:
4853
try:
4954
decode_avif(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif"))

test/test_image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ def test_decode_avif_heic_against_pil(decode_fun, mode, pil_mode, filename):
974974
"no 'ispe' property",
975975
"'iref' has double references",
976976
"Invalid image grid",
977+
"decode_heif failed: Invalid input: No 'meta' box",
977978
)
978979
):
979980
pytest.skip(reason="Expected failure, that's OK")
@@ -990,7 +991,7 @@ def test_decode_avif_heic_against_pil(decode_fun, mode, pil_mode, filename):
990991
try:
991992
from_pil = F.pil_to_tensor(Image.open(filename).convert(pil_mode))
992993
except RuntimeError as e:
993-
if "Invalid image grid" in str(e):
994+
if any(s in str(e) for s in ("Invalid image grid", "Failed to decode image: Not implemented")):
994995
pytest.skip(reason="PIL failure")
995996
else:
996997
raise e

0 commit comments

Comments
 (0)