|
10 | 10 | """ |
11 | 11 |
|
12 | 12 | import argparse |
13 | | -import torch |
14 | 13 | import random |
15 | 14 | import warnings |
16 | | -from typing import Dict, Any |
17 | | -import torchvision.transforms.v2.functional as F |
18 | | -import torchvision.transforms.functional as Fv1 |
| 15 | +from typing import Any, Dict |
| 16 | + |
19 | 17 | import numpy as np |
20 | | -from utils import bench, report_stats, print_comparison_table, print_benchmark_info |
| 18 | +import torch |
| 19 | +import torchvision.transforms.functional as Fv1 |
| 20 | +import torchvision.transforms.v2.functional as F |
| 21 | +from utils import bench, print_benchmark_info, print_comparison_table, report_stats |
21 | 22 |
|
22 | 23 | # Filter out the specific TF32 warning |
23 | 24 | warnings.filterwarnings( |
@@ -64,8 +65,9 @@ def torchvision_pipeline(images: torch.Tensor, target_size: int) -> torch.Tensor |
64 | 65 | images = F.normalize(images, mean=NORM_MEAN, std=NORM_STD) |
65 | 66 | return images |
66 | 67 |
|
| 68 | + |
67 | 69 | def torchvision_v1_pipeline(images: torch.Tensor, target_size: int) -> torch.Tensor: |
68 | | - images = images.float() / 255. # rough equivalent of to_tensor() |
| 70 | + images = images.float() / 255.0 # rough equivalent of to_tensor() |
69 | 71 | images = Fv1.resize( |
70 | 72 | images, size=(target_size, target_size), interpolation=Fv1.InterpolationMode.BILINEAR, antialias=True |
71 | 73 | ) |
@@ -243,7 +245,10 @@ def main(): |
243 | 245 | ) |
244 | 246 | all_backends = ["tv", "tv-v1", "tv-compiled", "opencv", "pil", "albumentations", "kornia"] |
245 | 247 | parser.add_argument( |
246 | | - "--backends", type=str, default="all", help="Backends to benchmark (comma-separated list or 'all'). First backend is used as reference for comparison." |
| 248 | + "--backends", |
| 249 | + type=str, |
| 250 | + default="all", |
| 251 | + help="Backends to benchmark (comma-separated list or 'all'). First backend is used as reference for comparison.", |
247 | 252 | ) |
248 | 253 | parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output") |
249 | 254 | parser.add_argument("--device", type=str, default="cpu", help="Device to use: cpu or cuda (default: cpu)") |
|
0 commit comments