|
3 | 3 | import torch
|
4 | 4 | import torchvision
|
5 | 5 | import torchaudio
|
6 |
| -import pathlib |
| 6 | +from pathlib import Path |
7 | 7 |
|
8 | 8 | gpu_arch_ver = os.getenv('GPU_ARCH_VER')
|
9 | 9 | gpu_arch_type = os.getenv('GPU_ARCH_TYPE')
|
10 | 10 | is_cuda_system = gpu_arch_type == 'cuda'
|
| 11 | +SCRIPT_DIR = Path(__file__).parent |
11 | 12 |
|
12 | 13 | def smoke_test_cuda() -> None:
|
13 | 14 | if(not torch.cuda.is_available() and is_cuda_system):
|
@@ -42,16 +43,18 @@ def smoke_test_torchvision() -> None:
|
42 | 43 |
|
43 | 44 | def smoke_test_torchvision_read_decode() -> None:
|
44 | 45 | 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}') |
49 | 52 |
|
50 | 53 | def smoke_test_torchvision_resnet50_classify() -> None:
|
51 | 54 | from torchvision.io import read_image
|
52 | 55 | from torchvision.models import resnet50, ResNet50_Weights
|
53 | 56 |
|
54 |
| - img = read_image(str(pathlib.Path(__file__).parent / 'assets' / 'dog2.jpg')) |
| 57 | + img = read_image(str(SCRIPT_DIR / 'assets' / 'dog2.jpg')) |
55 | 58 |
|
56 | 59 | # Step 1: Initialize model with the best available weights
|
57 | 60 | weights = ResNet50_Weights.DEFAULT
|
|
0 commit comments