Skip to content

Commit 273f34f

Browse files
committed
Addressing comments
1 parent b103773 commit 273f34f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/smoke_test/smoke_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import torch
44
import torchvision
55
import torchaudio
6-
import pathlib
6+
from pathlib import Path
77

88
gpu_arch_ver = os.getenv('GPU_ARCH_VER')
99
gpu_arch_type = os.getenv('GPU_ARCH_TYPE')
1010
is_cuda_system = gpu_arch_type == 'cuda'
11+
SCRIPT_DIR = Path(__file__).parent
1112

1213
def smoke_test_cuda() -> None:
1314
if(not torch.cuda.is_available() and is_cuda_system):
@@ -42,16 +43,18 @@ def smoke_test_torchvision() -> None:
4243

4344
def smoke_test_torchvision_read_decode() -> None:
4445
from torchvision.io import read_image
45-
img_jpg = read_image(str(pathlib.Path(__file__).parent / 'assets' / 'rgb_pytorch.jpg'))
46-
assert img_jpg.ndim == 3 and img_jpg.numel() > 100
47-
img_png = read_image(str(pathlib.Path(__file__).parent / 'assets' / 'rgb_pytorch.png'))
48-
assert img_png.ndim == 3 and img_png.numel() > 100
46+
img_jpg = read_image(str(SCRIPT_DIR / 'assets' / 'rgb_pytorch.jpg'))
47+
if img_jpg.ndim != 3 or img_jpg.numel() < 100:
48+
raise RuntimeError(f'Unexpected shape of img_jpg: {img_jpg.shape}')
49+
img_png = read_image(str(SCRIPT_DIR / 'assets' / 'rgb_pytorch.png'))
50+
if img_png.ndim != 3 or img_png.numel() < 100:
51+
raise RuntimeError(f'Unexpected shape of img_png: {img_png.shape}')
4952

5053
def smoke_test_torchvision_resnet50_classify() -> None:
5154
from torchvision.io import read_image
5255
from torchvision.models import resnet50, ResNet50_Weights
5356

54-
img = read_image(str(pathlib.Path(__file__).parent / 'assets' / 'dog2.jpg'))
57+
img = read_image(str(SCRIPT_DIR / 'assets' / 'dog2.jpg'))
5558

5659
# Step 1: Initialize model with the best available weights
5760
weights = ResNet50_Weights.DEFAULT

0 commit comments

Comments
 (0)