Comments (10)
Here is what I did the for the threaded code:
requirements:
pip install pymp-pypi
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.
from pillow_heif.
Alpine Linux:
Current build:
---------------------------------------- benchmark 'large_image': 1 tests --
Name (time in s) Min Max Mean StdDev Median IQR
----------------------------------------------------------------------------
test_pillow_convert_large 2.5099 2.5591 2.5232 0.0123 2.5207 0.0075
----------------------------------------------------------------------------
--------------------------------------------- benchmark 'small_image': 1 tests ------
Name (time in ms) Min Max Mean StdDev Median IQR
-------------------------------------------------------------------------------------
test_pillow_convert_small 853.6160 886.9666 866.4484 9.7187 866.5191 15.2944
-------------------------------------------------------------------------------------
Dev build for libheif 1.14.1
(currently unreleased, by will be soon)
---------------------------------------- benchmark 'large_image': 1 tests --
Name (time in s) Min Max Mean StdDev Median IQR
----------------------------------------------------------------------------
test_pillow_convert_large 1.1414 1.1750 1.1569 0.0108 1.1567 0.0154
----------------------------------------------------------------------------
-------------------------------------------- benchmark 'small_image': 1 tests ------
Name (time in ms) Min Max Mean StdDev Median IQR
------------------------------------------------------------------------------------
test_pillow_convert_small 424.9203 445.5481 430.4459 5.3578 428.2591 6.1504
------------------------------------------------------------------------------------
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 brew
or msys2
, probably it is only Linux bug.
from pillow_heif.
done, updated benchmarks in docs with new results.
from pillow_heif.
Will look tomorrow, just a quick question:
you run python code in cycle something like this?
e.g.:
for i in range(100):
img = Image.open(path_heic)
img.save(path_jpg)
from pillow_heif.
Looks like it is something wrong with speed(multithreading/optimization is disabled?) of compiled version of libheif that bundled in wheels.
If builded from source for example with libheif from ubuntu's repo, or ppa:strukturag the speed is ~equal.
Currently investigating further...
Edited: On Alpine this bug(speed lower 2x) present too, so can say it is present on all Linux...
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
)
from pillow_heif.
@bigcat88 that's a big improvement, and I'm glad you were able to find it. Thanks again.
from pillow_heif.
@jtressle you can take a look at benchmarks thread, new 0.9.0
version will be published in 4-6 days(still waiting a libheif
release)
from pillow_heif.
@bigcat88 is this still on schedule? Looking forward to testing it.
Thanks.
from pillow_heif.
@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.
Will publish today 0.9.0
version, it will be without this bug, built on libheif 1.14.0 with commits that eliminates this problem.
from pillow_heif.
@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!
from pillow_heif.
Related Issues (20)
- License inconsistency betweent the LICENSE file and the setup.cfg metadata HOT 6
- AUX images support
- How to save "nclx_profile" in a HEIC image? HOT 7
- Offline build HOT 6
- Failed to build x265 in freebsd 13.2 HOT 6
- Cannot install via PIP on raspberry pi HOT 7
- Libheif plugin support HOT 8
- issue with heic files using Pillow-SIMD but not Pillow HOT 3
- Small memory leak when opening image with `nclx` color profile
- XMP containing invalid bytes leading fail to decode image HOT 4
- Packaging as egg says "ModuleNotFoundError: No module named '_pillow_heif_cffi'" HOT 7
- `0.10.x` version, changes topic. HOT 1
- Process get crashed with a corrupted file HOT 1
- Depth Images support HOT 10
- After decoding Image dimensions not equal the one in the headers HOT 7
- crash during encoding when using with cv2 [macOS] HOT 2
- Crash when trying to get exif image data HOT 6
- EXIF data are not transferred correctly HOT 3
- support of native non-shifted HDR [v0.11.2] HOT 1
- reading support of monochrome images HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pillow_heif.