-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance, no multithreading for decoding #53
Comments
Will look tomorrow, just a quick question: for i in range(100):
img = Image.open(path_heic)
img.save(path_jpg) |
Here is what I did the for the threaded code: requirements: code: import pymp
import multiprocessing as mp
with pymp.Parallel(mp.cpu_count()) as p:
for i in p.range(0,len(image_paths)):
img = Image.open(path)
...
img.save(path_jpg) I ran my single threaded code just as you had. The approximate times I got were 75 seconds threaded and 208 seconds single-threaded. I did notice heif-convert is multi-threaded. Thank you and I appreciate you looking into it. |
Looks like it is something wrong with speed(multithreading/optimization is disabled?) of compiled version of libheif that bundled in wheels. Bench code: from subprocess import DEVNULL, run
import pytest
from PIL import Image
import pillow_heif
pillow_heif.register_heif_opener()
print(pillow_heif.libheif_info())
HEIF_CONVERT_PATH = "heif-convert"
# "C:/msys64/mingw64/bin/heif-convert.exe"
def libheif_convert(f_input, f_output):
run([HEIF_CONVERT_PATH, f_input, f_output], stderr=DEVNULL, stdout=DEVNULL, check=False)
def pillow_convert(f_input, f_output):
Image.open(f_input).save(f_output)
@pytest.mark.benchmark(group="small_image")
def test_libheif_convert_small(benchmark):
benchmark.pedantic(
libheif_convert, args=("small_image.heic", "small_image_libheif.jpg"), rounds=100, warmup_rounds=3
)
@pytest.mark.benchmark(group="small_image")
def test_pillow_convert_small(benchmark):
benchmark.pedantic(
pillow_convert, args=("small_image.heic", "small_image_pillow.jpg"), rounds=100, warmup_rounds=3
)
@pytest.mark.benchmark(group="large_image")
def test_libheif_convert_large(benchmark):
benchmark.pedantic(
libheif_convert, args=("large_image.heic", "large_image_libheif.jpg"), rounds=50, warmup_rounds=3
)
@pytest.mark.benchmark(group="large_image")
def test_pillow_convert_large(benchmark):
benchmark.pedantic(
pillow_convert, args=("large_image.heic", "large_image_pillow.jpg"), rounds=50, warmup_rounds=3
) |
Alpine Linux: Current build:
Dev build for libheif
Approximate time for release of fix - release time of new version of libheif + 5-7 days. @jtressle Thank you for reporting this. P.S: i am not sure that macos or windows build are affected by this, cause I take version of libheif builded by |
@bigcat88 that's a big improvement, and I'm glad you were able to find it. Thanks again. |
@jtressle you can take a look at benchmarks thread, new |
@bigcat88 is this still on schedule? Looking forward to testing it. Thanks. |
@jtressle sorry, was waiting libheif to publish fix as a release(you can check, even created an issue in their repo) - but no luck, seems author is busy. |
done, updated benchmarks in docs with new results. |
@bigcat88 just checked out the benchmarks. Huge improvement! Also, I've been running 0.9 since yesterday, and it's running smoothly and faster. Thanks! |
Describe the bug
Hi,
Thanks for developing this extension to Pillow. I had a question regarding performance converting a .heic to a .jpg file. Running
heif-convert
is about twice as fast as doing:The command line I used was:
for file in *.heic; do heif-convert $file ${file/%.heic/.jpg}; done
Is this expected? For 100 images (of the smaller variety I attached), heif-convert took 42 seconds, pillow_heif took 75 seconds (threaded), and 208 seconds using one thread.
I've attached two files from two datasets I've observed this on.
Thanks,
Steps/Code to Reproduce
images.zip
Expected Results
Performance should mirror heif-converte
Actual Results
About two times slower.
Versions
The text was updated successfully, but these errors were encountered: