Skip to content

Commit 5c83466

Browse files
committed
Added smoke test
1 parent dd1c53c commit 5c83466

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packaging/post_build_script.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/bin/bash
22
LD_LIBRARY_PATH="/usr/local/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" python packaging/wheel/relocate.py
3+
4+
pip install torchvision-extra-decoders

test/smoke_test.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import torch
88
import torchvision
9-
from torchvision.io import decode_image, decode_jpeg, decode_webp, read_file
9+
from torchvision.io import decode_avif, decode_heic, decode_image, decode_jpeg, read_file
1010
from torchvision.models import resnet50, ResNet50_Weights
1111

1212

@@ -24,13 +24,36 @@ def smoke_test_torchvision_read_decode() -> None:
2424
img_jpg = decode_image(str(SCRIPT_DIR / "assets" / "encode_jpeg" / "grace_hopper_517x606.jpg"))
2525
if img_jpg.shape != (3, 606, 517):
2626
raise RuntimeError(f"Unexpected shape of img_jpg: {img_jpg.shape}")
27+
2728
img_png = decode_image(str(SCRIPT_DIR / "assets" / "interlaced_png" / "wizard_low.png"))
2829
if img_png.shape != (4, 471, 354):
2930
raise RuntimeError(f"Unexpected shape of img_png: {img_png.shape}")
31+
3032
img_webp = decode_image(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.webp"))
3133
if img_webp.shape != (3, 100, 100):
3234
raise RuntimeError(f"Unexpected shape of img_webp: {img_webp.shape}")
3335

36+
if sys.platform == "linux":
37+
img_avif = decode_avif(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif"))
38+
if img_avif.shape != (3, 100, 100):
39+
raise RuntimeError(f"Unexpected shape of img_avif: {img_avif.shape}")
40+
41+
img_heic = decode_heic(
42+
str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch_incorrectly_encoded_but_who_cares.heic")
43+
)
44+
if img_heic.shape != (3, 100, 100):
45+
raise RuntimeError(f"Unexpected shape of img_heic: {img_heic.shape}")
46+
else:
47+
try:
48+
decode_avif(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif"))
49+
except RuntimeError as e:
50+
assert "torchvision-extra-decoders" in str(e)
51+
52+
try:
53+
decode_heic(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch_incorrectly_encoded_but_who_cares.heic"))
54+
except RuntimeError as e:
55+
assert "torchvision-extra-decoders" in str(e)
56+
3457

3558
def smoke_test_torchvision_decode_jpeg(device: str = "cpu"):
3659
img_jpg_data = read_file(str(SCRIPT_DIR / "assets" / "encode_jpeg" / "grace_hopper_517x606.jpg"))

0 commit comments

Comments
 (0)