Skip to content

Commit 6d13440

Browse files
authored
Updated reamde and filter jpeg4py and pillow-simd on Mac OS (#24)
* Updated reamde and filter jpeg4py and pillow-simd on Mac OS * Updated reamde and filter jpeg4py and pillow-simd on Mac OS * Fix in GitIgnore * Fix * Can use rglob
1 parent 2fc1cc5 commit 6d13440

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939
- id: requirements-txt-fixer
4040
- repo: https://github.com/astral-sh/ruff-pre-commit
4141
# Ruff version.
42-
rev: v0.9.2
42+
rev: v0.9.3
4343
hooks:
4444
# Run the linter.
4545
- id: ruff

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,19 @@ Several factors influence real-world performance beyond raw decoding speed:
161161
- When needing extensive image processing features, OpenCV remains a strong choice
162162
- Consider dependency size and installation complexity
163163
- Evaluate the full image processing pipeline, not just JPEG decoding
164+
165+
166+
## Citation
167+
168+
If you found this work useful, please cite:
169+
```bibtex
170+
@misc{iglovikov2025speed,
171+
title={Need for Speed: A Comprehensive Benchmark of JPEG Decoders in Python},
172+
author={Vladimir Iglovikov},
173+
year={2025},
174+
eprint={2501.13131},
175+
archivePrefix={arXiv},
176+
primaryClass={eess.IV},
177+
doi={10.48550/arXiv.2501.13131}
178+
}
179+
```

imread_benchmark/benchmark_single.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,13 @@ def main():
192192
output_dir = args.output_dir / system_id
193193
output_dir.mkdir(parents=True, exist_ok=True)
194194

195-
# Get image paths
196-
image_paths = sorted(Path(args.data_dir).glob("*.*"))[: args.num_images]
197-
image_paths = [str(x) for x in image_paths]
195+
# Define supported image extensions
196+
image_extensions = {".jpg", ".jpeg", ".JPEG", ".JPG"}
197+
198+
# Get image paths recursively, filtering for supported extensions
199+
image_paths = [str(p) for p in sorted(Path(args.data_dir).rglob("*")) if p.suffix.lower() in image_extensions][
200+
: args.num_images
201+
]
198202

199203
# Run benchmark
200204
results = {

run_benchmarks.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ to output/<operating_system>/<library>_results.json
1212
Arguments:
1313
path_to_image_directory (Required) Directory containing images to benchmark
1414
num_images (Optional) Number of images to process (default: 2000)
15-
num_runs (Optional) Number of benchmark runs (default: 5)
15+
num_runs (Optional) Number of benchmark runs (default: 20)
1616
1717
Example usage:
1818
# Basic usage with defaults (2000 images, 5 runs):
@@ -62,6 +62,16 @@ mkdir -p output
6262
# List of libraries to benchmark
6363
LIBRARIES=("opencv" "pillow" "jpeg4py" "skimage" "imageio" "torchvision" "tensorflow" "kornia" "pillow-simd")
6464

65+
# Function to get libraries based on OS
66+
get_libraries() {
67+
if [[ "$(uname)" == "Darwin" ]]; then
68+
# Skip jpeg4py and pillow-simd on macOS
69+
echo "${LIBRARIES[@]}" | tr ' ' '\n' | grep -v "jpeg4py" | grep -v "pillow-simd" | tr '\n' ' '
70+
else
71+
echo "${LIBRARIES[@]}"
72+
fi
73+
}
74+
6575
# Function to create and activate virtual environment
6676
setup_venv() {
6777
local lib=$1
@@ -118,7 +128,7 @@ fi
118128

119129
DATA_DIR=$1
120130
NUM_IMAGES=${2:-2000}
121-
NUM_RUNS=${3:-5}
131+
NUM_RUNS=${3:-20}
122132

123133
echo "Starting benchmarks with:"
124134
echo " Image directory: $DATA_DIR"
@@ -127,7 +137,7 @@ echo " Number of runs: $NUM_RUNS"
127137
echo
128138

129139
# Run benchmarks for each library
130-
for lib in "${LIBRARIES[@]}"; do
140+
for lib in $(get_libraries); do
131141
echo "Processing $lib..."
132142
setup_venv "$lib"
133143
run_benchmark "$lib"

0 commit comments

Comments
 (0)