1
1
"""Run smoke tests"""
2
2
3
+ import os
3
4
import sys
4
5
from pathlib import Path
5
6
6
7
import torch
7
8
import torchvision
8
- from torchvision .io import decode_jpeg , read_file , read_image
9
+ from torchvision .io import decode_jpeg , decode_webp , read_file , read_image
9
10
from torchvision .models import resnet50 , ResNet50_Weights
10
11
12
+
11
13
SCRIPT_DIR = Path (__file__ ).parent
12
14
13
15
@@ -25,6 +27,9 @@ def smoke_test_torchvision_read_decode() -> None:
25
27
img_png = read_image (str (SCRIPT_DIR / "assets" / "interlaced_png" / "wizard_low.png" ))
26
28
if img_png .shape != (4 , 471 , 354 ):
27
29
raise RuntimeError (f"Unexpected shape of img_png: { img_png .shape } " )
30
+ img_webp = read_image (str (SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.webp" ))
31
+ if img_webp .shape != (3 , 100 , 100 ):
32
+ raise RuntimeError (f"Unexpected shape of img_webp: { img_webp .shape } " )
28
33
29
34
30
35
def smoke_test_torchvision_decode_jpeg (device : str = "cpu" ):
@@ -77,11 +82,16 @@ def main() -> None:
77
82
print (f"torchvision: { torchvision .__version__ } " )
78
83
print (f"torch.cuda.is_available: { torch .cuda .is_available ()} " )
79
84
80
- # Turn 1.11.0aHASH into 1.11 (major.minor only)
81
- version = "." .join (torchvision .__version__ .split ("." )[:2 ])
82
- if version >= "0.16" :
83
- print (f"{ torch .ops .image ._jpeg_version () = } " )
84
- assert torch .ops .image ._is_compiled_against_turbo ()
85
+ print (f"{ torch .ops .image ._jpeg_version () = } " )
86
+ if not torch .ops .image ._is_compiled_against_turbo ():
87
+ msg = "Torchvision wasn't compiled against libjpeg-turbo"
88
+ if os .getenv ("IS_M1_CONDA_BUILD_JOB" ) == "1" :
89
+ # When building the conda package on M1, it's difficult to enforce
90
+ # that we build against turbo due to interactions with the libwebp
91
+ # package. So we just accept it, instead of raising an error.
92
+ print (msg )
93
+ else :
94
+ raise ValueError (msg )
85
95
86
96
smoke_test_torchvision ()
87
97
smoke_test_torchvision_read_decode ()
0 commit comments