
Making Pillow-SIMD, optimizing image processing in Python - igordebatur
https://blog.uploadcare.com/the-fastest-production-ready-image-resize-out-there-part-1-general-optimizations-1b9b0faf2959
======
Veratyr
Interesting, I wonder if it beats VIPS yet.

VIPS page says they beat Pillow-SIMD 4.3.0 by a tad:
[https://github.com/jcupitt/libvips/wiki/Speed-and-memory-
use](https://github.com/jcupitt/libvips/wiki/Speed-and-memory-use)

Pillow-SIMD's page says it beats VIPS: [https://python-pillow.org/pillow-
perf/](https://python-pillow.org/pillow-perf/) (you have to select "Full
operations cycle", it doesn't let you look at VIPS tests separately for some
reason.

~~~
igordebatur
Hi there, there's the 'see 1' thing in VIPS testing, it says the following:
"Pillow is single-threaded, so the fairest comparison for raw processing speed
would be against vips-1thread."

~~~
pen2l
Can you please comment if pillow-SIMD works with Windows at this point? I was
trying to make it work with py2.7 as I needed very fast image processing tools
(for something that works real-time) and my experience was that pillow-SIMD
does not work with Windows. It appeared at first that an Anaconda package
would make it work but even that doesn't work because of various dependency
issues.

~~~
Veratyr
It looks like it should, there's an installer here:
[https://www.lfd.uci.edu/~gohlke/pythonlibs/](https://www.lfd.uci.edu/~gohlke/pythonlibs/)

But there's also a bug here: [https://github.com/uploadcare/pillow-
simd/issues/9](https://github.com/uploadcare/pillow-simd/issues/9)

If you're using open source software like Python I'd really recommend either
leaving Windows, using the bash subsystem or running a Linux VM though. Most
of the open source ecosystem lives on *nix and you'll rarely find people who
port their projects to Windows.

~~~
pen2l
I would love to switch, but unfortunately the field of medical research is
windows everywhere (high speed andor cameras, spectrometers, microscope
stages, virtually everything needs windows).

~~~
Veratyr
Unless the Python is actually interacting with that hardware you should be
able to get along much better with Windows' Linux subsystem or a VM still.

------
mozumder
For image resizing, wouldn’t you use the GPU itself (assuming the server has
one)? Does Python have a library that works with the GPU for image processing?

I have a Skylake Xeon server with an integrated GPU. Any way to use that with
Python?

~~~
kozikow
> Does Python have a library that works with the GPU for image processing?

tensorflow. It's not just deep learning library and you can implement any
tensor operations there. 99% image processing is just tensor operations.

~~~
mozumder
Intriguing option but I'm dealing with the integrated GPU here. It looks like
TensorFlow is for NVidia discrete GPUs.

PythonOpenCL is probably the best option:
[https://mathema.tician.de/software/pyopencl/](https://mathema.tician.de/software/pyopencl/)

One thing about integrated GPUs for server is that there's no transfer time,
since the GPUs share memory with the CPU.

~~~
Marat_Dukhan
There is transfer time. You source image is in cacheable CPU memory.
Integrated GPUs normally work with uncacheable memory allocated in a special
region of system memory. Some GPUs can access cacheable memory too, but it is
much slower (because it has to maintain coherency with CPU caches), and
requires that you allocate such cacheable memory using special OpenCL driver
calls, not your normal malloc. So, in practice, you would do a copy to GPU-
optimized buffer (in shared with CPU, but uncacheable memory).

