diff --git a/README.md b/README.md index 725bd71..5e35b91 100644 --- a/README.md +++ b/README.md @@ -65,36 +65,37 @@ This benchmark suite measures the throughput and performance characteristics of ### Performance Comparison +Images per second (higher is better) + | Transform | albumentations
1.4.20 | augly
1.0.0 | imgaug
0.4.0 | kornia
0.7.3 | torchvision
0.20.0 | |:------------------|:---------------------------|:-----------------|:------------------|:------------------|:------------------------| -| HorizontalFlip | **8325 ± 955** | 4807 ± 818 | 5585 ± 1146 | 390 ± 106 | 875 ± 69 | -| VerticalFlip | **20493 ± 1134** | 9153 ± 1291 | 10390 ± 290 | 1212 ± 402 | 3131 ± 61 | -| Rotate | **1272 ± 12** | 1119 ± 41 | 1054 ± 96 | 143 ± 11 | 147 ± 6 | -| Affine | **967 ± 3** | - | 802 ± 55 | 147 ± 9 | 128 ± 6 | -| Equalize | **961 ± 4** | - | 540 ± 39 | 152 ± 19 | 414 ± 64 | -| RandomCrop80 | **118946 ± 741** | 25272 ± 1822 | 11009 ± 404 | 1510 ± 230 | 22499 ± 5532 | -| ShiftRGB | **1873 ± 252** | - | 1563 ± 195 | - | - | -| Resize | **2365 ± 153** | 611 ± 78 | 1699 ± 105 | 232 ± 24 | 166 ± 9 | -| RandomGamma | **8608 ± 220** | - | 2315 ± 151 | 108 ± 13 | - | -| Grayscale | **3050 ± 597** | 2720 ± 932 | 1670 ± 56 | 289 ± 75 | 1626 ± 156 | -| RandomPerspective | 410 ± 20 | - | **537 ± 41** | 86 ± 11 | 96 ± 4 | -| GaussianBlur | **1734 ± 204** | 242 ± 4 | 1047 ± 122 | 176 ± 18 | 73 ± 6 | -| MedianBlur | **862 ± 30** | - | 814 ± 71 | 5 ± 0 | - | -| MotionBlur | **2975 ± 52** | - | 583 ± 52 | 73 ± 2 | - | -| Posterize | **5214 ± 101** | - | 2112 ± 281 | 430 ± 49 | 3063 ± 116 | -| JpegCompression | **845 ± 61** | 778 ± 5 | 413 ± 29 | 71 ± 3 | 617 ± 24 | -| GaussianNoise | 147 ± 10 | 67 ± 2 | **203 ± 10** | 75 ± 1 | - | -| Elastic | 171 ± 15 | - | **227 ± 17** | 1 ± 0 | 2 ± 0 | -| ColorJitter | **536 ± 41** | 255 ± 13 | - | 55 ± 18 | 45 ± 2 | -| Brightness | **4443 ± 84** | 1163 ± 86 | - | 472 ± 101 | - | -| Contrast | **4398 ± 143** | 736 ± 79 | - | 425 ± 52 | - | -| Blur | **4816 ± 59** | 246 ± 3 | - | - | - | -| RandomResizedCrop | **2952 ± 24** | - | - | 287 ± 58 | 466 ± 30 | -| Normalize | **1016 ± 84** | - | - | 626 ± 40 | 422 ± 64 | +| HorizontalFlip | **8325 ± 955** | 4807 ± 818 | 6042 ± 788 | 390 ± 106 | 914 ± 67 | +| VerticalFlip | **20493 ± 1134** | 9153 ± 1291 | 10931 ± 1844 | 1212 ± 402 | 3198 ± 200 | +| Rotate | **1272 ± 12** | 1119 ± 41 | 1136 ± 218 | 143 ± 11 | 181 ± 11 | +| Affine | **967 ± 3** | - | 774 ± 97 | 147 ± 9 | 130 ± 12 | +| Equalize | **961 ± 4** | - | 581 ± 54 | 152 ± 19 | 479 ± 12 | +| RandomCrop80 | **118946 ± 741** | 25272 ± 1822 | 11503 ± 441 | 1510 ± 230 | 32109 ± 1241 | +| ShiftRGB | **1873 ± 252** | - | 1582 ± 65 | - | - | +| Resize | **2365 ± 153** | 611 ± 78 | 1806 ± 63 | 232 ± 24 | 195 ± 4 | +| RandomGamma | **8608 ± 220** | - | 2318 ± 269 | 108 ± 13 | - | +| Grayscale | **3050 ± 597** | 2720 ± 932 | 1681 ± 156 | 289 ± 75 | 1838 ± 130 | +| RandomPerspective | 410 ± 20 | - | **554 ± 22** | 86 ± 11 | 96 ± 5 | +| GaussianBlur | **1734 ± 204** | 242 ± 4 | 1090 ± 65 | 176 ± 18 | 79 ± 3 | +| MedianBlur | **862 ± 30** | - | 813 ± 30 | 5 ± 0 | - | +| MotionBlur | **2975 ± 52** | - | 612 ± 18 | 73 ± 2 | - | +| Posterize | **5214 ± 101** | - | 2097 ± 68 | 430 ± 49 | 3196 ± 185 | +| JpegCompression | **845 ± 61** | 778 ± 5 | 459 ± 35 | 71 ± 3 | 625 ± 17 | +| GaussianNoise | 147 ± 10 | 67 ± 2 | **206 ± 11** | 75 ± 1 | - | +| Elastic | 171 ± 15 | - | **235 ± 20** | 1 ± 0 | 2 ± 0 | +| Clahe | **423 ± 10** | - | 335 ± 43 | 94 ± 9 | - | +| CoarseDropout | **11288 ± 609** | - | 671 ± 38 | 536 ± 87 | - | +| Blur | **4816 ± 59** | 246 ± 3 | 3807 ± 325 | - | - | +| ColorJitter | **536 ± 41** | 255 ± 13 | - | 55 ± 18 | 46 ± 2 | +| Brightness | **4443 ± 84** | 1163 ± 86 | - | 472 ± 101 | 429 ± 20 | +| Contrast | **4398 ± 143** | 736 ± 79 | - | 425 ± 52 | 335 ± 35 | +| RandomResizedCrop | **2952 ± 24** | - | - | 287 ± 58 | 511 ± 10 | +| Normalize | **1016 ± 84** | - | - | 626 ± 40 | 519 ± 12 | | PlankianJitter | **1844 ± 208** | - | - | 813 ± 211 | - | -| Clahe | **423 ± 10** | - | - | 94 ± 9 | - | -| CoarseDropout | **11288 ± 609** | - | - | 536 ± 87 | - | - ## Requirements diff --git a/benchmark/__init__.py b/benchmark/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/benchmark/compare_results.py b/benchmark/compare_results.py index eada6ed..14f44c5 100644 --- a/benchmark/compare_results.py +++ b/benchmark/compare_results.py @@ -1,7 +1,8 @@ -from pathlib import Path import json +from pathlib import Path + import pandas as pd -import numpy as np + def load_results(file_path: Path) -> tuple[str, dict[str, float], dict[str, float], str]: """Load results from a JSON file and extract mean and std throughputs and version""" @@ -14,13 +15,14 @@ def load_results(file_path: Path) -> tuple[str, dict[str, float], dict[str, floa version = data["metadata"]["library_versions"].get(library, "N/A") for transform_name, results in data["results"].items(): - transform_name = transform_name.split('(')[0].strip() + transform_name_stripped = transform_name.split("(")[0].strip() if results["supported"]: - medians[transform_name] = results["median_throughput"] - stds[transform_name] = results["std_throughput"] + medians[transform_name_stripped] = results["median_throughput"] + stds[transform_name_stripped] = results["std_throughput"] return library, medians, stds, version + def create_comparison_table(results_dir: Path) -> pd.DataFrame: """Create a comparison table from all result files in the directory""" result_files = list(results_dir.glob("*_results.json")) @@ -55,16 +57,14 @@ def create_comparison_table(results_dir: Path) -> pd.DataFrame: median = df_medians.loc[idx, library] std = df_stds.loc[idx, library] # Bold if it's the maximum value - if median == max_values[idx]: - value = f"**{median:.0f} ± {std:.0f}**" - else: - value = f"{median:.0f} ± {std:.0f}" + value = f"**{median:.0f} ± {std:.0f}**" if median == max_values[idx] else f"{median:.0f} ± {std:.0f}" column_values.append(value) formatted_data[f"{library}
{versions[library]}"] = column_values return pd.DataFrame(formatted_data) + def get_system_summary(results_dir: Path) -> str: """Extract and format system information from any result file""" result_files = list(results_dir.glob("*_results.json")) @@ -96,11 +96,13 @@ def get_system_summary(results_dir: Path) -> str: ] # Add library versions - summary.extend([ - "", - "### Library Versions", - "", - ]) + summary.extend( + [ + "", + "### Library Versions", + "", + ], + ) # Collect versions from all result files versions = {} @@ -116,6 +118,7 @@ def get_system_summary(results_dir: Path) -> str: return "\n".join(summary) + def main() -> None: import argparse diff --git a/benchmark/runner.py b/benchmark/runner.py index 607db88..5629fea 100644 --- a/benchmark/runner.py +++ b/benchmark/runner.py @@ -1,21 +1,15 @@ -import json -import numpy as np -from pathlib import Path -from typing import Any import importlib -from tqdm import tqdm -import time import json - +import os +import time from pathlib import Path from typing import Any -import importlib - -from .transforms.specs import TRANSFORM_SPECS -from .utils import get_image_loader, get_system_info, time_transform, verify_thread_settings, get_library_versions, is_variance_stable +import numpy as np +from tqdm import tqdm -import os +from .transforms.specs import TRANSFORM_SPECS +from .utils import get_image_loader, get_library_versions, get_system_info, time_transform, verify_thread_settings # Environment variables for various libraries os.environ["OMP_NUM_THREADS"] = "1" @@ -24,6 +18,7 @@ os.environ["VECLIB_MAXIMUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1" + class BenchmarkRunner: def __init__( self, @@ -55,7 +50,7 @@ def _get_implementation(self) -> Any: module = importlib.import_module(f".transforms.{self.library.lower()}_impl", package="benchmark") return getattr(module, f"{self.library.capitalize()}Impl") except (ImportError, AttributeError) as e: - raise ValueError(f"Library {self.library} not supported: {e}") + raise ValueError(f"Library {self.library} not supported: {e}") # noqa: B904 def load_images(self) -> list[Any]: """Load images using appropriate loader""" @@ -67,7 +62,7 @@ def load_images(self) -> list[Any]: try: img = self.image_loader(path) # Check if image is RGB (3 channels) - if hasattr(img, 'shape'): # numpy array or tensor + if hasattr(img, "shape"): # numpy array or tensor if len(img.shape) == 4: # batched tensor (B,C,H,W) if img.shape[1] != 3: # check channels continue @@ -76,18 +71,18 @@ def load_images(self) -> list[Any]: continue else: continue - elif hasattr(img, 'mode'): # PIL Image - if img.mode != 'RGB': - continue + elif hasattr(img, "mode") and img.mode != "RGB": + continue + rgb_images.append(img) if len(rgb_images) >= self.num_images: break - except Exception as e: + except Exception: # noqa: S112, BLE001 # Skip problematic images continue - pbar.set_postfix({'loaded': len(rgb_images)}) + pbar.set_postfix({"loaded": len(rgb_images)}) if not rgb_images: raise ValueError("No valid RGB images found in the directory") @@ -101,7 +96,7 @@ def _perform_warmup( self, transform: Any, transform_spec: Any, - warmup_subset: list[Any] + warmup_subset: list[Any], ) -> tuple[list[float], float, bool, str | None]: """Perform adaptive warmup until performance stabilizes or early stopping conditions are met. @@ -123,10 +118,7 @@ def _perform_warmup( max_time_per_transform = 60 start_time = time.time() - with tqdm(total=self.max_warmup_iterations, - desc=f"Warming up {transform_spec.name}", - leave=False) as pbar: - + with tqdm(total=self.max_warmup_iterations, desc=f"Warming up {transform_spec.name}", leave=False) as pbar: for i in range(self.max_warmup_iterations): elapsed = time_transform(lambda x: self.impl.__call__(transform, x), warmup_subset) throughput = len(warmup_subset) / elapsed @@ -137,20 +129,32 @@ def _perform_warmup( total_time = time.time() - start_time # Stop if transform is too slow - if (i >= min_iterations_before_stopping and - time_per_image > slow_transform_threshold): - return warmup_throughputs, time_per_image, True, \ - f"Transform too slow: {time_per_image:.3f} sec/image > {slow_transform_threshold} sec/image threshold" + if i >= min_iterations_before_stopping and time_per_image > slow_transform_threshold: + return ( + warmup_throughputs, + time_per_image, + True, + ( + f"Transform too slow: {time_per_image:.3f} sec/image > {slow_transform_threshold}" + " sec/image threshold" + ), + ) # Stop if total time exceeds maximum if total_time > max_time_per_transform: - return warmup_throughputs, time_per_image, True, \ - f"Transform timeout: {total_time:.1f} sec > {max_time_per_transform} sec limit" + return ( + warmup_throughputs, + time_per_image, + True, + f"Transform timeout: {total_time:.1f} sec > {max_time_per_transform} sec limit", + ) # Variance stability check - if (i >= self.warmup_window * self.min_warmup_windows and - len(warmup_throughputs) >= self.warmup_window * 2): - recent_mean = np.mean(warmup_throughputs[-self.warmup_window:]) + if ( + i >= self.warmup_window * self.min_warmup_windows + and len(warmup_throughputs) >= self.warmup_window * 2 + ): + recent_mean = np.mean(warmup_throughputs[-self.warmup_window :]) overall_mean = np.mean(warmup_throughputs) relative_diff = abs(recent_mean - overall_mean) / overall_mean @@ -162,7 +166,6 @@ def _perform_warmup( return warmup_throughputs, time_per_image, False, None - def run_transform(self, transform_spec: Any, images: list[Any]) -> dict[str, Any]: """Run benchmark for a single transform""" if not hasattr(self.impl, transform_spec.name): @@ -173,9 +176,12 @@ def run_transform(self, transform_spec: Any, images: list[Any]) -> dict[str, Any transform = transform_fn(transform_spec.params) # Perform warmup - warmup_subset = images[:min(10, len(images))] - warmup_throughputs, time_per_image, early_stopped, early_stop_reason = \ - self._perform_warmup(transform, transform_spec, warmup_subset) + warmup_subset = images[: min(10, len(images))] + warmup_throughputs, time_per_image, early_stopped, early_stop_reason = self._perform_warmup( + transform, + transform_spec, + warmup_subset, + ) if early_stopped: return { @@ -189,16 +195,14 @@ def run_transform(self, transform_spec: Any, images: list[Any]) -> dict[str, Any "std_time": 0.0, "variance_stable": False, "early_stopped": True, - "early_stop_reason": early_stop_reason + "early_stop_reason": early_stop_reason, } # Benchmark runs throughputs = [] times = [] - for _ in tqdm(range(self.num_runs), - desc=f"Benchmarking {transform_spec.name}", - leave=False): + for _ in tqdm(range(self.num_runs), desc=f"Benchmarking {transform_spec.name}", leave=False): elapsed = time_transform(lambda x: self.impl.__call__(transform, x), images) throughput = len(images) / elapsed throughputs.append(throughput) @@ -215,10 +219,10 @@ def run_transform(self, transform_spec: Any, images: list[Any]) -> dict[str, Any "std_throughput": std_throughput, "times": times, "mean_time": len(images) / median_throughput, - "std_time": std_throughput / (median_throughput ** 2) * len(images), + "std_time": std_throughput / (median_throughput**2) * len(images), "variance_stable": True, "early_stopped": False, - "early_stop_reason": None + "early_stop_reason": None, } def run(self, output_path: Path | None = None) -> dict[str, Any]: @@ -237,30 +241,30 @@ def run(self, output_path: Path | None = None) -> dict[str, Any]: "max_warmup_iterations": self.max_warmup_iterations, "warmup_window": self.warmup_window, "warmup_threshold": self.warmup_threshold, - "min_warmup_windows": self.min_warmup_windows - } + "min_warmup_windows": self.min_warmup_windows, + }, } # Run benchmarks results = { - str(spec): self.run_transform(spec, images) - for spec in tqdm(TRANSFORM_SPECS, desc="Running transforms") + str(spec): self.run_transform(spec, images) for spec in tqdm(TRANSFORM_SPECS, desc="Running transforms") } # Combine results and metadata full_results = { "metadata": metadata, - "results": results + "results": results, } if output_path: output_path = Path(output_path) output_path.parent.mkdir(parents=True, exist_ok=True) - with open(output_path, 'w') as f: + with open(output_path, "w") as f: json.dump(full_results, f, indent=2) return full_results + def main() -> None: """CLI entry point""" import argparse @@ -286,10 +290,11 @@ def main() -> None: max_warmup_iterations=args.max_warmup, warmup_window=args.warmup_window, warmup_threshold=args.warmup_threshold, - min_warmup_windows=args.min_warmup_windows + min_warmup_windows=args.min_warmup_windows, ) runner.run(args.output) + if __name__ == "__main__": main() diff --git a/benchmark/transforms/albumentations_impl.py b/benchmark/transforms/albumentations_impl.py index ca11b70..dc0b7d4 100644 --- a/benchmark/transforms/albumentations_impl.py +++ b/benchmark/transforms/albumentations_impl.py @@ -1,4 +1,3 @@ - from typing import Any import albumentations as A @@ -9,6 +8,7 @@ cv2.setNumThreads(0) cv2.ocl.setUseOpenCL(False) + class AlbumentationsImpl: """Albumentations implementations of transforms""" @@ -25,7 +25,7 @@ def Rotate(params: dict[str, Any]) -> A.BasicTransform: return A.Rotate( limit=(params["angle"], params["angle"]), interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod @@ -36,7 +36,7 @@ def Affine(params: dict[str, Any]) -> A.BasicTransform: scale=params["scale"], shear=params["shear"], interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod @@ -44,7 +44,7 @@ def Clahe(params: dict[str, Any]) -> A.BasicTransform: return A.CLAHE( clip_limit=params["clip_limit"], tile_grid_size=params["tile_grid_size"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -56,7 +56,7 @@ def RandomCrop80(params: dict[str, Any]) -> A.BasicTransform: return A.RandomCrop( height=params["height"], width=params["width"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -67,7 +67,7 @@ def RandomResizedCrop(params: dict[str, Any]) -> A.BasicTransform: scale=params["scale"], ratio=params["ratio"], interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod @@ -77,7 +77,7 @@ def ShiftRGB(params: dict[str, Any]) -> A.BasicTransform: r_shift_limit=shift, g_shift_limit=shift, b_shift_limit=shift, - p=params["p"] + p=params["p"], ) @staticmethod @@ -86,14 +86,14 @@ def Resize(params: dict[str, Any]) -> A.BasicTransform: height=params["target_size"], width=params["target_size"], interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod def RandomGamma(params: dict[str, Any]) -> A.BasicTransform: return A.RandomGamma( gamma_limit=(params["gamma"], params["gamma"]), - p=params["p"] + p=params["p"], ) @staticmethod @@ -107,14 +107,14 @@ def ColorJitter(params: dict[str, Any]) -> A.BasicTransform: contrast=params["contrast"], saturation=params["saturation"], hue=params["hue"], - p=params["p"] + p=params["p"], ) @staticmethod def PlankianJitter(params: dict[str, Any]) -> A.BasicTransform: return A.PlanckianJitter( mode=params["mode"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -122,7 +122,7 @@ def RandomPerspective(params: dict[str, Any]) -> A.BasicTransform: return A.Perspective( scale=params["scale"], interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod @@ -130,28 +130,28 @@ def GaussianBlur(params: dict[str, Any]) -> A.BasicTransform: return A.GaussianBlur( blur_limit=params["kernel_size"][0], # assuming square kernel sigma_limit=(params["sigma"], params["sigma"]), - p=params["p"] + p=params["p"], ) @staticmethod def MedianBlur(params: dict[str, Any]) -> A.BasicTransform: return A.MedianBlur( blur_limit=(params["blur_limit"], params["blur_limit"]), - p=params["p"] + p=params["p"], ) @staticmethod def MotionBlur(params: dict[str, Any]) -> A.BasicTransform: return A.MotionBlur( blur_limit=params["kernel_size"], - p=params["p"] + p=params["p"], ) @staticmethod def Posterize(params: dict[str, Any]) -> A.BasicTransform: return A.Posterize( num_bits=params["bits"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -159,7 +159,7 @@ def JpegCompression(params: dict[str, Any]) -> A.BasicTransform: return A.ImageCompression( quality_lower=params["quality"], quality_upper=params["quality"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -168,7 +168,7 @@ def GaussianNoise(params: dict[str, Any]) -> A.BasicTransform: var_limit=params["var"] * 255, # convert to 0-255 range mean=params["mean"], per_channel=params["per_channel"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -179,7 +179,7 @@ def Elastic(params: dict[str, Any]) -> A.BasicTransform: interpolation=cv2.INTER_LINEAR if params["interpolation"] == "bilinear" else cv2.INTER_NEAREST, approximate=params["approximate"], same_dxdy=params["same_dxdy"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -187,7 +187,7 @@ def Normalize(params: dict[str, Any]) -> A.BasicTransform: return A.Normalize( mean=params["mean"], std=params["std"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -195,7 +195,7 @@ def Brightness(params: dict[str, Any]) -> A.BasicTransform: return A.RandomBrightnessContrast( brightness_limit=params["brightness_limit"], contrast_limit=(0.0, 0.0), - p=params["p"] + p=params["p"], ) @staticmethod @@ -203,14 +203,14 @@ def Contrast(params: dict[str, Any]) -> A.BasicTransform: return A.RandomBrightnessContrast( brightness_limit=(0.0, 0.0), contrast_limit=params["contrast_limit"], - p=params["p"] + p=params["p"], ) @staticmethod def Solarize(params: dict[str, Any]) -> A.BasicTransform: return A.Solarize( threshold=params["threshold"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -219,14 +219,14 @@ def CoarseDropout(params: dict[str, Any]) -> A.BasicTransform: hole_height_range=params["hole_height_range"], hole_width_range=params["hole_width_range"], num_holes_range=params["num_holes_range"], - p=params["p"] + p=params["p"], ) @staticmethod def Blur(params: dict[str, Any]) -> A.BasicTransform: return A.Blur( blur_limit=params["radius"], - p=params["p"] + p=params["p"], ) @staticmethod diff --git a/benchmark/transforms/augly_impl.py b/benchmark/transforms/augly_impl.py index 0dcfd82..4baee26 100644 --- a/benchmark/transforms/augly_impl.py +++ b/benchmark/transforms/augly_impl.py @@ -4,7 +4,7 @@ from PIL import Image Image.MAX_IMAGE_PIXELS = None # Disable image size check -if hasattr(Image.core, 'set_threads'): +if hasattr(Image.core, "set_threads"): Image.core.set_threads(1) @@ -25,7 +25,7 @@ def Rotate(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.RandomRotation( min_degrees=params["angle"], max_degrees=params["angle"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -37,7 +37,7 @@ def RandomCrop80(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: y1=0.25, x2=0.75, y2=0.75, - p=params["p"] + p=params["p"], ) @staticmethod @@ -46,7 +46,7 @@ def Resize(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: width=params["target_size"], height=params["target_size"], resample=Image.BILINEAR if params["interpolation"] == "bilinear" else Image.NEAREST, - p=params["p"] + p=params["p"], ) @staticmethod @@ -59,21 +59,21 @@ def ColorJitter(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: brightness_factor=params["brightness"], contrast_factor=params["contrast"], saturation_factor=params["saturation"], - p=params["p"] + p=params["p"], ) @staticmethod def GaussianBlur(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.Blur( radius=params["sigma"], - p=params["p"] + p=params["p"], ) @staticmethod def JpegCompression(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.EncodingQuality( quality=params["quality"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -81,14 +81,14 @@ def GaussianNoise(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.RandomNoise( mean=params["mean"], var=params["var"], - p=params["p"] + p=params["p"], ) @staticmethod def Blur(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.Blur( radius=params["radius"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -96,14 +96,14 @@ def Brightness(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.RandomBrightness( min_factor=params["brightness_limit"][0], max_factor=params["brightness_limit"][1], - p=params["p"] + p=params["p"], ) @staticmethod def Contrast(params: dict[str, Any]) -> imaugs.transforms.BaseTransform: return imaugs.Contrast( factor=params["contrast_limit"][0], - p=params["p"] + p=params["p"], ) @staticmethod diff --git a/benchmark/transforms/imgaug_impl.py b/benchmark/transforms/imgaug_impl.py index 5cb8f0a..6e6948e 100644 --- a/benchmark/transforms/imgaug_impl.py +++ b/benchmark/transforms/imgaug_impl.py @@ -1,15 +1,15 @@ # benchmark/transforms/imgaug_impl.py from typing import Any +import cv2 import numpy as np from imgaug import augmenters as iaa -import cv2 - # Ensure single thread cv2.setNumThreads(0) cv2.ocl.setUseOpenCL(False) + class ImgaugImpl: """Imgaug implementations of transforms""" @@ -36,7 +36,7 @@ def Affine(params: dict[str, Any]) -> iaa.Augmenter: rotate=(params["angle"], params["angle"]), translate_px=params["shift"], order=1 if params["interpolation"] == "bilinear" else 0, - mode=params["mode"] + mode=params["mode"], ) @staticmethod @@ -45,30 +45,24 @@ def Equalize(params: dict[str, Any]) -> iaa.Augmenter: @staticmethod def RandomCrop80(params: dict[str, Any]) -> iaa.Augmenter: - return iaa.CropToFixedSize( - width=params["width"], - height=params["height"] - ) + return iaa.CropToFixedSize(width=params["width"], height=params["height"]) @staticmethod def ShiftRGB(params: dict[str, Any]) -> iaa.Augmenter: shift = params["pixel_shift"] - return iaa.Add( - value=(-shift, shift), - per_channel=params["per_channel"] - ) + return iaa.Add(value=(-shift, shift), per_channel=params["per_channel"]) @staticmethod def Resize(params: dict[str, Any]) -> iaa.Augmenter: return iaa.Resize( size=params["target_size"], - interpolation="linear" if params["interpolation"] == "bilinear" else "nearest" + interpolation="linear" if params["interpolation"] == "bilinear" else "nearest", ) @staticmethod def RandomGamma(params: dict[str, Any]) -> iaa.Augmenter: return iaa.GammaContrast( - gamma=params["gamma"] / 100 # Convert to imgaug scale + gamma=params["gamma"] / 100, # Convert to imgaug scale ) @staticmethod @@ -84,43 +78,31 @@ def RandomPerspective(params: dict[str, Any]) -> iaa.Augmenter: @staticmethod def GaussianBlur(params: dict[str, Any]) -> iaa.Augmenter: - return iaa.GaussianBlur( - sigma=params["sigma"] - ) + return iaa.GaussianBlur(sigma=params["sigma"]) @staticmethod def MedianBlur(params: dict[str, Any]) -> iaa.Augmenter: blur_limit = params["blur_limit"] - return iaa.MedianBlur( - k=(blur_limit, blur_limit) - ) + return iaa.MedianBlur(k=(blur_limit, blur_limit)) @staticmethod def MotionBlur(params: dict[str, Any]) -> iaa.Augmenter: - return iaa.MotionBlur( - k=params["kernel_size"], - angle=[params["angle"]], - direction=params["direction"] - ) + return iaa.MotionBlur(k=params["kernel_size"], angle=[params["angle"]], direction=params["direction"]) @staticmethod def Posterize(params: dict[str, Any]) -> iaa.Augmenter: - return iaa.Posterize( - nb_bits=params["bits"] - ) + return iaa.Posterize(nb_bits=params["bits"]) @staticmethod def JpegCompression(params: dict[str, Any]) -> iaa.Augmenter: - return iaa.JpegCompression( - compression=params["quality"] - ) + return iaa.JpegCompression(compression=params["quality"]) @staticmethod def GaussianNoise(params: dict[str, Any]) -> iaa.Augmenter: return iaa.AdditiveGaussianNoise( loc=params["mean"], scale=(0, params["var"]), - per_channel=params["per_channel"] + per_channel=params["per_channel"], ) @staticmethod @@ -128,9 +110,21 @@ def Elastic(params: dict[str, Any]) -> iaa.Augmenter: return iaa.ElasticTransformation( alpha=params["alpha"], sigma=params["sigma"], - order=1 if params["interpolation"] == "bilinear" else 0 + order=1 if params["interpolation"] == "bilinear" else 0, ) + @staticmethod + def Clahe(params: dict[str, Any]) -> iaa.Augmenter: + return iaa.AllChannelsCLAHE(clip_limit=params["clip_limit"], tile_grid_size_px=params["tile_grid_size"]) + + @staticmethod + def CoarseDropout(params: dict[str, Any]) -> iaa.Augmenter: + return iaa.CoarseDropout() + + @staticmethod + def Blur(params: dict[str, Any]) -> iaa.Augmenter: + return iaa.AverageBlur(k=params["radius"]) + @staticmethod def __call__(transform: iaa.Augmenter, image: np.ndarray) -> np.ndarray: """Apply the transform to the image""" diff --git a/benchmark/transforms/kornia_impl.py b/benchmark/transforms/kornia_impl.py index 1e9b362..4c54baa 100644 --- a/benchmark/transforms/kornia_impl.py +++ b/benchmark/transforms/kornia_impl.py @@ -1,7 +1,8 @@ from typing import Any -import torch import kornia.augmentation as Kaug +import torch + torch.set_num_threads(1) @@ -33,7 +34,7 @@ def Affine(params: dict[str, Any]) -> Kaug.AugmentationBase2D: translate=0.1, scale=[params["scale"], params["scale"]], shear=params["shear"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -41,7 +42,7 @@ def Clahe(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomClahe( clip_limit=params["clip_limit"], grid_size=params["tile_grid_size"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -52,7 +53,7 @@ def Equalize(params: dict[str, Any]) -> Kaug.AugmentationBase2D: def RandomCrop80(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomCrop( size=(params["height"], params["width"]), - p=params["p"] + p=params["p"], ) @staticmethod @@ -61,14 +62,14 @@ def RandomResizedCrop(params: dict[str, Any]) -> Kaug.AugmentationBase2D: size=(params["height"], params["width"]), scale=params["scale"], ratio=params["ratio"], - p=params["p"] + p=params["p"], ) @staticmethod def Resize(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.Resize( size=(params["target_size"], params["target_size"]), - p=params["p"] + p=params["p"], ) @staticmethod @@ -76,7 +77,7 @@ def RandomGamma(params: dict[str, Any]) -> Kaug.AugmentationBase2D: gamma = params["gamma"] / 100 # Convert to kornia scale return Kaug.RandomGamma( gamma=(gamma, gamma), - p=params["p"] + p=params["p"], ) @staticmethod @@ -90,21 +91,21 @@ def ColorJitter(params: dict[str, Any]) -> Kaug.AugmentationBase2D: contrast=params["contrast"], saturation=params["saturation"], hue=params["hue"], - p=params["p"] + p=params["p"], ) @staticmethod def PlankianJitter(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomPlanckianJitter( mode=params["mode"], - p=params["p"] + p=params["p"], ) @staticmethod def RandomPerspective(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomPerspective( distortion_scale=params["scale"][1], # Using max scale - p=params["p"] + p=params["p"], ) @staticmethod @@ -112,7 +113,7 @@ def GaussianBlur(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomGaussianBlur( kernel_size=params["kernel_size"], sigma=(params["sigma"], params["sigma"]), - p=params["p"] + p=params["p"], ) @staticmethod @@ -122,7 +123,7 @@ def MedianBlur(params: dict[str, Any]) -> Kaug.AugmentationBase2D: kernel_size += 1 # Ensure odd kernel size return Kaug.RandomMedianBlur( kernel_size=(kernel_size, kernel_size), - p=params["p"] + p=params["p"], ) @staticmethod @@ -131,21 +132,21 @@ def MotionBlur(params: dict[str, Any]) -> Kaug.AugmentationBase2D: kernel_size=params["kernel_size"], angle=params["angle"], direction=params["direction"], - p=params["p"] + p=params["p"], ) @staticmethod def Posterize(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomPosterize( bits=params["bits"], - p=params["p"] + p=params["p"], ) @staticmethod def JpegCompression(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomJPEG( jpeg_quality=params["quality"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -155,7 +156,7 @@ def Elastic(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomElasticTransform( alpha=alpha, sigma=sigma, - p=params["p"] + p=params["p"], ) @staticmethod @@ -163,21 +164,21 @@ def Normalize(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.Normalize( mean=params["mean"], std=params["std"], - p=params["p"] + p=params["p"], ) @staticmethod def Brightness(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomBrightness( brightness=params["brightness_limit"], - p=params["p"] + p=params["p"], ) @staticmethod def Contrast(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomContrast( contrast=params["contrast_limit"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -185,7 +186,7 @@ def GaussianNoise(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomGaussianNoise( mean=params["mean"], std=params["var"], - p=params["p"] + p=params["p"], ) @staticmethod @@ -194,20 +195,20 @@ def RGBShift(params: dict[str, Any]) -> Kaug.AugmentationBase2D: r_shift_limit=params["r_shift_limit"] / 255.0, g_shift_limit=params["g_shift_limit"] / 255.0, b_shift_limit=params["b_shift_limit"] / 255.0, - p=params["p"] + p=params["p"], ) @staticmethod def Solarize(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomSolarize( threshold=params["threshold"] / 255.0, - p=params["p"] + p=params["p"], ) @staticmethod def CoarseDropout(params: dict[str, Any]) -> Kaug.AugmentationBase2D: return Kaug.RandomErasing( - p=params["p"] + p=params["p"], ) @staticmethod diff --git a/benchmark/transforms/specs.py b/benchmark/transforms/specs.py index 4bbc75a..700b3aa 100644 --- a/benchmark/transforms/specs.py +++ b/benchmark/transforms/specs.py @@ -1,9 +1,11 @@ from dataclasses import dataclass from typing import Any + @dataclass class TransformSpec: """Base class that defines exact parameters for each transform""" + name: str params: dict[str, Any] @@ -11,168 +13,224 @@ def __str__(self) -> str: params_str = ", ".join(f"{k}={v}" for k, v in self.params.items()) return f"{self.name}({params_str})" + # Define all transform specifications based on the original implementations TRANSFORM_SPECS = [ - TransformSpec("HorizontalFlip", { - "p": 1.0 - }), - - TransformSpec("VerticalFlip", { - "p": 1.0 - }), - - TransformSpec("Rotate", { - "angle": 45, - "p": 1.0, - "interpolation": "nearest", - "mode": "reflect" # from imgaug implementation - }), - - TransformSpec("Affine", { - "angle": 25.0, - "shift": (50, 50), - "scale": 2.0, - "shear": [10.0, 15.0], - "p": 1.0, - "interpolation": "bilinear", - "mode": "reflect" # from imgaug implementation - }), - - TransformSpec("Equalize", { - "p": 1.0 - }), - - TransformSpec("RandomCrop80", { - "height": 80, - "width": 80, - "p": 1.0 - }), - - TransformSpec("RandomResizedCrop", { - "height": 512, - "width": 512, - "scale": (0.08, 1.0), - "ratio": (0.75, 1.3333333333333333), - "interpolation": "bilinear", - "p": 1.0 - }), - - TransformSpec("ShiftRGB", { - "pixel_shift": 100, - "p": 1.0, - "per_channel": True # from imgaug implementation - }), - - TransformSpec("Resize", { - "target_size": 512, - "interpolation": "bilinear", - "p": 1.0 - }), - - TransformSpec("RandomGamma", { - "gamma": 120, - "p": 1.0 - }), - - TransformSpec("Grayscale", { - "p": 1.0, - "num_output_channels": 3 # from torchvision implementation - }), - - TransformSpec("ColorJitter", { - "brightness": 0.5, - "contrast": 1.5, - "saturation": 1.5, - "hue": 0.5, - "p": 1.0 - }), - - TransformSpec("PlankianJitter", { - "mode": "blackbody", - "p": 1.0 - }), - - TransformSpec("RandomPerspective", { - "scale": (0.05, 0.1), - "p": 1.0, - "interpolation": "bilinear" - }), - - TransformSpec("GaussianBlur", { - "sigma": 2.0, - "kernel_size": (5, 5), - "p": 1.0 - }), - - TransformSpec("MedianBlur", { - "blur_limit": 5, - "p": 1.0 - }), - - TransformSpec("MotionBlur", { - "kernel_size": 5, - "angle": 45, - "direction": 0.0, - "p": 1.0 - }), - - TransformSpec("Posterize", { - "bits": 4, - "p": 1.0 - }), - - TransformSpec("JpegCompression", { - "quality": 50, - "p": 1.0 - }), - - TransformSpec("GaussianNoise", { - "mean": 127, - "var": 0.010, - "per_channel": True, - "p": 1.0 - }), - - TransformSpec("Elastic", { - "alpha": 50.0, - "sigma": 5.0, - "interpolation": "bilinear", - "approximate": False, - "same_dxdy": True, - "p": 1.0 - }), - - TransformSpec("Normalize", { - "mean": (0.485, 0.456, 0.406), - "std": (0.229, 0.224, 0.225), - "p": 1.0 - }), - - TransformSpec("Clahe", { - "clip_limit": (1, 4), - "tile_grid_size": (8, 8), - "p": 1.0 - }), - - TransformSpec("Brightness", { - "brightness_limit": (0.2, 0.2), - "p": 1.0 - }), - - TransformSpec("Contrast", { - "contrast_limit": (0.2, 0.2), - "p": 1.0 - }), - - TransformSpec("CoarseDropout", { - "hole_height_range": (16, 16), - "hole_width_range": (16, 16), - "num_holes_range": (1, 1), - "p": 1.0 - }), - - TransformSpec("Blur", { - "radius": 5, - "p": 1.0 - }) + TransformSpec( + "HorizontalFlip", + { + "p": 1.0, + }, + ), + TransformSpec( + "VerticalFlip", + { + "p": 1.0, + }, + ), + TransformSpec( + "Rotate", + { + "angle": 45, + "p": 1.0, + "interpolation": "nearest", + "mode": "reflect", # from imgaug implementation + }, + ), + TransformSpec( + "Affine", + { + "angle": 25.0, + "shift": (50, 50), + "scale": 2.0, + "shear": [10.0, 15.0], + "p": 1.0, + "interpolation": "bilinear", + "mode": "reflect", # from imgaug implementation + }, + ), + TransformSpec( + "Equalize", + { + "p": 1.0, + }, + ), + TransformSpec( + "RandomCrop80", + { + "height": 80, + "width": 80, + "p": 1.0, + }, + ), + TransformSpec( + "RandomResizedCrop", + { + "height": 512, + "width": 512, + "scale": (0.08, 1.0), + "ratio": (0.75, 1.3333333333333333), + "interpolation": "bilinear", + "p": 1.0, + }, + ), + TransformSpec( + "ShiftRGB", + { + "pixel_shift": 100, + "p": 1.0, + "per_channel": True, # from imgaug implementation + }, + ), + TransformSpec( + "Resize", + { + "target_size": 512, + "interpolation": "bilinear", + "p": 1.0, + }, + ), + TransformSpec( + "RandomGamma", + { + "gamma": 120, + "p": 1.0, + }, + ), + TransformSpec( + "Grayscale", + { + "p": 1.0, + "num_output_channels": 3, # from torchvision implementation + }, + ), + TransformSpec( + "ColorJitter", + { + "brightness": 0.5, + "contrast": 1.5, + "saturation": 1.5, + "hue": 0.5, + "p": 1.0, + }, + ), + TransformSpec( + "PlankianJitter", + { + "mode": "blackbody", + "p": 1.0, + }, + ), + TransformSpec( + "RandomPerspective", + { + "scale": (0.05, 0.1), + "p": 1.0, + "interpolation": "bilinear", + }, + ), + TransformSpec( + "GaussianBlur", + { + "sigma": 2.0, + "kernel_size": (5, 5), + "p": 1.0, + }, + ), + TransformSpec( + "MedianBlur", + { + "blur_limit": 5, + "p": 1.0, + }, + ), + TransformSpec( + "MotionBlur", + { + "kernel_size": 5, + "angle": 45, + "direction": 0.0, + "p": 1.0, + }, + ), + TransformSpec( + "Posterize", + { + "bits": 4, + "p": 1.0, + }, + ), + TransformSpec( + "JpegCompression", + { + "quality": 50, + "p": 1.0, + }, + ), + TransformSpec( + "GaussianNoise", + { + "mean": 127, + "var": 0.010, + "per_channel": True, + "p": 1.0, + }, + ), + TransformSpec( + "Elastic", + { + "alpha": 50.0, + "sigma": 5.0, + "interpolation": "bilinear", + "approximate": False, + "same_dxdy": True, + "p": 1.0, + }, + ), + TransformSpec( + "Normalize", + { + "mean": (0.485, 0.456, 0.406), + "std": (0.229, 0.224, 0.225), + "p": 1.0, + }, + ), + TransformSpec( + "Clahe", + { + "clip_limit": (1, 4), + "tile_grid_size": (8, 8), + "p": 1.0, + }, + ), + TransformSpec( + "Brightness", + { + "brightness_limit": (0.2, 0.2), + "p": 1.0, + }, + ), + TransformSpec( + "Contrast", + { + "contrast_limit": (0.2, 0.2), + "p": 1.0, + }, + ), + TransformSpec( + "CoarseDropout", + { + "hole_height_range": (16, 16), + "hole_width_range": (16, 16), + "num_holes_range": (1, 1), + "p": 1.0, + }, + ), + TransformSpec( + "Blur", + { + "radius": 5, + "p": 1.0, + }, + ), ] diff --git a/benchmark/transforms/torchvision_impl.py b/benchmark/transforms/torchvision_impl.py index a4cfc78..b7269f6 100644 --- a/benchmark/transforms/torchvision_impl.py +++ b/benchmark/transforms/torchvision_impl.py @@ -1,10 +1,11 @@ from typing import Any import torch -from torchvision.transforms import v2 -from torchvision.transforms import InterpolationMode +from torchvision.transforms import InterpolationMode, v2 + torch.set_num_threads(1) + class TorchvisionImpl: """Torchvision implementations of transforms""" @@ -20,17 +21,21 @@ def VerticalFlip(params: dict[str, Any]) -> v2.Transform: def Rotate(params: dict[str, Any]) -> v2.Transform: return v2.RandomRotation( degrees=params["angle"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, ) @staticmethod def Affine(params: dict[str, Any]) -> v2.Transform: return v2.RandomAffine( degrees=params["angle"], - translate=[x/100 for x in params["shift"]], # Convert to relative coordinates + translate=[x / 100 for x in params["shift"]], # Convert to relative coordinates scale=(params["scale"], params["scale"]), shear=params["shear"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, ) @staticmethod @@ -39,9 +44,7 @@ def Equalize(params: dict[str, Any]) -> v2.Transform: @staticmethod def RandomCrop80(params: dict[str, Any]) -> v2.Transform: - return v2.RandomCrop( - size=(params["height"], params["width"]) - ) + return v2.RandomCrop(size=(params["height"], params["width"])) @staticmethod def RandomResizedCrop(params: dict[str, Any]) -> v2.Transform: @@ -49,15 +52,19 @@ def RandomResizedCrop(params: dict[str, Any]) -> v2.Transform: size=(params["height"], params["width"]), scale=params["scale"], ratio=params["ratio"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, ) @staticmethod def Resize(params: dict[str, Any]) -> v2.Transform: return v2.Resize( size=params["target_size"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST, - antialias=True + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, + antialias=True, ) @staticmethod @@ -72,7 +79,7 @@ def ColorJitter(params: dict[str, Any]) -> v2.Transform: brightness=params["brightness"], contrast=params["contrast"], saturation=params["saturation"], - hue=params["hue"] + hue=params["hue"], ) @staticmethod @@ -80,40 +87,45 @@ def RandomPerspective(params: dict[str, Any]) -> v2.Transform: return v2.RandomPerspective( distortion_scale=params["scale"][1], # Using max scale p=params["p"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, ) @staticmethod def GaussianBlur(params: dict[str, Any]) -> v2.Transform: - return v2.GaussianBlur( - kernel_size=params["kernel_size"], - sigma=(params["sigma"], params["sigma"]) - ) + return v2.GaussianBlur(kernel_size=params["kernel_size"], sigma=(params["sigma"], params["sigma"])) @staticmethod def Posterize(params: dict[str, Any]) -> v2.Transform: - return v2.RandomPosterize( - bits=params["bits"], - p=params["p"] - ) + return v2.RandomPosterize(bits=params["bits"], p=params["p"]) @staticmethod def Elastic(params: dict[str, Any]) -> v2.Transform: return v2.ElasticTransform( alpha=params["alpha"], sigma=params["sigma"], - interpolation=InterpolationMode.BILINEAR if params["interpolation"] == "bilinear" else InterpolationMode.NEAREST + interpolation=InterpolationMode.BILINEAR + if params["interpolation"] == "bilinear" + else InterpolationMode.NEAREST, ) @staticmethod def Normalize(params: dict[str, Any]) -> v2.Transform: - return v2.Compose([ - v2.ConvertImageDtype(torch.float32), # Convert to float32 first - v2.Normalize( - mean=params["mean"], - std=params["std"] + return v2.Compose( + [ + v2.ConvertImageDtype(torch.float32), # Convert to float32 first + v2.Normalize(mean=params["mean"], std=params["std"]), + ], ) - ]) + + @staticmethod + def Brightness(params: dict[str, Any]) -> v2.Transform: + return v2.ColorJitter(brightness=params["brightness_limit"], contrast=0.0, saturation=0.0, hue=0.0) + + @staticmethod + def Contrast(params: dict[str, Any]) -> v2.Transform: + return v2.ColorJitter(brightness=0.0, contrast=params["contrast_limit"], saturation=0.0, hue=0.0) @staticmethod def JpegCompression(params: dict[str, Any]) -> v2.Transform: diff --git a/benchmark/utils.py b/benchmark/utils.py index a30f20f..0854611 100644 --- a/benchmark/utils.py +++ b/benchmark/utils.py @@ -1,14 +1,14 @@ -from pathlib import Path -from typing import Any, Callable, Any -from functools import lru_cache -import sys -import platform -from datetime import datetime -import pkg_resources import multiprocessing import platform import sys +from collections.abc import Callable +from datetime import UTC, datetime +from functools import cache +from pathlib import Path +from typing import Any + import numpy as np +import pkg_resources def read_img_cv2(path: Path) -> np.ndarray: @@ -20,6 +20,7 @@ def read_img_cv2(path: Path) -> np.ndarray: raise ValueError(f"Failed to load image: {path}") return cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + def read_img_torch(path: Path) -> Any: # torch.Tensor """Read image using torchvision""" import torchvision @@ -27,18 +28,23 @@ def read_img_torch(path: Path) -> Any: # torch.Tensor img = torchvision.io.read_image(str(path)) return img.unsqueeze(0) + def read_img_pillow(path: Path) -> Any: # PIL.Image.Image """Read image using PIL (for augly)""" from PIL import Image - return Image.open(path).convert('RGB') + + return Image.open(path).convert("RGB") + def read_img_kornia(path: Path) -> Any: # torch.Tensor """Read image using kornia format""" return read_img_torch(path) / 255.0 + def time_transform(transform: Any, images: list[Any]) -> float: """Time the execution of a transform on a list of images""" import time + start = time.perf_counter() for img in images: @@ -46,7 +52,8 @@ def time_transform(transform: Any, images: list[Any]) -> float: return time.perf_counter() - start -@lru_cache(maxsize=None) + +@cache def get_image_loader(library: str) -> Callable[[Path], Any]: """Get the appropriate image loader for the library""" loaders = { @@ -54,12 +61,11 @@ def get_image_loader(library: str) -> Callable[[Path], Any]: "imgaug": read_img_cv2, "torchvision": read_img_torch, "kornia": read_img_kornia, - "augly": read_img_pillow + "augly": read_img_pillow, } if library not in loaders: - raise ValueError(f"Unsupported library: {library}. " - f"Supported libraries are: {list(loaders.keys())}") + raise ValueError(f"Unsupported library: {library}. Supported libraries are: {list(loaders.keys())}") return loaders[library] @@ -70,20 +76,21 @@ def verify_thread_settings() -> dict[str, Any]: thread_vars: dict[str, Any] = { "environment": { - "OMP_NUM_THREADS": str( os.environ.get("OMP_NUM_THREADS")), + "OMP_NUM_THREADS": str(os.environ.get("OMP_NUM_THREADS")), "OPENBLAS_NUM_THREADS": str(os.environ.get("OPENBLAS_NUM_THREADS")), "MKL_NUM_THREADS": str(os.environ.get("MKL_NUM_THREADS")), "VECLIB_MAXIMUM_THREADS": str(os.environ.get("VECLIB_MAXIMUM_THREADS")), - "NUMEXPR_NUM_THREADS": str(os.environ.get("NUMEXPR_NUM_THREADS")) - } + "NUMEXPR_NUM_THREADS": str(os.environ.get("NUMEXPR_NUM_THREADS")), + }, } # OpenCV try: import cv2 + thread_vars["opencv"] = { "threads": cv2.getNumThreads(), - "opencl": cv2.ocl.useOpenCL() + "opencl": cv2.ocl.useOpenCL(), } except ImportError: thread_vars["opencv"] = "not installed" @@ -91,10 +98,11 @@ def verify_thread_settings() -> dict[str, Any]: # PyTorch try: import torch + thread_vars["pytorch"] = { "threads": torch.get_num_threads(), "gpu_available": torch.cuda.is_available(), - "gpu_device": str(torch.cuda.current_device()) if torch.cuda.is_available() else None + "gpu_device": str(torch.cuda.current_device()) if torch.cuda.is_available() else None, } except ImportError: thread_vars["pytorch"] = "not installed" @@ -102,14 +110,15 @@ def verify_thread_settings() -> dict[str, Any]: # Pillow try: from PIL import Image + thread_vars["pillow"] = { - "threads": Image.core.get_threads() if hasattr(Image.core, 'get_threads') else "unknown", - "simd": hasattr(Image.core, "simd_support") + "threads": Image.core.get_threads() if hasattr(Image.core, "get_threads") else "unknown", + "simd": hasattr(Image.core, "simd_support"), } except ImportError: thread_vars["pillow"] = "not installed" - # Convert all values to strings, replacing None with "Not set" + # Convert all values to strings, replacing None with "Not set" return {k: str(v) if v is not None else "Not set" for k, v in thread_vars.items()} @@ -120,9 +129,10 @@ def get_system_info() -> dict[str, str]: "platform": platform.platform(), "processor": platform.processor(), "cpu_count": str(multiprocessing.cpu_count()), - "timestamp": datetime.now().isoformat() + "timestamp": datetime.now(UTC).isoformat(), } + def get_library_versions(library: str) -> dict[str, str]: """Get versions of relevant libraries""" versions = {} @@ -141,10 +151,12 @@ def get_version(package: str) -> str: return versions -def is_variance_stable(throughputs: list[float], - window: int = 5, - threshold: float = 0.05, - min_windows: int = 3) -> bool: +def is_variance_stable( + throughputs: list[float], + window: int = 5, + threshold: float = 0.05, + min_windows: int = 3, +) -> bool: """Check if throughput variance has stabilized""" if len(throughputs) < window * min_windows: return False diff --git a/output/comparison.md b/output/comparison.md new file mode 100644 index 0000000..cc53c78 --- /dev/null +++ b/output/comparison.md @@ -0,0 +1,55 @@ +# Benchmark Results + +### System Information + +- Platform: macOS-15.0.1-arm64-arm-64bit +- Processor: arm +- CPU Count: 10 +- Python Version: 3.12.7 + +### Benchmark Parameters + +- Number of images: 1000 +- Runs per transform: 10 +- Max warmup iterations: 1000 + + +### Library Versions + +- albumentations: 1.4.20 +- augly: 1.0.0 +- imgaug: 0.4.0 +- kornia: 0.7.3 +- torchvision: 0.20.0 + +## Performance Comparison + +| Transform | albumentations
1.4.20 | augly
1.0.0 | imgaug
0.4.0 | kornia
0.7.3 | torchvision
0.20.0 | +|:------------------|:---------------------------|:-----------------|:------------------|:------------------|:------------------------| +| HorizontalFlip | **8325 ± 955** | 4807 ± 818 | 6042 ± 788 | 390 ± 106 | 914 ± 67 | +| VerticalFlip | **20493 ± 1134** | 9153 ± 1291 | 10931 ± 1844 | 1212 ± 402 | 3198 ± 200 | +| Rotate | **1272 ± 12** | 1119 ± 41 | 1136 ± 218 | 143 ± 11 | 181 ± 11 | +| Affine | **967 ± 3** | - | 774 ± 97 | 147 ± 9 | 130 ± 12 | +| Equalize | **961 ± 4** | - | 581 ± 54 | 152 ± 19 | 479 ± 12 | +| RandomCrop80 | **118946 ± 741** | 25272 ± 1822 | 11503 ± 441 | 1510 ± 230 | 32109 ± 1241 | +| ShiftRGB | **1873 ± 252** | - | 1582 ± 65 | - | - | +| Resize | **2365 ± 153** | 611 ± 78 | 1806 ± 63 | 232 ± 24 | 195 ± 4 | +| RandomGamma | **8608 ± 220** | - | 2318 ± 269 | 108 ± 13 | - | +| Grayscale | **3050 ± 597** | 2720 ± 932 | 1681 ± 156 | 289 ± 75 | 1838 ± 130 | +| RandomPerspective | 410 ± 20 | - | **554 ± 22** | 86 ± 11 | 96 ± 5 | +| GaussianBlur | **1734 ± 204** | 242 ± 4 | 1090 ± 65 | 176 ± 18 | 79 ± 3 | +| MedianBlur | **862 ± 30** | - | 813 ± 30 | 5 ± 0 | - | +| MotionBlur | **2975 ± 52** | - | 612 ± 18 | 73 ± 2 | - | +| Posterize | **5214 ± 101** | - | 2097 ± 68 | 430 ± 49 | 3196 ± 185 | +| JpegCompression | **845 ± 61** | 778 ± 5 | 459 ± 35 | 71 ± 3 | 625 ± 17 | +| GaussianNoise | 147 ± 10 | 67 ± 2 | **206 ± 11** | 75 ± 1 | - | +| Elastic | 171 ± 15 | - | **235 ± 20** | 1 ± 0 | 2 ± 0 | +| Clahe | **423 ± 10** | - | 335 ± 43 | 94 ± 9 | - | +| CoarseDropout | **11288 ± 609** | - | 671 ± 38 | 536 ± 87 | - | +| Blur | **4816 ± 59** | 246 ± 3 | 3807 ± 325 | - | - | +| ColorJitter | **536 ± 41** | 255 ± 13 | - | 55 ± 18 | 46 ± 2 | +| Brightness | **4443 ± 84** | 1163 ± 86 | - | 472 ± 101 | 429 ± 20 | +| Contrast | **4398 ± 143** | 736 ± 79 | - | 425 ± 52 | 335 ± 35 | +| RandomResizedCrop | **2952 ± 24** | - | - | 287 ± 58 | 511 ± 10 | +| Normalize | **1016 ± 84** | - | - | 626 ± 40 | 519 ± 12 | +| PlankianJitter | **1844 ± 208** | - | - | 813 ± 211 | - | diff --git a/output/imgaug_results.json b/output/imgaug_results.json index d146ac1..91711bd 100644 --- a/output/imgaug_results.json +++ b/output/imgaug_results.json @@ -5,7 +5,7 @@ "platform": "macOS-15.0.1-arm64-arm-64bit", "processor": "arm", "cpu_count": "10", - "timestamp": "2024-10-27T18:13:34.629232" + "timestamp": "2024-10-28T15:44:25.117855" }, "library_versions": { "imgaug": "0.4.0", @@ -33,70 +33,70 @@ "results": { "HorizontalFlip(p=1.0)": { "supported": true, - "warmup_iterations": 22, + "warmup_iterations": 16, "throughputs": [ - 1801.3457855761335, - 5077.5758398930475, - 4683.417576762179, - 5483.021034162476, - 5659.736655758723, - 5659.475057435511, - 5811.062046567376, - 5550.3354026024335, - 5675.540679065377, - 5620.340375285887 - ], - "median_throughput": 5585.33788894416, - "std_throughput": 1146.235168062563, + 3491.270144418871, + 6271.29300295955, + 6009.996138173763, + 5814.747946634742, + 6074.842068302928, + 5934.285231158384, + 6241.476485619589, + 5753.778563956966, + 6136.911412453394, + 6254.977904966986 + ], + "median_throughput": 6042.419103238346, + "std_throughput": 787.8935425285474, "times": [ - 0.5551404999569058, - 0.1969443749403581, - 0.2135192909045145, - 0.18238120805472136, - 0.1766866659745574, - 0.17669483297504485, - 0.1720855829771608, - 0.18016929202713072, - 0.17619466700125486, - 0.17792516702320427 - ], - "mean_time": 0.1790401977254482, - "std_time": 0.03674301809672224, + 0.2864287089323625, + 0.15945674991235137, + 0.16638945799786597, + 0.17197649995796382, + 0.16461333294864744, + 0.16851229104213417, + 0.16021849995013326, + 0.1737988330423832, + 0.16294841701164842, + 0.15987266704905778 + ], + "mean_time": 0.16549663022613983, + "std_time": 0.021579722299555123, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "VerticalFlip(p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 17, "throughputs": [ - 10323.277670857864, - 10724.526715416467, - 10782.518766457808, - 10430.352039738627, - 10431.517129628775, - 10456.974051532236, - 10181.640464558675, - 9860.146159677935, - 10350.257055049493, - 9878.4620240836 - ], - "median_throughput": 10390.30454739406, - "std_throughput": 290.27682589685105, + 12546.297089959899, + 10665.841841905827, + 11348.923638879467, + 10828.223765099967, + 10523.735591014178, + 10354.441214937811, + 11050.99577048541, + 11033.539192184258, + 12203.027863615825, + 5446.498261661708 + ], + "median_throughput": 10930.881478642114, + "std_throughput": 1843.6682801895888, "times": [ - 0.09686845901887864, - 0.09324420802295208, - 0.09274270897731185, - 0.09587404108606279, - 0.0958633329719305, - 0.09562995901796967, - 0.09821600001305342, - 0.10141837492119521, - 0.09661595791112632, - 0.10123033297713846 - ], - "mean_time": 0.09624356970853226, - "std_time": 0.0026887833557277083, + 0.07970479200594127, + 0.09375724999699742, + 0.08811408304609358, + 0.09235125000122935, + 0.09502329200040549, + 0.09657691605389118, + 0.0904895830899477, + 0.09063275007065386, + 0.08194687508512288, + 0.183604208054021 + ], + "mean_time": 0.09148393036315537, + "std_time": 0.015430230479324096, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -105,68 +105,68 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 1114.548305041022, - 1119.0814579488408, - 1123.7556508561677, - 1095.1125306728775, - 923.835463339237, - 976.9285304811281, - 1093.0367369772462, - 1014.7350520107144, - 864.9878955532008, - 889.2829067691389 - ], - "median_throughput": 1053.8858944939802, - "std_throughput": 96.2916335889823, + 1041.9938733944962, + 1102.0327088952029, + 1129.1059231172862, + 1142.2879570078583, + 1165.9238930428876, + 1163.3220275091187, + 1149.3535623740986, + 1144.110215546878, + 784.7266301380204, + 461.99324960904465 + ], + "median_throughput": 1135.6969400625721, + "std_throughput": 217.72628633782367, "times": [ - 0.8972244589822367, - 0.8935899999924004, - 0.8898731670342386, - 0.9131481669610366, - 1.0824438330018893, - 1.023616333026439, - 0.9148823330178857, - 0.9854789169039577, - 1.1560855419375002, - 1.1245015420718119 - ], - "mean_time": 0.9488693275282393, - "std_time": 0.08669646124644582, + 0.9596985409734771, + 0.9074140830198303, + 0.8856565000023693, + 0.8754360000602901, + 0.8576889160322025, + 0.8596072079380974, + 0.8700542920269072, + 0.8740416669752449, + 1.2743291250662878, + 2.164533791015856 + ], + "mean_time": 0.8805165926967314, + "std_time": 0.16880525166875143, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "Affine(angle=25.0, shift=(50, 50), scale=2.0, shear=[10.0, 15.0], p=1.0, interpolation=bilinear, mode=reflect)": { "supported": true, - "warmup_iterations": 38, + "warmup_iterations": 20, "throughputs": [ - 726.3434260399148, - 644.9986707763927, - 813.3399132130673, - 795.0562606183228, - 744.2359389762573, - 769.0576324682582, - 816.8388606129606, - 825.8037810158932, - 824.6254316971606, - 809.8815264480735 - ], - "median_throughput": 802.4688935331981, - "std_throughput": 54.85612019544122, + 478.1828285773287, + 722.521208718914, + 690.3148196437411, + 811.7913505705297, + 821.3521160298176, + 765.3810983919354, + 811.5182847144296, + 763.1421907491781, + 783.5228541022572, + 786.5836882282193 + ], + "median_throughput": 774.4519762470964, + "std_throughput": 96.61040614250372, "times": [ - 1.376759208040312, - 1.5503907919628546, - 1.2294982500607148, - 1.2577726250747219, - 1.343659917009063, - 1.3002926670014858, - 1.2242316670017317, - 1.210941416095011, - 1.2126717920182273, - 1.2347485000500455 - ], - "mean_time": 1.2461542223737674, - "std_time": 0.0851860880284252, + 2.0912503340514377, + 1.3840424169320613, + 1.4486144169932231, + 1.2318436249624938, + 1.2175046249758452, + 1.3065386669477448, + 1.232258125091903, + 1.3103717919439077, + 1.2762869580183178, + 1.2713205409236252 + ], + "mean_time": 1.2912356487821013, + "std_time": 0.161077515818381, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -175,68 +175,68 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 577.4599205327488, - 508.92004287448566, - 553.2570032295507, - 457.4853786903154, - 562.2121344492208, - 507.9295206382391, - 504.63938119738486, - 577.5792818784104, - 579.8909754377761, - 526.358048268023 - ], - "median_throughput": 539.8075257487869, - "std_throughput": 38.883820561027505, + 584.9104939355445, + 586.2531690799602, + 561.3170591738905, + 585.8215514771779, + 590.7450920081841, + 405.2281043592084, + 581.3974756455702, + 530.301399980946, + 579.3949204954256, + 580.0329458709996 + ], + "median_throughput": 580.7152107582849, + "std_throughput": 53.82739102934836, "times": [ - 1.7317219160031527, - 1.9649452089797705, - 1.8074782500043511, - 2.1858622080180794, - 1.77868804091122, - 1.9687770829768851, - 1.981613083044067, - 1.7313640419160947, - 1.7244620840065181, - 1.8998474580002949 - ], - "mean_time": 1.8525121497942496, - "std_time": 0.13344154459462865, + 1.7096632909961045, + 1.7057477089110762, + 1.7815243339864537, + 1.7070044580614194, + 1.6927775000222027, + 2.4677459170343354, + 1.7199937080731615, + 1.8857200830243528, + 1.7259385000215843, + 1.7240400000009686 + ], + "mean_time": 1.72201447710354, + "std_time": 0.15961618518002404, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "RandomCrop80(height=80, width=80, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 20, "throughputs": [ - 10295.939598337307, - 10312.020171310178, - 11051.519839996447, - 10492.725263669901, - 11076.318059165693, - 10966.310121719474, - 11328.695454069031, - 11155.734044792162, - 10600.322781422672, - 11501.04444805807 - ], - "median_throughput": 11008.91498085796, - "std_throughput": 403.77636625349896, + 12145.158850576978, + 11350.292162576798, + 11355.469189027024, + 11348.408481065007, + 11611.64283392847, + 10456.149517113932, + 11394.069004742301, + 11973.77747299442, + 11653.246013941916, + 11821.611932356382 + ], + "median_throughput": 11502.855919335387, + "std_throughput": 441.1347139313665, "times": [ - 0.09712566691450775, - 0.09697420906741172, - 0.09048529202118516, - 0.09530412498861551, - 0.09028270898852497, - 0.09118837502319366, - 0.08827141695655882, - 0.08964000002015382, - 0.0943367499858141, - 0.08694862492848188 - ], - "mean_time": 0.09083547304514353, - "std_time": 0.0033315923773468295, + 0.08233733393717557, + 0.08810345898382366, + 0.08806329208891839, + 0.08811808296013623, + 0.08612045808695257, + 0.09563750005327165, + 0.08776495908387005, + 0.08351583301555365, + 0.08581299998331815, + 0.08459083293564618 + ], + "mean_time": 0.08693493224748468, + "std_time": 0.0033339560833039344, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -248,33 +248,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 1574.928399882046, - 1535.115968318402, - 1567.5346862168121, - 984.0740728995662, - 1211.3638660242184, - 1444.2622192167612, - 1560.7424357639427, - 1607.9127523215311, - 1587.889381367935, - 1565.8006172212106 - ], - "median_throughput": 1563.2715264925766, - "std_throughput": 194.52697070509535, + 1566.8193636179722, + 1570.4661280794646, + 1596.413711618888, + 1562.2417615051254, + 1395.691269142315, + 1593.0433912926328, + 1488.4363380627753, + 1609.8165533315075, + 1595.024798496151, + 1621.2497199477395 + ], + "median_throughput": 1581.7547596860486, + "std_throughput": 64.92880722266759, "times": [ - 0.6349494999740273, - 0.651416583918035, - 0.6379444160265848, - 1.0161836670013145, - 0.8255157909588888, - 0.6923950420459732, - 0.6407207089941949, - 0.6219242919469252, - 0.6297667908947915, - 0.6386509169824421 - ], - "mean_time": 0.6396841387136648, - "std_time": 0.07959961887827433, + 0.6382356659742072, + 0.636753625003621, + 0.6264040409587324, + 0.6401057919720188, + 0.7164908329723403, + 0.6277292919112369, + 0.6718460000120103, + 0.6211887919344008, + 0.626949500059709, + 0.6168081250507385 + ], + "mean_time": 0.6322092561292391, + "std_time": 0.025951300392324333, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -283,103 +283,103 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 1698.19771480152, - 1772.7960913794195, - 1688.7237433719329, - 1452.1190092279655, - 1700.4374708409252, - 1773.590395460569, - 1611.327957852688, - 1650.4938897128834, - 1801.8199305209084, - 1831.7505098237102 - ], - "median_throughput": 1699.3175928212227, - "std_throughput": 105.02111521505809, + 1805.0355536336551, + 1797.257386397398, + 1809.957342187562, + 1734.8752145388978, + 1733.4179422082389, + 1861.0693144403244, + 1655.925343912322, + 1806.9810000874973, + 1812.480193768783, + 1887.282373856979 + ], + "median_throughput": 1806.0082768605762, + "std_throughput": 63.403395498404485, "times": [ - 0.5888595840660855, - 0.5640806660521775, - 0.592163166962564, - 0.6886487909359857, - 0.5880839590681717, - 0.5638280420098454, - 0.6206061249831691, - 0.6058792499825358, - 0.5549944159574807, - 0.5459258750779554 - ], - "mean_time": 0.5884715159923642, - "std_time": 0.03636867831116245, + 0.5540057080797851, + 0.5564033329719678, + 0.5524992090649903, + 0.5764103329274803, + 0.5768949170596898, + 0.5373255000449717, + 0.6038919590646401, + 0.5534092499874532, + 0.5517301670042798, + 0.529862416908145 + ], + "mean_time": 0.5537073184062711, + "std_time": 0.019438960800501382, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "RandomGamma(gamma=120, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 19, "throughputs": [ - 1828.6750883357702, - 2284.1432287188095, - 2365.297769851415, - 2258.5743934734032, - 2189.134864019432, - 2305.8609220121566, - 2323.73006887188, - 2336.7454689732576, - 2347.1988236429765, - 2329.8109503199894 - ], - "median_throughput": 2314.7954954420184, - "std_throughput": 150.72238467686634, + 2360.5955270001627, + 2272.203545228159, + 2352.758491333704, + 2325.1985920884076, + 2356.1547886440376, + 2343.69850072981, + 2282.3043038464516, + 1431.8690742103463, + 2151.5499822603856, + 2311.613604610254 + ], + "median_throughput": 2318.406098349331, + "std_throughput": 268.9088004766135, "times": [ - 0.5468439999967813, - 0.4378009169595316, - 0.42277975007891655, - 0.44275716703850776, - 0.45680145907681435, - 0.43367749999742955, - 0.4303425829857588, - 0.42794562492053956, - 0.42603974998928607, - 0.42921937501523644 - ], - "mean_time": 0.4320036054887201, - "std_time": 0.02812888384156398, + 0.42362191597931087, + 0.44010141701437533, + 0.42503300006501377, + 0.43007079197559506, + 0.42442033300176263, + 0.4266760420287028, + 0.4381536670261994, + 0.698387874988839, + 0.4647812080802396, + 0.43259824998676777 + ], + "mean_time": 0.43133081849292254, + "std_time": 0.05002948063849117, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "Grayscale(p=1.0, num_output_channels=3)": { "supported": true, - "warmup_iterations": 23, + "warmup_iterations": 16, "throughputs": [ - 1591.3569153082296, - 1641.3155226887422, - 1761.3948485963094, - 1595.5388732211732, - 1653.1702536165465, - 1599.386047958689, - 1687.3068812726162, - 1732.6630813295462, - 1698.5977075356993, - 1686.8766180996226 - ], - "median_throughput": 1670.0234358580847, - "std_throughput": 55.882838236088645, + 1798.2801696970744, + 1701.141599489283, + 1460.1148636541106, + 1661.5745165307621, + 1722.342958670056, + 1450.2910030549365, + 1290.834195575942, + 1651.4810698731972, + 1749.3444526635274, + 1728.2515901253935 + ], + "median_throughput": 1681.3580580100224, + "std_throughput": 155.79012457166408, "times": [ - 0.6283945420291275, - 0.6092673749662936, - 0.5677318749949336, - 0.6267475000349805, - 0.6048983749933541, - 0.6252399170771241, - 0.5926604170817882, - 0.5771462500561029, - 0.5887209170032293, - 0.592811584006995 - ], - "mean_time": 0.5987939920652575, - "std_time": 0.020037028868478763, + 0.5560868750326335, + 0.5878405420808122, + 0.6848776249680668, + 0.6018387920921668, + 0.580604457994923, + 0.6895167920738459, + 0.7746928330743685, + 0.6055170829640701, + 0.571642707916908, + 0.5786194589454681 + ], + "mean_time": 0.5947573125402889, + "std_time": 0.055108616138685326, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -394,33 +394,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 479.00938942305817, - 539.1009951832954, - 429.9196028420474, - 543.3383414936403, - 552.1052556313313, - 483.00699870892703, - 533.9772982983767, - 480.81961490748847, - 550.7432831300805, - 557.189229142831 - ], - "median_throughput": 536.539146740836, - "std_throughput": 41.11466555441507, + 565.63085519086, + 552.1598619866701, + 498.06225765197877, + 544.7209549982209, + 555.6932825931372, + 574.78546896938, + 577.0411346584584, + 578.4087952000102, + 550.9454430739659, + 545.498210202521 + ], + "median_throughput": 553.9265722899036, + "std_throughput": 22.35200973404784, "times": [ - 2.087641749996692, - 1.8549399999901652, - 2.326016290928237, - 1.840473833028227, - 1.8112488330807537, - 2.0703633750090376, - 1.8727387909311801, - 2.0797820409061387, - 1.8157280000159517, - 1.7947224169038236 - ], - "mean_time": 1.8637969029369426, - "std_time": 0.14282161290762482, + 1.767937499913387, + 1.8110697079682723, + 2.0077811250230297, + 1.8358023329637945, + 1.7995538749964908, + 1.739779542083852, + 1.7329787079943344, + 1.7288810410536826, + 1.8150617498904467, + 1.8331865830114111 + ], + "mean_time": 1.8052934270079375, + "std_time": 0.07284708528511497, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -429,243 +429,243 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 1075.9599954205892, - 1076.9199009158096, - 960.0043008162532, - 859.3360664354558, - 690.5804907513271, - 1032.9812398425258, - 935.6947305920056, - 1088.5023619052147, - 1075.4540821371131, - 1061.0150407617446 - ], - "median_throughput": 1046.9981403021352, - "std_throughput": 122.1573014186601, + 1083.3500658907924, + 1092.230291628081, + 1097.71321635807, + 1100.2501142443607, + 1095.5333871330538, + 1091.2151274725209, + 1089.771815850399, + 1038.3850724002327, + 892.777430632875, + 984.0022555519561 + ], + "median_throughput": 1090.4934716614598, + "std_throughput": 64.68004996280315, "times": [ - 0.9294025839772075, - 0.928574167075567, - 1.0416620000032708, - 1.1636890840018168, - 1.4480571249732748, - 0.9680717920418829, - 1.0687246249290183, - 0.918693459010683, - 0.9298397919628769, - 0.9424937079893425 - ], - "mean_time": 0.9551115341154542, - "std_time": 0.11143653753550269, + 0.9230626659700647, + 0.9155578339705244, + 0.9109847500221804, + 0.9088842500932515, + 0.912797375000082, + 0.9164095830637962, + 0.9176232909085229, + 0.9630338749848306, + 1.1200999999418855, + 1.0162578331073746 + ], + "mean_time": 0.9170160353884693, + "std_time": 0.054390644719082996, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "MedianBlur(blur_limit=5, p=1.0)": { "supported": true, - "warmup_iterations": 24, + "warmup_iterations": 16, "throughputs": [ - 599.3287066747761, - 691.2792018055446, - 818.4750556954745, - 816.6466894557365, - 821.440753653008, - 825.9691589485064, - 819.0162750420315, - 802.179495364661, - 781.322892551899, - 810.9115992280373 - ], - "median_throughput": 813.7791443418869, - "std_throughput": 70.79600656401828, + 817.5922134143515, + 762.3902712116748, + 811.4820654559302, + 832.2298194673288, + 830.1803195373285, + 755.2222196631511, + 829.2603114125382, + 814.4659194838996, + 769.7564981452288, + 763.0864802555166 + ], + "median_throughput": 812.973992469915, + "std_throughput": 30.2202548621013, "times": [ - 1.6685334589565173, - 1.446593499975279, - 1.2217843329999596, - 1.2245197499869391, - 1.2173732500523329, - 1.210698957904242, - 1.2209769579349086, - 1.2466037910198793, - 1.2798805839847773, - 1.2331800420070067 - ], - "mean_time": 1.2288346376936363, - "std_time": 0.1069044171027594, + 1.2231036250013858, + 1.3116641669766977, + 1.2323131250450388, + 1.2015911670168862, + 1.2045575840165839, + 1.3241135840071365, + 1.2058939590351656, + 1.2277984579559416, + 1.299112124950625, + 1.3104674579808488 + ], + "mean_time": 1.2300516489609674, + "std_time": 0.04572406333960801, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "MotionBlur(kernel_size=5, angle=45, direction=0.0, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 20, "throughputs": [ - 492.25324648881946, - 581.9320427807053, - 631.3318141699966, - 628.1416405717836, - 631.6722517172326, - 562.793351618235, - 583.6328911350481, - 475.2315176056552, - 592.5303549559287, - 551.3404682284785 - ], - "median_throughput": 582.7824669578767, - "std_throughput": 52.0690504715599, + 589.7831713564254, + 613.9702481704222, + 631.8156453124735, + 630.47407458545, + 610.327457454143, + 628.9245050296877, + 586.3884577948804, + 607.1447428146959, + 620.1510648108541, + 580.2743704311874 + ], + "median_throughput": 612.1488528122826, + "std_throughput": 17.972468274261356, "times": [ - 2.0314746670192108, - 1.7184137089643627, - 1.5839531250530854, - 1.591997625073418, - 1.5830994590651244, - 1.776851125061512, - 1.7134058329975232, - 2.1042375409742817, - 1.6876772500108927, - 1.813761292025447 - ], - "mean_time": 1.7159061171143288, - "std_time": 0.15330866538052906, + 1.6955383750610054, + 1.628743417095393, + 1.5827401670394465, + 1.5861080420436338, + 1.6384647090453655, + 1.590015958994627, + 1.7053541670320556, + 1.6470537080895156, + 1.6125103329541162, + 1.7233227089745924 + ], + "mean_time": 1.6335896006435109, + "std_time": 0.04796159812412815, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "Posterize(bits=4, p=1.0)": { "supported": true, - "warmup_iterations": 21, + "warmup_iterations": 17, "throughputs": [ - 2214.6607944216134, - 2069.253605522157, - 2176.031911524501, - 1748.0369354022316, - 1356.4385311561289, - 1646.9770559716067, - 2121.1651985285707, - 2103.087750554191, - 2221.733855135703, - 2181.9693295940647 - ], - "median_throughput": 2112.126474541381, - "std_throughput": 280.91825287177375, + 1952.2700848037036, + 2148.303472829784, + 2097.946474812978, + 2124.195892473739, + 2184.6413325612375, + 2133.6077592746637, + 2091.9712485250825, + 2096.2269502977038, + 1979.5613614068607, + 2085.888729462587 + ], + "median_throughput": 2097.086712555341, + "std_throughput": 68.34713090518032, "times": [ - 0.4515364170074463, - 0.4832660420797765, - 0.4595520840957761, - 0.5720702919643372, - 0.7372247079620138, - 0.6071729999966919, - 0.47143899998627603, - 0.4754913339857012, - 0.45009891607332975, - 0.4583015840034932 - ], - "mean_time": 0.4734564961206389, - "std_time": 0.06297093157259026, + 0.5122242090292275, + 0.4654835839755833, + 0.4766565839527175, + 0.47076637495774776, + 0.4577410420170054, + 0.46868970908690244, + 0.4780180419329554, + 0.47704758297186345, + 0.5051624160259962, + 0.4794119580183178 + ], + "mean_time": 0.4768520033115276, + "std_time": 0.015541305992548644, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "JpegCompression(quality=50, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 39, "throughputs": [ - 437.8939482047951, - 418.55071165489073, - 403.6720023687898, - 430.1869342077575, - 407.8396362312955, - 352.632032270414, - 386.0815664790574, - 434.90825141689703, - 359.93439481560125, - 419.9837728749122 - ], - "median_throughput": 413.1951739430931, - "std_throughput": 28.565356539126373, + 374.3545600978824, + 385.68768910898274, + 418.35935873681814, + 450.5788501973967, + 472.45417918413665, + 457.360142400023, + 472.20758332446366, + 460.23045987091575, + 461.7533634796306, + 470.8132195292551 + ], + "median_throughput": 458.79530113546934, + "std_throughput": 34.6506142645078, "times": [ - 2.283657958963886, - 2.3891967500094324, - 2.477258750004694, - 2.3245708330068737, - 2.4519441250013188, - 2.835817249957472, - 2.5901262500556186, - 2.2993355420185253, - 2.7782840828876942, - 2.3810443750116974 - ], - "mean_time": 2.4201637944051204, - "std_time": 0.16731280041472232, + 2.671264374977909, + 2.592771374969743, + 2.3902895420324057, + 2.219367375015281, + 2.1166073749773204, + 2.1864607500610873, + 2.117712707957253, + 2.172824459034018, + 2.16565829096362, + 2.123984541045502 + ], + "mean_time": 2.179621276689423, + "std_time": 0.1646163679409148, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "GaussianNoise(mean=127, var=0.01, per_channel=True, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 21, "throughputs": [ - 204.11106909562196, - 207.99187099824874, - 176.7064927032036, - 202.81656260520765, - 206.63173357688197, - 202.20630330576145, - 194.66725124915322, - 181.27469694236967, - 190.99326687759066, - 203.0165914152076 - ], - "median_throughput": 202.51143295548457, - "std_throughput": 10.304916556382164, + 198.5539103885967, + 207.51944815393173, + 196.6719661540353, + 221.5435236364253, + 207.33998581801416, + 204.8279238605258, + 188.6584454040238, + 209.88077224597862, + 212.59452483799583, + 184.9048973018899 + ], + "median_throughput": 206.08395483926998, + "std_throughput": 10.574338516584488, "times": [ - 4.8992933329427615, - 4.807880208012648, - 5.659101624973118, - 4.93056379200425, - 4.839527708012611, - 4.945444250013679, - 5.136970875086263, - 5.516489707981236, - 5.235786665929481, - 4.925705790985376 - ], - "mean_time": 4.937992810607473, - "std_time": 0.2512727460701468, + 5.03641554096248, + 4.818825458991341, + 5.084608750068583, + 4.513785750023089, + 4.822996375034563, + 4.88214683404658, + 5.3005843330174685, + 4.764609874924645, + 4.703790000057779, + 5.408185584004968 + ], + "mean_time": 4.8523913507964505, + "std_time": 0.24898022166881909, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "Elastic(alpha=50.0, sigma=5.0, interpolation=bilinear, approximate=False, same_dxdy=True, p=1.0)": { "supported": true, - "warmup_iterations": 17, + "warmup_iterations": 22, "throughputs": [ - 226.18099913883833, - 196.3671423976653, - 244.51540485758352, - 229.0866750883899, - 226.99107777343207, - 241.90548710053133, - 200.6663661644161, - 201.20059918664572, - 225.97976989798235, - 243.09295679759163 - ], - "median_throughput": 226.5860384561352, - "std_throughput": 17.250395615688895, + 256.1481178453024, + 208.78730801154057, + 229.9680376055478, + 227.16525616082876, + 202.82809294848815, + 256.16266533602237, + 254.87385446406537, + 240.98057163679556, + 226.6242642414829, + 265.20796683868076 + ], + "median_throughput": 235.47430462117168, + "std_throughput": 20.204484041938084, "times": [ - 4.421237875008956, - 5.092501666978933, - 4.089721874915995, - 4.3651600409066305, - 4.40545950003434, - 4.133845875039697, - 4.983396167051978, - 4.970164124970324, - 4.425174874952063, - 4.11365270789247 - ], - "mean_time": 4.413334585014998, - "std_time": 0.33599496286109104, + 3.903991207946092, + 4.789563166094013, + 4.348430374986492, + 4.402081625070423, + 4.9302834999980405, + 3.9037695000879467, + 3.923509542015381, + 4.14971212495584, + 4.412590167019516, + 3.770625791978091 + ], + "mean_time": 4.246747863248979, + "std_time": 0.3643851908648295, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -674,7 +674,39 @@ "supported": false }, "Clahe(clip_limit=(1, 4), tile_grid_size=(8, 8), p=1.0)": { - "supported": false + "supported": true, + "warmup_iterations": 16, + "throughputs": [ + 395.5325781998847, + 322.25350151653805, + 333.2223702925267, + 343.3610939335399, + 293.77601725783836, + 391.4096923538846, + 335.83064456364684, + 285.880034876686, + 403.322442514632, + 282.1363434513103 + ], + "median_throughput": 334.5265074280868, + "std_throughput": 43.03756153819522, + "times": [ + 2.5282367499312386, + 3.1031470419839025, + 3.0009989999234676, + 2.9123858750099316, + 3.40395383303985, + 2.554867749917321, + 2.9776913339737803, + 3.4979707499733195, + 2.479405791964382, + 3.5443856249330565 + ], + "mean_time": 2.98929973498429, + "std_time": 0.3845799015737293, + "variance_stable": true, + "early_stopped": false, + "early_stop_reason": null }, "Brightness(brightness_limit=(0.2, 0.2), p=1.0)": { "supported": false @@ -683,10 +715,74 @@ "supported": false }, "CoarseDropout(hole_height_range=(16, 16), hole_width_range=(16, 16), num_holes_range=(1, 1), p=1.0)": { - "supported": false + "supported": true, + "warmup_iterations": 20, + "throughputs": [ + 658.8579733016427, + 595.652466561014, + 640.9075250418597, + 609.9890434311362, + 628.1038962971899, + 706.5741928278744, + 687.8335600380078, + 699.4777493485426, + 682.5988072561116, + 692.2765731321988 + ], + "median_throughput": 670.7283902788772, + "std_throughput": 37.522275316747596, + "times": [ + 1.517777792061679, + 1.6788312919670716, + 1.560287500033155, + 1.639373708050698, + 1.5920932920416817, + 1.4152795419795439, + 1.453840082976967, + 1.4296380419982597, + 1.4649893749738112, + 1.4445093750255182 + ], + "mean_time": 1.4909164640909525, + "std_time": 0.08340571064336877, + "variance_stable": true, + "early_stopped": false, + "early_stop_reason": null }, "Blur(radius=5, p=1.0)": { - "supported": false + "supported": true, + "warmup_iterations": 16, + "throughputs": [ + 3808.725790453262, + 3081.1078568422126, + 3787.175277486362, + 3706.275790221003, + 4343.4118572185525, + 4112.65240915849, + 3923.385431337511, + 3791.902900208782, + 3805.3361289916916, + 4193.088225534482 + ], + "median_throughput": 3807.030959722477, + "std_throughput": 325.28869695317167, + "times": [ + 0.26255500002298504, + 0.32455858297180384, + 0.2640490409685299, + 0.26981262501794845, + 0.2302337500732392, + 0.24315208301413804, + 0.2548819170333445, + 0.26371983310673386, + 0.2627888749120757, + 0.2384877079166472 + ], + "mean_time": 0.2626718854088062, + "std_time": 0.022443787884796205, + "variance_stable": true, + "early_stopped": false, + "early_stop_reason": null } } } diff --git a/output/torchvision_results.json b/output/torchvision_results.json index 8e24cdf..2a8b120 100644 --- a/output/torchvision_results.json +++ b/output/torchvision_results.json @@ -5,7 +5,7 @@ "platform": "macOS-15.0.1-arm64-arm-64bit", "processor": "arm", "cpu_count": "10", - "timestamp": "2024-10-27T18:18:01.004843" + "timestamp": "2024-10-28T15:13:56.999948" }, "library_versions": { "torchvision": "0.20.0", @@ -35,68 +35,68 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 716.4749290256449, - 875.0357759547668, - 877.8732695746061, - 703.2988880825576, - 879.4314185443116, - 874.8283880690927, - 878.3091669453174, - 875.9827431276682, - 762.6188881505627, - 861.7556816557299 - ], - "median_throughput": 874.9320820119298, - "std_throughput": 69.07091547476486, + 747.2349971600635, + 826.678627607349, + 918.3625090705252, + 910.3992289558888, + 932.1081183399957, + 921.9494147252099, + 917.4487975974989, + 915.0388696472988, + 913.1201214157029, + 762.9225971640715 + ], + "median_throughput": 914.0794955315009, + "std_throughput": 66.8236866044236, "times": [ - 1.3957222499884665, - 1.1428104169899598, - 1.1391165839741006, - 1.4218705829698592, - 1.1370983329834417, - 1.1430813330225646, - 1.1385512501001358, - 1.1415750000160187, - 1.3112709579290822, - 1.1604217080166563 - ], - "mean_time": 1.1429458589522437, - "std_time": 0.09022907999257311, + 1.3382670830469579, + 1.209659916930832, + 1.0888946250779554, + 1.0984192079631612, + 1.072836917010136, + 1.0846582079539075, + 1.089979083975777, + 1.092849750071764, + 1.095146165927872, + 1.3107489589601755 + ], + "mean_time": 1.0939967528956984, + "std_time": 0.07997651902174176, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "VerticalFlip(p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 17, "throughputs": [ - 3151.500505992668, - 3099.8208150270666, - 3134.6169057456455, - 3038.9910079052597, - 3259.8185469021473, - 3048.973753532352, - 3184.5135023125335, - 3143.677866520088, - 3127.8937111076616, - 3095.933297201943 - ], - "median_throughput": 3131.2553084266538, - "std_throughput": 61.15436436578735, + 2933.6317125205146, + 3148.190852915995, + 2992.245216651117, + 3507.3807673917, + 3494.632463017403, + 3188.484042152071, + 3247.9562874418266, + 3207.324677877501, + 3508.073391698704, + 3080.22562846764 + ], + "median_throughput": 3197.904360014786, + "std_throughput": 200.08382708150447, "times": [ - 0.31730916688684374, - 0.32259929191786796, - 0.31901825009845197, - 0.3290565840434283, - 0.30676554096862674, - 0.32797920901793987, - 0.3140197079628706, - 0.31809875008184463, - 0.3197039581136778, - 0.3230043750954792 - ], - "mean_time": 0.3193607360309642, - "std_time": 0.006237211882022138, + 0.3408744171028957, + 0.31764274998568, + 0.33419720898382366, + 0.28511304198764265, + 0.28615312499459833, + 0.3136286670342088, + 0.3078859170200303, + 0.3117863329825923, + 0.28505675005726516, + 0.3246515420032665 + ], + "mean_time": 0.31270478645439426, + "std_time": 0.019565053665398083, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -105,33 +105,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 152.08575054575147, - 150.29090871060674, - 140.71058940776817, - 151.76121162544217, - 141.09367847756172, - 149.24780413372278, - 146.62636828885894, - 139.6311772848826, - 133.90987860253875, - 147.6980447461068 - ], - "median_throughput": 147.16220651748287, - "std_throughput": 5.800205207812243, + 165.14034557365133, + 177.36244091609115, + 178.78958909743122, + 187.73694016518803, + 186.05424947639108, + 182.54497217884233, + 184.45842326911583, + 183.2540424775017, + 154.30853738434706, + 160.5018153453899 + ], + "median_throughput": 180.6672806381368, + "std_throughput": 11.154046567223102, "times": [ - 6.575237958924845, - 6.653762417030521, - 7.106785667012446, - 6.589298999984749, - 7.087489750003442, - 6.700266083003953, - 6.820055708056316, - 7.161724332952872, - 7.467708957963623, - 6.770570332999341 - ], - "mean_time": 6.795222928933184, - "std_time": 0.26782479247456153, + 6.0554554159753025, + 5.638172291917726, + 5.593166833976284, + 5.326602207962424, + 5.374776458018459, + 5.478102124994621, + 5.42127587494906, + 5.456905542057939, + 6.480522833997384, + 6.230459125014022 + ], + "mean_time": 5.535036540473126, + "std_time": 0.3417223921545344, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -140,103 +140,103 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 117.28116917050065, - 112.05036969942034, - 114.62704469942864, - 128.05320319220968, - 128.65393043162868, - 128.76389818334448, - 128.38641640902364, - 127.91571208574723, - 129.34190118980615, - 122.57564838624704 - ], - "median_throughput": 127.98445763897845, - "std_throughput": 6.333691240871551, + 138.82881729202245, + 94.86719762701733, + 124.428247025682, + 133.87988382014836, + 124.67394257565003, + 130.3462449229185, + 123.87180976070557, + 128.9831889808849, + 134.7213653147767, + 133.5470977194724 + ], + "median_throughput": 129.6647169519017, + "std_throughput": 11.656980900269243, "times": [ - 8.526518000056967, - 8.924557792022824, - 8.723944708006456, - 7.809254084015265, - 7.772790124989115, - 7.766151958028786, - 7.788985999999568, - 7.817647915915586, - 7.731446583056822, - 8.158227292005904 - ], - "mean_time": 7.813448745634593, - "std_time": 0.3866717318193546, + 7.203115459065884, + 10.541051332955249, + 8.036760332994163, + 7.469382042065263, + 8.020922249997966, + 7.6718742499360815, + 8.07286179100629, + 7.752948333043605, + 7.422727625002153, + 7.48799500009045 + ], + "mean_time": 7.712198225604761, + "std_time": 0.6933339271338804, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "Equalize(p=1.0)": { "supported": true, - "warmup_iterations": 25, + "warmup_iterations": 19, "throughputs": [ - 450.3671645821117, - 411.62067603329945, - 455.42400886052553, - 466.451115731181, - 398.07498895451084, - 386.10850452698736, - 439.0143572278911, - 415.654094328013, - 333.53243362523045, - 242.214477344214 - ], - "median_throughput": 413.6373851806562, - "std_throughput": 64.37179888187593, + 478.63252772336807, + 498.84815959791626, + 479.2203658991048, + 488.8001328168957, + 489.50550181644314, + 482.7755344739228, + 472.18266639545107, + 454.9017511813026, + 463.7233296742268, + 471.62547845229045 + ], + "median_throughput": 478.9264468112365, + "std_throughput": 12.329574124096089, "times": [ - 2.2204105419805273, - 2.429421207983978, - 2.1957560000009835, - 2.1438473749440163, - 2.5120895000873134, - 2.589945541927591, - 2.277829832979478, - 2.405846624984406, - 2.998209167039022, - 4.128572375047952 - ], - "mean_time": 2.417576446972388, - "std_time": 0.37623230008114006, + 2.0892854999983683, + 2.004618000006303, + 2.0867226669797674, + 2.0458259580191225, + 2.042877958039753, + 2.071356000029482, + 2.1178244589827955, + 2.1982768749585375, + 2.1564582500141114, + 2.1203264999203384 + ], + "mean_time": 2.088003297078599, + "std_time": 0.053753956571194327, "variance_stable": true, "early_stopped": false, "early_stop_reason": null }, "RandomCrop80(height=80, width=80, p=1.0)": { "supported": true, - "warmup_iterations": 22, + "warmup_iterations": 24, "throughputs": [ - 14610.110917336968, - 22515.380453445236, - 18835.17020362318, - 9311.008635231736, - 17165.51572306269, - 24501.47159839807, - 22482.561838698315, - 26220.309651944077, - 26110.34230174694, - 27259.93367560033 - ], - "median_throughput": 22498.971146071774, - "std_throughput": 5532.304928332288, + 28768.216316449816, + 31013.24106870796, + 30646.095727958094, + 32286.44529871329, + 32480.055211220657, + 32534.211733944052, + 31403.008226371276, + 31930.561985032364, + 32645.466177196304, + 33296.75349723717 + ], + "median_throughput": 32108.503641872827, + "std_throughput": 1241.4068781290487, "times": [ - 0.06844575004652143, - 0.04441408405546099, - 0.0530921668978408, - 0.10739975003525615, - 0.05825633299537003, - 0.04081387503538281, - 0.04447891691233963, - 0.038138374919071794, - 0.0382990000071004, - 0.03668387501966208 - ], - "mean_time": 0.044446476841435295, - "std_time": 0.010929009210263867, + 0.034760584007017314, + 0.03224429197143763, + 0.03263058396987617, + 0.030972750042565167, + 0.03078812500461936, + 0.0307368750218302, + 0.03184408298693597, + 0.03131795802619308, + 0.030632124980911613, + 0.030032958020456135 + ], + "mean_time": 0.03114439748278696, + "std_time": 0.0012041317677568867, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -245,33 +245,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 459.84028889304227, - 457.70922204425335, - 390.2683718572008, - 467.5778863453911, - 464.00440409325427, - 430.66584114766283, - 478.8247056856954, - 489.5187807219051, - 479.4611910254879, - 499.40307796671897 - ], - "median_throughput": 465.7911452193227, - "std_throughput": 29.8813583702368, + 526.1605950886607, + 508.489432428662, + 503.15048732282565, + 506.3695168257368, + 503.78973739308447, + 512.7421663473993, + 485.6088305531467, + 512.8633390311529, + 516.2408954649244, + 515.6752933840744 + ], + "median_throughput": 510.61579938803067, + "std_throughput": 10.17829563399386, "times": [ - 2.1746680840151384, - 2.184793208958581, - 2.562339333933778, - 2.1386811250122264, - 2.1551519579952583, - 2.321985875023529, - 2.088446957990527, - 2.042822542018257, - 2.08567454200238, - 2.0023905420675874 - ], - "mean_time": 2.146884951042037, - "std_time": 0.1377266168757863, + 1.9005604169797152, + 1.9666092080296949, + 1.9874769580783322, + 1.9748424160061404, + 1.9849550829967484, + 1.9502979579847306, + 2.059270625002682, + 1.9498371669324115, + 1.9370801670011133, + 1.939204791910015 + ], + "mean_time": 1.9584196203848232, + "std_time": 0.039037910490785366, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -283,33 +283,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 178.12506360787663, - 164.82328760358695, - 168.05771776246044, - 163.75109321779502, - 172.02598821278906, - 160.8325216532227, - 143.06270010753596, - 171.932164422913, - 156.9826336579225, - 171.3081112480101 - ], - "median_throughput": 166.44050268302368, - "std_throughput": 9.398029283258564, + 195.80771281084475, + 194.95493509111037, + 191.46863928756176, + 195.17005669396278, + 191.12789261071245, + 193.00941142828935, + 198.35848270717923, + 196.46223251641334, + 196.37446105642096, + 185.05446189425257 + ], + "median_throughput": 195.06249589253656, + "std_throughput": 3.625152726118055, "times": [ - 5.614033082965761, - 6.067103833076544, - 5.950336665962823, - 6.106829458964057, - 5.813075166079216, - 6.217647959012538, - 6.989942166954279, - 5.816247374983504, - 6.370131375035271, - 5.837435207911767 - ], - "mean_time": 6.008152966855923, - "std_time": 0.33924914074756635, + 5.107051125029102, + 5.129390541114844, + 5.222787416889332, + 5.123736791079864, + 5.232098708045669, + 5.181094500003383, + 5.04137754207477, + 5.09003683400806, + 5.0923118750797585, + 5.403814583900385 + ], + "mean_time": 5.126562107310049, + "std_time": 0.0952749554130955, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -319,35 +319,35 @@ }, "Grayscale(p=1.0, num_output_channels=3)": { "supported": true, - "warmup_iterations": 17, + "warmup_iterations": 22, "throughputs": [ - 1247.5839103841367, - 1617.7275973178241, - 1662.3733574496944, - 1626.5075185523724, - 1330.4929526331641, - 1405.08345142539, - 1626.0133967862553, - 1628.7807725175921, - 1729.8005406824147, - 1669.5198064583212 - ], - "median_throughput": 1626.2604576693138, - "std_throughput": 155.5997850857127, + 1814.010556821464, + 1435.7862543737324, + 1831.6265129871279, + 1870.6874785864404, + 1889.2959193986283, + 1844.0113888135436, + 1895.9956336393402, + 1721.8672184953023, + 1788.3253206109794, + 1865.465577516206 + ], + "median_throughput": 1837.8189509003357, + "std_throughput": 129.73562287084826, "times": [ - 0.8015492919366807, - 0.6181510420283303, - 0.6015495830215514, - 0.6148142499150708, - 0.7516011249972507, - 0.7117014999967068, - 0.6150010830024257, - 0.6139561670133844, - 0.5781013339292258, - 0.5989746249979362 - ], - "mean_time": 0.6149076522669418, - "std_time": 0.05883405581749188, + 0.5512647080468014, + 0.6964825000613928, + 0.5459628329845145, + 0.5345628339564428, + 0.529297708068043, + 0.5422959999414161, + 0.5274273749673739, + 0.5807648750487715, + 0.5591823749709874, + 0.5360592079814523 + ], + "mean_time": 0.5441232388588149, + "std_time": 0.03841083871578811, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -356,33 +356,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 46.86818242005605, - 45.36789543652036, - 47.276125738695626, - 46.47433639355329, - 39.53944761097503, - 47.35278955556054, - 43.0201847481223, - 42.65400953534965, - 45.2054156678933, - 45.11150339913713 - ], - "median_throughput": 45.286655552206824, - "std_throughput": 2.3597324725936155, + 49.71341963991096, + 45.900741081775394, + 42.819476933665605, + 46.19253702195175, + 46.90982871463958, + 45.256272497602836, + 46.14830179034922, + 47.28774545226531, + 41.173356035593216, + 43.74680507179362 + ], + "median_throughput": 46.02452143606231, + "std_throughput": 2.3028893746798533, "times": [ - 21.336436541052535, - 22.042018709005788, - 21.152325499919243, - 21.517251834040508, - 25.291198041988537, - 21.11808004102204, - 23.244902499951422, - 23.44445483305026, - 22.12124333390966, - 22.167294917046092 - ], - "mean_time": 22.08155996079666, - "std_time": 1.1505944400099495, + 20.11529295798391, + 21.786140625015832, + 23.353858374990523, + 21.648518667090684, + 21.317494167014956, + 22.09638454101514, + 21.669269750011154, + 21.147127875010483, + 24.287551375105977, + 22.858812166028656 + ], + "mean_time": 21.72754802870051, + "std_time": 1.087162624007971, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -394,33 +394,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 97.07355901347576, - 95.80137998065818, - 100.08951255385082, - 98.85776891726691, - 100.11240954712775, - 93.85005589714581, - 88.299919595763, - 95.562287266813, - 93.00922403597373, - 90.83589678953388 - ], - "median_throughput": 95.6818336237356, - "std_throughput": 3.7212531721355027, + 91.96765251798172, + 105.49411087710045, + 106.44162730149928, + 96.47258601261271, + 94.08747597245144, + 104.13815161197094, + 95.5740219958042, + 97.12261033995752, + 93.80971427443507, + 95.74207811843527 + ], + "median_throughput": 96.10733206552399, + "std_throughput": 4.983666933992531, "times": [ - 10.301466332981363, - 10.438262999989092, - 9.991056749946438, - 10.11554287490435, - 9.988771667005494, - 10.65529466595035, - 11.325038624927402, - 10.464379083015956, - 10.751621791976504, - 11.008863624883816 - ], - "mean_time": 10.451304726584295, - "std_time": 0.4064716299198173, + 10.87338833406102, + 9.47920212498866, + 9.39482066698838, + 10.365638999966905, + 10.628407125012018, + 9.602628667023964, + 10.463094250066206, + 10.29626362491399, + 10.659876834019087, + 10.444728374946862 + ], + "mean_time": 10.405033398682013, + "std_time": 0.5395553053199486, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -429,33 +429,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 76.29230316459167, - 65.068146724189, - 71.57838071513818, - 76.33932333039918, - 78.4322717027558, - 79.05295560916859, - 63.8632063772406, - 63.85400012756356, - 73.95793432509595, - 68.63200435204104 - ], - "median_throughput": 72.76815752011706, - "std_throughput": 5.687562681066468, + 78.94431607902469, + 77.81194647848847, + 76.50161701009243, + 85.2352992501732, + 78.37884770528382, + 79.48868690371793, + 76.66805832015687, + 79.97620707784614, + 83.65622311901664, + 78.69227601863753 + ], + "median_throughput": 78.81829604883112, + "std_throughput": 2.6918424665266762, "times": [ - 13.107482124934904, - 15.368502874975093, - 13.970698834047653, - 13.099408749956638, - 12.74985383299645, - 12.649748416035436, - 15.65846841596067, - 15.660725999972783, - 13.521199707989581, - 14.570461833965965 - ], - "mean_time": 13.742274561830783, - "std_time": 1.0740968387062726, + 12.667156416922808, + 12.851497041992843, + 13.071619124966674, + 11.732228417065926, + 12.758544291951694, + 12.580406583030708, + 13.04324149992317, + 12.503718750085682, + 11.953683333005756, + 12.707727500004694 + ], + "mean_time": 12.687409524565966, + "std_time": 0.43330685209539216, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -468,35 +468,35 @@ }, "Posterize(bits=4, p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 41, "throughputs": [ - 2699.963217797264, - 3108.6874820476683, - 3085.894722334338, - 3091.8364312374915, - 3055.9027722756978, - 2986.1245921506766, - 3111.3429065140617, - 3070.988585301627, - 2994.435213565722, - 3015.5337684768588 - ], - "median_throughput": 3063.4456787886625, - "std_throughput": 115.67287055789863, + 2604.657868540034, + 3221.596292633165, + 3139.757675276036, + 3182.6203460805195, + 3213.498411013569, + 3105.9501787146605, + 3184.687593437601, + 3206.8168410766766, + 3259.816772933619, + 3282.095715975725 + ], + "median_throughput": 3195.752217257139, + "std_throughput": 185.10418973764743, "times": [ - 0.37037541600875556, - 0.32167916710022837, - 0.32405512500554323, - 0.323432374978438, - 0.327235542004928, - 0.33488220907747746, - 0.32140462496317923, - 0.3256280419882387, - 0.33395279198884964, - 0.33161624998319894 - ], - "mean_time": 0.32642981297955204, - "std_time": 0.012325687301872886, + 0.3839275829959661, + 0.3104051250265911, + 0.31849591701757163, + 0.3142065000720322, + 0.3111873329617083, + 0.32196266599930823, + 0.31400254205800593, + 0.3118357079802081, + 0.30676570790819824, + 0.3046833750559017 + ], + "mean_time": 0.31291537391415264, + "std_time": 0.018124667623494805, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -505,33 +505,33 @@ "supported": true, "warmup_iterations": 16, "throughputs": [ - 617.8903348227616, - 539.3150563867355, - 616.0193203637833, - 619.761786175155, - 623.1881777661731, - 593.4280365695563, - 620.3401790715602, - 618.5889537412277, - 616.6036248210617, - 605.0255693803157 - ], - "median_throughput": 617.2469798219116, - "std_throughput": 24.08050502071801, + 636.0548989087168, + 636.5283908429074, + 632.8502935205697, + 634.2278334328039, + 635.6871589938823, + 596.3881836998518, + 591.9465962944573, + 613.2549541424269, + 597.850458341883, + 616.3922745425207 + ], + "median_throughput": 624.6212840315452, + "std_throughput": 17.40816813409794, "times": [ - 1.6184101670514792, - 1.8542037500301376, - 1.623325709020719, - 1.6135231669759378, - 1.604651749948971, - 1.685124292038381, - 1.6120187499327585, - 1.6165823750197887, - 1.6217874169815332, - 1.6528227080125362 - ], - "mean_time": 1.6200970319668806, - "std_time": 0.06320444811829583, + 1.5721913339802995, + 1.5710218340391293, + 1.5801525419810787, + 1.5767204579897225, + 1.5731008340371773, + 1.6767602500040084, + 1.68934158293996, + 1.6306431660195813, + 1.6726590839680284, + 1.622343499911949 + ], + "mean_time": 1.6009701007074506, + "std_time": 0.04461896736994877, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -543,46 +543,46 @@ "supported": true, "warmup_iterations": 11, "throughputs": [], - "median_throughput": 2.290618194047865, - "std_throughput": 0.13911587318818375, + "median_throughput": 2.399504022351023, + "std_throughput": 0.2304475322239314, "times": [], - "mean_time": 0.43014599590096625, + "mean_time": 0.3882118834066205, "std_time": 0.0, "variance_stable": false, "early_stopped": true, - "early_stop_reason": "Transform too slow: 0.430 sec/image > 0.1 sec/image threshold" + "early_stop_reason": "Transform too slow: 0.388 sec/image > 0.1 sec/image threshold" }, "Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), p=1.0)": { "supported": true, - "warmup_iterations": 16, + "warmup_iterations": 23, "throughputs": [ - 478.3794228889614, - 512.1235541615192, - 503.80422573171455, - 446.06872937508473, - 472.80303941032497, - 339.57270837923625, - 339.69312462462847, - 356.69461621945237, - 398.49374005142306, - 378.0623284978212 - ], - "median_throughput": 422.28123471325387, - "std_throughput": 64.39438709798944, + 507.4255384535148, + 540.8474106484097, + 546.2630022036857, + 515.9829037949355, + 519.2584745852874, + 513.2460793584511, + 521.3678825787217, + 507.59744343151164, + 527.701120473409, + 518.9289274049187 + ], + "median_throughput": 519.0937009951031, + "std_throughput": 12.35419897045367, "times": [ - 2.090390915982425, - 1.9526537919882685, - 1.9848979999078438, - 2.2418070000130683, - 2.115045625017956, - 2.9448774160118774, - 2.9438335000304505, - 2.8035186249762774, - 2.509449708973989, - 2.6450664999429137 - ], - "mean_time": 2.368090073145307, - "std_time": 0.361114101971813, + 1.9707325000781566, + 1.8489503329619765, + 1.8306200419319794, + 1.9380487079033628, + 1.9258231669664383, + 1.9483831250108778, + 1.9180314580444247, + 1.9700650839367881, + 1.895012083929032, + 1.9270461660344154 + ], + "mean_time": 1.9264344723948665, + "std_time": 0.04584828274718679, "variance_stable": true, "early_stopped": false, "early_stop_reason": null @@ -591,10 +591,74 @@ "supported": false }, "Brightness(brightness_limit=(0.2, 0.2), p=1.0)": { - "supported": false + "supported": true, + "warmup_iterations": 16, + "throughputs": [ + 434.2925976976927, + 428.73967820437684, + 430.3781560711843, + 415.83582513803526, + 429.2010050858441, + 387.9000088099491, + 427.6703271373656, + 426.1961838830481, + 454.56303435745156, + 466.3923139085969 + ], + "median_throughput": 428.97034164511047, + "std_throughput": 19.852788678756973, + "times": [ + 2.302595082903281, + 2.332417667028494, + 2.3235379999969155, + 2.4047952089458704, + 2.3299106669146568, + 2.577983957948163, + 2.3382496669655666, + 2.3463372921105474, + 2.1999149170005694, + 2.144117666990496 + ], + "mean_time": 2.331163492946805, + "std_time": 0.10788647071408417, + "variance_stable": true, + "early_stopped": false, + "early_stop_reason": null }, "Contrast(contrast_limit=(0.2, 0.2), p=1.0)": { - "supported": false + "supported": true, + "warmup_iterations": 16, + "throughputs": [ + 365.9898446992593, + 364.3414803177351, + 366.6516680307063, + 318.3809226733769, + 301.5445943682822, + 252.0491543954552, + 350.3842678453461, + 320.15648398452805, + 307.160085832431, + 349.32689652386483 + ], + "median_throughput": 334.74169025419644, + "std_throughput": 34.99284276613602, + "times": [ + 2.7323162499815226, + 2.744677875074558, + 2.727384291938506, + 3.140891707967967, + 3.316259082988836, + 3.9674800829961896, + 2.8540094170020893, + 3.123472583014518, + 3.255631334031932, + 2.8626481669489294 + ], + "mean_time": 2.9873781160650146, + "std_time": 0.31229110607368743, + "variance_stable": true, + "early_stopped": false, + "early_stop_reason": null }, "CoarseDropout(hole_height_range=(16, 16), hole_width_range=(16, 16), num_holes_range=(1, 1), p=1.0)": { "supported": false diff --git a/pyproject.toml b/pyproject.toml index d507a71..e1345ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,3 @@ -[build-system] -build-backend = "setuptools.build_meta" - -requires = [ "setuptools>=45", "wheel" ] - [project] name = "image-augmentation-benchmark" @@ -87,12 +82,10 @@ exclude = [ ".vscode", "__pypackages__", "_build", - "benchmark", "buck-out", "build", "dist", "node_modules", - "setup.py", "site", "site-packages", "tests", @@ -115,8 +108,10 @@ lint.ignore = [ "ANN401", "ARG001", "ARG002", + "ARG004", "B008", "B027", + "C901", "D100", "D101", "D102", @@ -134,9 +129,14 @@ lint.ignore = [ "FBT002", "FBT003", "G004", + "N802", + "N812", + "PD901", "PLR0913", + "PLR2004", "PTH123", "S311", + "T201", "TCH001", "TCH002", "TCH003", diff --git a/run_all.sh b/run_all.sh index b1b3314..3eb19ed 100755 --- a/run_all.sh +++ b/run_all.sh @@ -88,7 +88,7 @@ done # Generate comparison table echo "Generating comparison table..." -python -m benchmark.compare_results -r "$OUTPUT_DIR" -o"${OUTPUT_DIR}/comparison.csv" +python -m benchmark.compare_results -r "$OUTPUT_DIR" -o"${OUTPUT_DIR}/comparison.md" echo "All benchmarks complete." echo "Individual results saved in: $OUTPUT_DIR"