Coder Social home page Coder Social logo

Comments (10)

jtressle avatar jtressle commented on July 23, 2024 1

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.

bigcat88 avatar bigcat88 commented on July 23, 2024 1

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.

bigcat88 avatar bigcat88 commented on July 23, 2024 1

done, updated benchmarks in docs with new results.

from pillow_heif.

bigcat88 avatar bigcat88 commented on July 23, 2024

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.

bigcat88 avatar bigcat88 commented on July 23, 2024

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.

jtressle avatar jtressle commented on July 23, 2024

@bigcat88 that's a big improvement, and I'm glad you were able to find it. Thanks again.

from pillow_heif.

bigcat88 avatar bigcat88 commented on July 23, 2024

@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.

jtressle avatar jtressle commented on July 23, 2024

@bigcat88 is this still on schedule? Looking forward to testing it.

Thanks.

from pillow_heif.

bigcat88 avatar bigcat88 commented on July 23, 2024

@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.

jtressle avatar jtressle commented on July 23, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.